Initial stubs for the api

This commit is contained in:
Michael Chung committed 2023-09-30 01:27:36 -04:00
1 parent 12a119cc1b
commit 7cb18d63f2
20 files changed
+337 -5

No files matched your search

@@ -23,4 +23,5 @@ pub mod user_ratings;
pub mod vocoders;
pub mod voice_clone_requests;
pub mod voice_conversion;
pub mod w2l;
pub mod w2l;
pub mod voice_designer;
@@ -0,0 +1,17 @@
use std::fmt;
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use actix_web::web::Path;
use log::{error, log, warn};
use http_server_common::request::get_request_ip::get_request_ip;
use http_server_common::response::serialize_as_json_error::serialize_as_json_error;
pub async fn create_dataset() -> HttpResponse {
// Implementation for creating a dataset
HttpResponse::Ok().json("Dataset created successfully")
}
@@ -0,0 +1,13 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
pub async fn create_voice() -> HttpResponse {
// Implementation for creating a voice
HttpResponse::Ok().json("Voice created successfully")
}
@@ -0,0 +1,19 @@
use std::fmt;
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use actix_web::web::Path;
use log::{error, log, warn};
use http_server_common::request::get_request_ip::get_request_ip;
use http_server_common::response::serialize_as_json_error::serialize_as_json_error;
pub async fn delete_dataset(dataset_token: web::Path<String>) -> HttpResponse {
// Implementation for deleting a dataset (soft delete)
HttpResponse::Ok().json(format!("Dataset {} deleted (soft delete)", dataset_token))
}
@@ -0,0 +1,15 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
pub async fn delete_sample() -> HttpResponse {
// Implementation for deleting a sample
HttpResponse::Ok().json("Sample deleted successfully")
}
@@ -0,0 +1,13 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
pub async fn delete_voice(voice_token: web::Path<String>) -> HttpResponse {
// Implementation for deleting a voice (soft delete)
HttpResponse::Ok().json(format!("Voice {} deleted (soft delete)", voice_token))
}
@@ -0,0 +1,17 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
pub async fn enqueue_tts_request() -> HttpResponse {
// Implementation for enqueuing a TTS request
HttpResponse::Ok().json("TTS request enqueued successfully")
}
@@ -0,0 +1,16 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
pub async fn enqueue_vc_request() -> HttpResponse {
// Implementation for enqueuing a VC request
HttpResponse::Ok().json("VC request enqueued successfully")
}
@@ -0,0 +1,16 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
pub async fn list_available_voices() -> HttpResponse {
// Implementation for listing available voices (paginated)
HttpResponse::Ok().json("List of available voices")
}
@@ -0,0 +1,15 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
fn list_datasets_by_user(user_token: web::Path<String>) -> HttpResponse {
// Implementation for listing datasets for a user
HttpResponse::Ok().json(format!("List of datasets for user {}", user_token))
}
@@ -0,0 +1,15 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
pub async pub async fn list_favorite_models() -> HttpResponse {
// Implementation for listing favorite models
HttpResponse::Ok().json("List of favorite models")
}
@@ -0,0 +1,14 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
pub async fn list_samples_by_dataset(data_set_token: web::Path<String>) -> HttpResponse {
// Implementation for listing samples for a dataset
HttpResponse::Ok().json(format!("List of samples for dataset {}", data_set_token))
}
@@ -0,0 +1,15 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
pub async fn list_user_models() -> HttpResponse {
// Implementation for listing models created by a particular user
HttpResponse::Ok().json("List of models created by the user")
}
@@ -0,0 +1,14 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
pub async fn list_voices_by_user(user_token: web::Path<String>) -> HttpResponse {
// Implementation for listing voices for a user
HttpResponse::Ok().json(format!("List of voices for user {}", user_token))
}
@@ -0,0 +1,22 @@
pub mod create_dataset;
pub mod update_dataset;
pub mod delete_dataset;
pub mod list_datasets_by_user;
pub mod create_voice;
pub mod update_voice;
pub mod delete_voice;
pub mod list_voices_by_user;
pub mod upload_sample;
pub mod delete_sample;
pub mod update_sample;
pub mod list_samples_by_dataset;
pub mod enqueue_tts_request;
pub mod enqueue_vc_request;
pub mod list_available_voices;
pub mod list_user_models;
pub mod list_favorite_models;
pub mod search_voices;
@@ -0,0 +1,14 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
pub async fn search_voices() -> HttpResponse {
// Implementation for searching voices with keywords
HttpResponse::Ok().json("Search results for voices")
}
@@ -0,0 +1,14 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
pub async fn update_dataset(dataset_token: web::Path<String>) -> HttpResponse {
// Implementation for updating a dataset
HttpResponse::Ok().json(format!("Dataset {} updated successfully", dataset_token))
}
@@ -0,0 +1,13 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
pub async fn update_voice(voice_token: web::Path<String>) -> HttpResponse {
// Implementation for updating a voice
HttpResponse::Ok().json(format!("Voice {} updated successfully", voice_token))
}
@@ -0,0 +1,15 @@
use std::sync::Arc;
use actix_web::{HttpRequest, HttpResponse, web};
use actix_web::error::ResponseError;
use actix_web::http::StatusCode;
use log::{info, warn};
pub async fn upload_sample() -> HttpResponse {
// Implementation for uploading a sample
HttpResponse::Ok().json("Sample uploaded successfully")
}
@@ -120,6 +120,28 @@ use crate::http_server::endpoints::w2l::list_user_w2l_templates::list_user_w2l_t
use crate::http_server::endpoints::w2l::list_w2l_templates::list_w2l_templates_handler;
use crate::http_server::endpoints::w2l::set_w2l_template_mod_approval::set_w2l_template_mod_approval_handler;
use crate::http_server::endpoints::voice_designer::create_dataset::create_dataset;
use crate::http_server::endpoints::voice_designer::update_dataset::update_dataset;
use crate::http_server::endpoints::voice_designer::delete_dataset::delete_dataset;
use crate::http_server::endpoints::voice_designer::list_samples_by_dataset::list_samples_by_dataset;
use crate::http_server::endpoints::voice_designer::create_voice::create_voice;
use crate::http_server::endpoints::voice_designer::update_voice::update_voice;
use crate::http_server::endpoints::voice_designer::delete_voice::delete_voice;
use crate::http_server::endpoints::voice_designer::list_available_voices::list_available_voices;
use crate::http_server::endpoints::voice_designer::upload_sample::upload_sample;
use crate::http_server::endpoints::voice_designer::delete_sample::delete_sample;
// list sample by dataset
use crate::http_server::endpoints::voice_designer::enqueue_tts_request::enqueue_tts_request;
use crate::http_server::endpoints::voice_designer::enqueue_vc_request::enqueue_vc_request;
use crate::http_server::endpoints::voice_designer::list_user_models::list_user_models;
use crate::http_server::endpoints::voice_designer::list_voices_by_user::list_voices_by_user;
use crate::http_server::endpoints::voice_designer::list_favorite_models::list_favorite_models;
use crate::http_server::endpoints::voice_designer::search_voices::search_voices;
pub fn add_routes<T, B> (app: App<T>) -> App<T>
where
B: MessageBody,
@@ -1096,8 +1118,8 @@ fn add_subscription_routes<T, B> (app: App<T>) -> App<T>
)
}
// Rename to what you think makes sense
fn add_zeroshot_routes<T,B> (app:APP<T>)-> App<T>
// Rename to what you think makes
fn add_voice_designer_routes<T,B> (app:App<T>)-> App<T>
where
B: MessageBody,
T: ServiceFactory<
@@ -1108,5 +1130,37 @@ fn add_zeroshot_routes<T,B> (app:APP<T>)-> App<T>
InitError = (),
>,
{
}
app.service(
web::scope("/v1/voice_designer")
.service(
web::scope("/datasets")
.route("/create", web::post().to(create_dataset))
.route("/{dataset_token}/update", web::post().to(update_dataset))
.route("/{dataset_token}/delete", web::delete().to(delete_dataset))
.route("/user/{user_token}/list", web::get().to(list_datasets_by_user))
.service(
web::scope("/voice")
.route("/create", web::post().to(create_voice))
.route("/{voice_token}/update", web::post().to(update_voice))
.route("/{voice_token}/delete", web::delete().to(delete_voice))
.route("/user/{user_token}/list", web::get().to(list_voices_by_user))
.service(
web::scope("/sample")
.route("/upload", web::post().to(upload_sample))
.route("/delete", web::delete().to(delete_sample))
.route("/data_set/{data_set_token}/list", web::get().to(list_samples_by_dataset))
)
.service(
web::scope("/inference")
.route("/enqueue_tts", web::post().to(enqueue_tts_request))
.route("/enqueue_vc", web::post().to(enqueue_vc_request))
)
.service(
web::scope("/inventory")
.route("/list", web::get().to(list_available_voices))
.route("/user_list", web::get().to(list_user_models))
.route("/favorites_list", web::get().to(list_favorite_models))
.route("/search", web::get().to(search_voices))
))))
}