pub struct Audio<'s> { /* private fields */ }
Expand description
Audio
supports the insertion of recorded audio files and the insertion of other audio formats in conjunction
with synthesized speech output.
Implementations§
Source§impl<'s> Audio<'s>
impl<'s> Audio<'s>
Sourcepub fn new(src: impl Into<Cow<'s, str>>) -> Self
pub fn new(src: impl Into<Cow<'s, str>>) -> Self
Creates a new Audio
element with an audio source URI.
ssml::audio("https://example.com/Congratulations_You_Won.wav");
pub fn src(&self) -> &str
pub fn set_src(&mut self, src: impl Into<Cow<'s, str>>)
Sourcepub fn with_alternate<S: Into<Element<'s>>, I: IntoIterator<Item = S>>(
self,
elements: I,
) -> Self
pub fn with_alternate<S: Into<Element<'s>>, I: IntoIterator<Item = S>>( self, elements: I, ) -> Self
Appends alternate (fallback) elements. Alternate elements will be spoken or displayed if the audio document located at the specified URI is unavailable for whatever reason.
See also Audio::with_desc
to provide an accessible description for this audio element.
ssml::audio("cat_purr.ogg").with_alternate(["PURR (sound didn't load)"]);
Sourcepub fn with_desc(self, desc: impl Into<Cow<'s, str>>) -> Self
pub fn with_desc(self, desc: impl Into<Cow<'s, str>>) -> Self
Sets an accessible description for this audio element.
ssml::audio("cat_purr.ogg").with_desc("a purring cat");
pub fn desc(&self) -> Option<&str>
pub fn set_desc(&mut self, desc: impl Into<Cow<'s, str>>)
pub fn take_desc(&mut self) -> Option<Cow<'s, str>>
Sourcepub fn with_clip(
self,
begin: impl Into<TimeDesignation>,
end: impl Into<TimeDesignation>,
) -> Self
pub fn with_clip( self, begin: impl Into<TimeDesignation>, end: impl Into<TimeDesignation>, ) -> Self
Specify an offset from the beginning and to the end of which to clip this audio’s duration to.
// Play the sound starting from 0.25s, and stop at 0.75s, for a total duration of 0.5s.
ssml::audio("cat_purr.ogg").with_clip("0.25s", "750ms");
Sourcepub fn with_clip_begin(self, begin: impl Into<TimeDesignation>) -> Self
pub fn with_clip_begin(self, begin: impl Into<TimeDesignation>) -> Self
Specify an offset from the beginning of the audio to start playback.
// maybe skip some silence at the beginning
ssml::audio("cat_purr.ogg").with_clip_begin("0.15s");
pub fn clip_begin(&self) -> Option<&TimeDesignation>
pub fn set_clip_begin(&mut self, begin: impl Into<TimeDesignation>)
pub fn take_clip_begin(&mut self) -> Option<TimeDesignation>
Sourcepub fn with_clip_end(self, end: impl Into<TimeDesignation>) -> Self
pub fn with_clip_end(self, end: impl Into<TimeDesignation>) -> Self
Specify an offset from the beginning of the audio to end playback.
// maybe skip some silence at the end
ssml::audio("cat_purr.ogg").with_clip_begin("0.75s");
pub fn clip_end(&self) -> Option<&TimeDesignation>
pub fn set_clip_end(&mut self, end: impl Into<TimeDesignation>)
pub fn take_clip_end(&mut self) -> Option<TimeDesignation>
Sourcepub fn with_repeat(self, repeat: AudioRepeat) -> Self
pub fn with_repeat(self, repeat: AudioRepeat) -> Self
Repeat this audio source for a set amount of times, or for a set duration. See AudioRepeat
.
// Play the beep sound effect 3 times
ssml::audio("beep.ogg").with_repeat(ssml::AudioRepeat::Times(3.0));
// Happy kitty!
ssml::audio("cat_purr.ogg").with_repeat(ssml::AudioRepeat::Duration("30s".into()));
pub fn repeat(&self) -> Option<&AudioRepeat>
pub fn set_repeat(&mut self, repeat: AudioRepeat)
pub fn take_repeat(&mut self) -> Option<AudioRepeat>
Sourcepub fn with_sound_level(self, db: impl Into<Decibels>) -> Self
pub fn with_sound_level(self, db: impl Into<Decibels>) -> Self
Specify the relative volume of the referenced audio, in decibels. Setting to a large negative value like
-100dB
will effectively silence the audio clip. A value of -6.0dB
will play the audio at approximately half
the volume, and likewise +6.0dB
will play the audio at twice the volume.
ssml::audio("cat_meow.ogg").with_sound_level("+6.0dB");
pub fn sound_level(&self) -> Option<&Decibels>
pub fn set_sound_level(&mut self, db: impl Into<Decibels>)
pub fn take_sound_level(&mut self) -> Option<Decibels>
Sourcepub fn with_speed(self, speed: f32) -> Self
pub fn with_speed(self, speed: f32) -> Self
Specify the speed at which to play the audio clip (where 1.0
is normal speed).
// panic beeping at 2x speed
ssml::audio("beep.ogg").with_repeat(ssml::AudioRepeat::Times(12.0)).with_speed(2.0);
pub fn speed(&self) -> Option<f32>
pub fn set_speed(&mut self, speed: f32)
pub fn take_speed(&mut self) -> Option<f32>
Sourcepub fn alternate(&self) -> &[Element<'s>]
pub fn alternate(&self) -> &[Element<'s>]
Returns a reference to the elements contained in this audio
element’s alternate/fallback section.
Sourcepub fn alternate_mut(&mut self) -> &mut Vec<Element<'s>>
pub fn alternate_mut(&mut self) -> &mut Vec<Element<'s>>
Returns a reference to the elements contained in this audio
element’s alternate/fallback section.
pub fn to_owned(&self) -> Audio<'static>
pub fn into_owned(self) -> Audio<'static>
Trait Implementations§
Source§impl<'s> Serialize for Audio<'s>
impl<'s> Serialize for Audio<'s>
Source§fn serialize_xml<W: Write>(
&self,
writer: &mut XmlWriter<W>,
options: &SerializeOptions,
) -> Result<()>
fn serialize_xml<W: Write>( &self, writer: &mut XmlWriter<W>, options: &SerializeOptions, ) -> Result<()>
XmlWriter
.Source§fn serialize<W: Write>(
&self,
writer: &mut W,
options: &SerializeOptions,
) -> Result<()>
fn serialize<W: Write>( &self, writer: &mut W, options: &SerializeOptions, ) -> Result<()>
std
Write
r.