Struct Speech

Source
pub struct Speech { /* private fields */ }
Expand description

Speech audio source

Implementations§

Source§

impl Speech

Source

pub fn set_text(&mut self, txt: &str) -> Result<(), SoloudError>

set speech text

Examples found in repository?
examples/speech.rs (line 9)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    let mut sl = Soloud::default()?;
5    sl.set_global_volume(4.0);
6
7    let mut speech = audio::Speech::default();
8
9    speech.set_text("Hello World")?;
10
11    sl.play(&speech);
12    while sl.active_voice_count() > 0 {
13        std::thread::sleep(std::time::Duration::from_millis(100));
14    }
15
16    speech.set_text("1 2 3")?;
17
18    sl.play(&speech);
19    while sl.active_voice_count() > 0 {
20        std::thread::sleep(std::time::Duration::from_millis(100));
21    }
22
23    speech.set_text("Can you hear me?")?;
24
25    sl.play(&speech);
26    while sl.active_voice_count() > 0 {
27        std::thread::sleep(std::time::Duration::from_millis(100));
28    }
29
30    Ok(())
31}
More examples
Hide additional examples
examples/recho.rs (line 11)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    let mut sl = Soloud::default()?;
5    sl.set_global_volume(4.0);
6    let mut speech = audio::Speech::default();
7
8    let strings: Vec<String> = std::env::args().collect();
9
10    if strings.len() < 2 {
11        speech.set_text("Please provide command line arguments!")?;
12        sl.play(&speech);
13        while sl.active_voice_count() > 0 {
14            std::thread::sleep(std::time::Duration::from_millis(100));
15        }
16    } else {
17        for i in strings.iter().skip(1) {
18            speech.set_text(i)?;
19
20            sl.play(&speech);
21            while sl.active_voice_count() > 0 {
22                std::thread::sleep(std::time::Duration::from_millis(100));
23            }
24        }
25    }
26
27    Ok(())
28}
Source

pub fn set_params(&mut self) -> Result<(), SoloudError>

Set speech params

Source

pub fn set_params_ex( &mut self, base_freq: u32, base_speed: f32, base_declination: f32, base_waveform: KlattWaveForm, ) -> Result<(), SoloudError>

Set speech params

Trait Implementations§

Source§

impl AudioExt for Speech

Source§

fn default() -> Self

Creates a default initialized object
Source§

fn set_volume(&mut self, volume: f32)

Sets the volume
Source§

fn set_looping(&mut self, flag: bool)

Set whether the audio is looping
Source§

fn set_auto_stop(&mut self, flag: bool)

Set auto stop
Source§

fn set_3d_min_max_distance(&mut self, min_distance: f32, max_distance: f32)

Set 3D min and max distances
Source§

fn set_3d_attenuation(&mut self, model: AttenuationModel, rolloff_factor: f32)

Set 3D attenuation
Source§

fn set_3d_doppler_factor(&mut self, doppler_factor: f32)

Set 3D doppler factor
Source§

fn set_3d_listener_relative(&mut self, flag: bool)

Set 3D listener relative
Source§

fn set_3d_distance_delay(&mut self, distance_delay: i32)

Set 3D distance delay
Source§

fn set_inaudible_behavior(&mut self, must_tick: bool, kill: bool)

Set inaudible behavior
Source§

fn set_loop_point(&mut self, loop_point: f64)

Set a loop point
Source§

fn loop_point(&self) -> f64

Get the loop point
Source§

fn set_filter<F: FilterExt>(&mut self, filter_id: u32, filter: Option<&F>)

Set a filter, the filter_id is assigned by the developer and becomes the id for that filter, and to cancel pass None as a filter to the already assigned id
Source§

fn stop(&mut self)

Stop
Source§

unsafe fn inner(&self) -> *mut *mut c_void

Get the inner pointer Read more
Source§

impl Debug for Speech

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Speech

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Speech

Source§

impl Sync for Speech

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.