Use Voice directly to avoid messing with stringly-typed voice names.

This commit is contained in:
Nolan Darilek 2022-01-27 10:26:12 -06:00
parent 911e98d9ec
commit 3709573305
2 changed files with 4 additions and 5 deletions

View File

@ -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(())
}

View File

@ -44,8 +44,7 @@ pub enum VoiceType {
#[derive(Clone, Debug, Hash, PartialEq)]
pub struct Voice {
/// The name of this voice. Unique with regards to the output module it came from. Pass this to
/// [`Connection::set_synthesis_voice`] to use this voice.
/// The name of this voice. Unique with regards to the output module it came from.
pub name: String,
/// The language of this voice. Probably a BCP 47 language tag.
pub language: String,
@ -441,8 +440,8 @@ impl Connection {
})
}
pub fn set_synthesis_voice<S: Into<String>>(&self, voice_name: S) -> Result<(), Error> {
let param = CString::new(voice_name.into()).unwrap();
pub fn set_synthesis_voice(&self, voice: &Voice) -> Result<(), Error> {
let param = CString::new(voice.name.clone()).unwrap();
let v = unsafe { spd_set_synthesis_voice(self.0, param.as_ptr()) };
c_int_to_result(v)
}