From 26f01a617047ef38ac5f09a150b942e50e41e99c Mon Sep 17 00:00:00 2001 From: kurotakazuki Date: Tue, 11 Jun 2024 21:50:37 +0900 Subject: [PATCH] feat: support VOICEVOX version 0.19.2 --- examples/basic.rs | 2 +- src/audio_query.rs | 12 ++++++++++-- src/restapi.rs | 8 +++++++- src/types/audio_query.rs | 4 ++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/examples/basic.rs b/examples/basic.rs index abb3b5e..f47fe8f 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -6,7 +6,7 @@ use voicevox_client::Client; async fn main() -> Result<()> { let client = Client::new("http://localhost:50021".to_string(), None); let audio_query = client.create_audio_query("こんにちは", 1, None).await?; - let audio = audio_query.synthesis(1).await?; + let audio = audio_query.synthesis(1, true).await?; let mut file = File::create("examples/hello.wav").unwrap(); file.write_all(&audio).unwrap(); Ok(()) diff --git a/src/audio_query.rs b/src/audio_query.rs index 2cfb42b..a9781bf 100644 --- a/src/audio_query.rs +++ b/src/audio_query.rs @@ -15,10 +15,18 @@ impl AudioQuery { } } - pub async fn synthesis(&self, speaker: i32) -> Result { + pub async fn synthesis( + &self, + speaker: i32, + enable_interrogative_upspeak: bool, + ) -> Result { let data = self .restapi - .synthesis(&self.audio_query, speaker.to_string().as_str()) + .synthesis( + &self.audio_query, + speaker.to_string().as_str(), + enable_interrogative_upspeak, + ) .await?; Ok(data) } diff --git a/src/restapi.rs b/src/restapi.rs index 98a35de..68f73cf 100644 --- a/src/restapi.rs +++ b/src/restapi.rs @@ -45,11 +45,17 @@ impl RestAPI { Ok(data) } - pub async fn synthesis(&self, audio_query: &AudioQueryType, speaker: &str) -> Result { + pub async fn synthesis( + &self, + audio_query: &AudioQueryType, + speaker: &str, + enable_interrogative_upspeak: bool, + ) -> Result { let data = self .request("POST", "/synthesis") .json(audio_query) .query(&[("speaker", speaker)]) + .query(&[("enable_interrogative_upspeak", enable_interrogative_upspeak)]) .send() .await? .bytes() diff --git a/src/types/audio_query.rs b/src/types/audio_query.rs index cf3f442..04ccc8d 100644 --- a/src/types/audio_query.rs +++ b/src/types/audio_query.rs @@ -37,6 +37,10 @@ pub struct AudioQueryType { pre_phoneme_length: f32, #[serde(rename = "postPhonemeLength")] post_phoneme_length: f32, + #[serde(rename = "pauseLength")] + pause_length: Option, + #[serde(rename = "pauseLengthScale")] + pause_length_scale: f32, #[serde(rename = "outputSamplingRate")] output_sampling_rate: i32, #[serde(rename = "outputStereo")]