diff --git a/crates/sbv2_core/src/tts.rs b/crates/sbv2_core/src/tts.rs index b8c3966..be7c9fd 100644 --- a/crates/sbv2_core/src/tts.rs +++ b/crates/sbv2_core/src/tts.rs @@ -41,7 +41,7 @@ pub struct TTSModelHolder { tokenizer: Tokenizer, bert: Session, models: Vec, - jtalk: jtalk::JTalk, + pub jtalk: jtalk::JTalk, max_loaded_models: Option, } diff --git a/crates/sbv2_editor/src/main.rs b/crates/sbv2_editor/src/main.rs index 3cf4859..cc4bf16 100644 --- a/crates/sbv2_editor/src/main.rs +++ b/crates/sbv2_editor/src/main.rs @@ -35,9 +35,13 @@ struct ResponseCreateAudioQuery { } async fn create_audio_query( + State(state): State, Query(request): Query, ) -> AppResult { - let (text, process) = preprocess_parse_text(&request.text, &JTalk::new()?)?; + let (text, process) = { + let mut tts_model = state.tts_model.lock().await; + preprocess_parse_text(&request.text, &tts_model.jtalk)? + }; let kana_tone_list = process.g2kana_tone()?; let audio_query = kana_tone_list .iter() diff --git a/test.py b/test.py new file mode 100644 index 0000000..371abb5 --- /dev/null +++ b/test.py @@ -0,0 +1,19 @@ +import requests + + +data = (requests.get("http://localhost:8080/audio_query", params={ + "text": "こんにちは", +})).json() +print(data) + +data = (requests.post("http://localhost:8080/synthesis", json={ + "text": "こんにちは", + "ident": "tsukuyomi", + "speaker_id": 0, + "style_id": 0, + "sdp_ratio": 0.5, + "length_scale": 0.5, + "audio_query": data["audio_query"], +})).content +with open("test.wav", "wb") as f: + f.write(data) \ No newline at end of file