Use Voice
directly to avoid messing with stringly-typed voice names.
This commit is contained in:
parent
911e98d9ec
commit
3709573305
|
@ -24,6 +24,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Use connection.set_synthesis_voice(voice.name) to set the voice to use.
|
// Use connection.set_synthesis_voice(voice) to set the voice to use.
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,7 @@ pub enum VoiceType {
|
||||||
|
|
||||||
#[derive(Clone, Debug, Hash, PartialEq)]
|
#[derive(Clone, Debug, Hash, PartialEq)]
|
||||||
pub struct Voice {
|
pub struct Voice {
|
||||||
/// The name of this voice. Unique with regards to the output module it came from. Pass this to
|
/// The name of this voice. Unique with regards to the output module it came from.
|
||||||
/// [`Connection::set_synthesis_voice`] to use this voice.
|
|
||||||
pub name: String,
|
pub name: String,
|
||||||
/// The language of this voice. Probably a BCP 47 language tag.
|
/// The language of this voice. Probably a BCP 47 language tag.
|
||||||
pub language: String,
|
pub language: String,
|
||||||
|
@ -441,8 +440,8 @@ impl Connection {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_synthesis_voice<S: Into<String>>(&self, voice_name: S) -> Result<(), Error> {
|
pub fn set_synthesis_voice(&self, voice: &Voice) -> Result<(), Error> {
|
||||||
let param = CString::new(voice_name.into()).unwrap();
|
let param = CString::new(voice.name.clone()).unwrap();
|
||||||
let v = unsafe { spd_set_synthesis_voice(self.0, param.as_ptr()) };
|
let v = unsafe { spd_set_synthesis_voice(self.0, param.as_ptr()) };
|
||||||
c_int_to_result(v)
|
c_int_to_result(v)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user