mirror of
https://github.com/mii443/rust.git
synced 2025-08-22 16:25:37 +00:00
feat: support VOICEVOX version 0.19.2
This commit is contained in:
@ -6,7 +6,7 @@ use voicevox_client::Client;
|
|||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
let client = Client::new("http://localhost:50021".to_string(), None);
|
let client = Client::new("http://localhost:50021".to_string(), None);
|
||||||
let audio_query = client.create_audio_query("こんにちは", 1, None).await?;
|
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();
|
let mut file = File::create("examples/hello.wav").unwrap();
|
||||||
file.write_all(&audio).unwrap();
|
file.write_all(&audio).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -15,10 +15,18 @@ impl AudioQuery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn synthesis(&self, speaker: i32) -> Result<Bytes> {
|
pub async fn synthesis(
|
||||||
|
&self,
|
||||||
|
speaker: i32,
|
||||||
|
enable_interrogative_upspeak: bool,
|
||||||
|
) -> Result<Bytes> {
|
||||||
let data = self
|
let data = self
|
||||||
.restapi
|
.restapi
|
||||||
.synthesis(&self.audio_query, speaker.to_string().as_str())
|
.synthesis(
|
||||||
|
&self.audio_query,
|
||||||
|
speaker.to_string().as_str(),
|
||||||
|
enable_interrogative_upspeak,
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(data)
|
Ok(data)
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,17 @@ impl RestAPI {
|
|||||||
Ok(data)
|
Ok(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn synthesis(&self, audio_query: &AudioQueryType, speaker: &str) -> Result<Bytes> {
|
pub async fn synthesis(
|
||||||
|
&self,
|
||||||
|
audio_query: &AudioQueryType,
|
||||||
|
speaker: &str,
|
||||||
|
enable_interrogative_upspeak: bool,
|
||||||
|
) -> Result<Bytes> {
|
||||||
let data = self
|
let data = self
|
||||||
.request("POST", "/synthesis")
|
.request("POST", "/synthesis")
|
||||||
.json(audio_query)
|
.json(audio_query)
|
||||||
.query(&[("speaker", speaker)])
|
.query(&[("speaker", speaker)])
|
||||||
|
.query(&[("enable_interrogative_upspeak", enable_interrogative_upspeak)])
|
||||||
.send()
|
.send()
|
||||||
.await?
|
.await?
|
||||||
.bytes()
|
.bytes()
|
||||||
|
@ -37,6 +37,10 @@ pub struct AudioQueryType {
|
|||||||
pre_phoneme_length: f32,
|
pre_phoneme_length: f32,
|
||||||
#[serde(rename = "postPhonemeLength")]
|
#[serde(rename = "postPhonemeLength")]
|
||||||
post_phoneme_length: f32,
|
post_phoneme_length: f32,
|
||||||
|
#[serde(rename = "pauseLength")]
|
||||||
|
pause_length: Option<f32>,
|
||||||
|
#[serde(rename = "pauseLengthScale")]
|
||||||
|
pause_length_scale: f32,
|
||||||
#[serde(rename = "outputSamplingRate")]
|
#[serde(rename = "outputSamplingRate")]
|
||||||
output_sampling_rate: i32,
|
output_sampling_rate: i32,
|
||||||
#[serde(rename = "outputStereo")]
|
#[serde(rename = "outputStereo")]
|
||||||
|
Reference in New Issue
Block a user