Struct ibm_watson::tts::TextToSpeech [−][src]
pub struct TextToSpeech { /* fields omitted */ }Expand description
Defines text to speech options.
Implementations
Creates a new text to speech options and sets headers based on IamAuthenticator.
Arguments
auth- a reference to IamAuthenticator to use, ideally of the same language as the query.service_url- your IBM Watson TTS endpoint.
Examples
let tts_service_url = String::from("https://my.service.url/foobar");
let auth = IamAuthenticator::new("{myapikey}");
let mut tts = TextToSpeech::new(
&auth,
tts_service_url,
);Changes the voice (from the default).
Arguments
voice- AvailableVoices
Examples
tts.set_voice(AvailableVoices::en_US_OliviaV3);Returns the String equivalent of the current AvailableVoices set on the current options.
Examples
println!("{}", tts.current_voice());pub async fn synthesise_text(
&self,
utterance: &str,
format: AudioFormats
) -> Result<Bytes, Error>
pub async fn synthesise_text(
&self,
utterance: &str,
format: AudioFormats
) -> Result<Bytes, Error>
Returns a stream of bytes containing synthesised text.
Arguments
utterance- text to synthesise.format- audio format to return.
Examples
let synth_bytes = tts.synthesise_text(
"This is just fantastic",
AudioFormats::default()
).await?;
tts.set_voice(AvailableVoices::en_US_LisaV3);
let synth_bytes = tts.synthesise_text(
"I have changed the voice",
AudioFormats::AudioWav
).await?;pub async fn pronunciation<'a>(
&self,
options: &PronunciationOptions<'a>
) -> Result<String, Error>
pub async fn pronunciation<'a>(
&self,
options: &PronunciationOptions<'a>
) -> Result<String, Error>
Gets the phonetic pronunciation for the specified word. You can request the pronunciation for a specific format. You can also request the pronunciation for a specific voice to see the default translation for the language of that voice or for a specific custom model to see the translation for that model.
Arguments
utterance- text to synthesise.format- audio format to return.
Examples
let options = PronunciationOptions::new(
PhonemeFormat::default(),
"ça va",
AvailableVoices::fr_FR_Renee,
);
let pronunciation = tts.pronunciation(&options).await?;
println!("{}", pronunciation);Trait Implementations
The base URL for your service instance.
Additional headers to use in your request.
Enable Data collection (IBM Cloud), Text to Speech service instances managed on IBM Cloud that are not part of Premium plans collect data about API requests and their results.
Disable Data collection (IBM Cloud).
Auto Trait Implementations
impl !RefUnwindSafe for TextToSpeech
impl Send for TextToSpeech
impl Sync for TextToSpeech
impl Unpin for TextToSpeech
impl !UnwindSafe for TextToSpeech
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more
