pub struct SpeechBuilder { /* private fields */ }Expand description
Helper type that can construct a Speech from a sequence of rendering instructions.
It’s important to understand that the instructions do not override the configuration of the
synthesizer, but adjust them instead. For example, if you call set_volume(80) on the
synthesizer, and your speech starts with the instruction start_volume(50), the volume at that
point will be set to 40 (i.e. 50% of 80%).
NOTE: Although any complex speech is encoded as XML, the builder performs no validation. This is because SAPI itself is very lax when processing speech. For example, SAPI will be perfectly happy to render the following XML:
<emph><volume level="50">Hello</emph>world</volume>Implementations§
Source§impl SpeechBuilder
impl SpeechBuilder
Sourcepub fn start_emphasis(&mut self) -> &mut Self
pub fn start_emphasis(&mut self) -> &mut Self
Emphasizes all subsequent speech until the corresponding
end_emphasis call.
Sourcepub fn start_pitch<P: Into<Pitch>>(&mut self, pitch: P) -> &mut Self
pub fn start_pitch<P: Into<Pitch>>(&mut self, pitch: P) -> &mut Self
Changes the pitch of all subsequent speech until the corresponding
end_pitch call.
Sourcepub fn start_rate<R: Into<Rate>>(&mut self, rate: R) -> &mut Self
pub fn start_rate<R: Into<Rate>>(&mut self, rate: R) -> &mut Self
Changes the rate of all subsequent speech until the corresponding
end_rate call.
Sourcepub fn start_voice(&mut self, voice: &Voice) -> &mut Self
pub fn start_voice(&mut self, voice: &Voice) -> &mut Self
Switches to the specified voice until the corresponding
end_voice call.
Sourcepub fn select_and_start_voice(
&mut self,
required: Option<VoiceSelector>,
optional: Option<VoiceSelector>,
) -> &mut Self
pub fn select_and_start_voice( &mut self, required: Option<VoiceSelector>, optional: Option<VoiceSelector>, ) -> &mut Self
Switches to a voice that matches the specified criteria until the corresponding
end_voice call. For the explanation of required and
optional criteria, see installed_voices.
Sourcepub fn start_volume<V: Into<Volume>>(&mut self, volume: V) -> &mut Self
pub fn start_volume<V: Into<Volume>>(&mut self, volume: V) -> &mut Self
Changes the volume of all subsequent speech until the corresponding
end_rate call.
Sourcepub fn say_as<S: AsRef<str>>(&mut self, text: S, ctx: SayAs<'_>) -> &mut Self
pub fn say_as<S: AsRef<str>>(&mut self, text: S, ctx: SayAs<'_>) -> &mut Self
Appends text to pronounce, along witha hint on how to pronounce it.
Sourcepub fn pronounce<S: AsRef<str>>(&mut self, pronunciation: S) -> &mut Self
pub fn pronounce<S: AsRef<str>>(&mut self, pronunciation: S) -> &mut Self
Appends a specific pronunciation to render. The pronunciation specification depends on the language of the current voice. For example, “m ah dh ax r” in American English is pronounced as “mother”.
Sourcepub fn silence(&mut self, duration: Duration) -> &mut Self
pub fn silence(&mut self, duration: Duration) -> &mut Self
Appends a silence with a specified duration. Does not support sub-millisecond precision.
Sourcepub fn end_emphasis(&mut self) -> &mut Self
pub fn end_emphasis(&mut self) -> &mut Self
Ends the effect of the corresponding start_emphasis call.
Sourcepub fn end_pitch(&mut self) -> &mut Self
pub fn end_pitch(&mut self) -> &mut Self
Ends the effect of the corresponding start_pitch call.
Sourcepub fn end_rate(&mut self) -> &mut Self
pub fn end_rate(&mut self) -> &mut Self
Ends the effect of the corresponding start_rate call.
Sourcepub fn end_voice(&mut self) -> &mut Self
pub fn end_voice(&mut self) -> &mut Self
Ends the effect of the corresponding start_voice or
select_and_start_voice call.
Sourcepub fn end_volume(&mut self) -> &mut Self
pub fn end_volume(&mut self) -> &mut Self
Ends the effect of the corresponding start_volume call.