Changing up enqueue_infer_tts_handler to allow embedding tokens.

This commit is contained in:
Michael Chung committed 2023-10-02 20:17:36 -04:00
1 parent 0b3ea3af2a
commit 40d0d0d844
3 files changed
+31 -9

No files matched your search

@@ -73,6 +73,7 @@ const MAX_TTS_LENGTH : usize = 10_000;
pub struct InferTtsRequest {
uuid_idempotency_token: String,
tts_model_token: String,
embedding_token: Option<String>, // for any voice cloning based system that uses embeddings or prompts
inference_text: String,
creator_set_visibility: Option<Visibility>,
is_storyteller_demo: Option<bool>,
@@ -23,6 +23,7 @@ pub struct EnqueueTTSRequest {
pub struct EnqueueTTSRequestSuccessResponse {
pub success: bool,
pub inference_job_token: InferenceJobToken,
pub embedding_token: str
}
#[derive(Debug)]
@@ -61,20 +62,40 @@ impl std::fmt::Display for EnqueueTTSRequestError {
}
}
// TODO Delete later.
// Not gonna go this route, going to leverage enqueue_infer_tts_handler.rs instead.
pub async fn enqueue_tts_request(http_request: HttpRequest,
request: web::Json<EnqueueTTSRequest>,
server_state: web::Data<Arc<ServerState>>) -> Result<HttpResponse,EnqueueTTSRequestError>
{
// Implementation for enqueuing a TTS request
// do something with user session check if the user should even be able to access the end point
let mut mysql_connection = server_state.mysql_pool
.acquire()
.await
.map_err(|err| {
warn!("MySql pool error: {:?}", err);
EnqueueTTSRequestError::ServerError
})?;
// let mut mysql_connection = server_state.mysql_pool
// .acquire()
// .await
// .map_err(|err| {
// warn!("MySql pool error: {:?}", err);
// EnqueueTTSRequestError::ServerError
// })?;
// check for session later
// grab any data from other sources from GCB
// rate limiter
// remap the json into data for lookup in the DB and for other processes, from the request
// create the inference args here
// enqueue a zero shot tts request here...
// create the job record here! explore the table
HttpResponse::Ok().json("TTS request enqueued successfully");
}
@@ -1160,7 +1160,7 @@ fn add_voice_designer_routes<T,B> (app:App<T>)-> App<T>
)
.service(
web::scope("/inference")
.route("/enqueue_tts", web::post().to(enqueue_tts_request))
.route("/enqueue_tts", web::post().to(enqueue_infer_tts_handler))
.route("/enqueue_vc", web::post().to(enqueue_vc_request))
)
.service(