diff --git a/src/backends/av_foundation.rs b/src/backends/av_foundation.rs index 6940e07..445b3c9 100644 --- a/src/backends/av_foundation.rs +++ b/src/backends/av_foundation.rs @@ -10,9 +10,10 @@ use objc::runtime::{Object, Sel}; use objc::{class, declare::ClassDecl, msg_send, sel, sel_impl}; use crate::{Backend, BackendId, Error, Features, UtteranceId, CALLBACKS}; +use crate::voices::Backend as VoiceBackend; mod voices; -use voices::AVSpeechSynthesisVoice; +use voices::*; pub(crate) struct AvFoundation { id: BackendId, @@ -100,7 +101,7 @@ impl AvFoundation { rate: 0.5, volume: 1., pitch: 1., - voice: AVSpeechSynthesisVoice::default(), + voice: AVSpeechSynthesisVoice::new(""), } }; *backend_id += 1; @@ -222,11 +223,11 @@ impl Backend for AvFoundation { } fn voice(&self) -> Result { - Ok(self.voice.identifier()) + Ok(self.voice.id()) } fn list_voices(&self) -> Vec { - AVSpeechSynthesisVoice::list().iter().map(|v| {v.identifier()}).collect() + AVSpeechSynthesisVoice::list().iter().map(|v| {v.id()}).collect() } fn set_voice(&mut self, voice: &str) -> Result<(),Error> { diff --git a/src/backends/av_foundation/voices.rs b/src/backends/av_foundation/voices.rs index b8ee960..32ae9a2 100644 --- a/src/backends/av_foundation/voices.rs +++ b/src/backends/av_foundation/voices.rs @@ -11,7 +11,7 @@ use crate::voices; use crate::voices::Gender; #[derive(Copy,Clone)] -pub struct AVSpeechSynthesisVoice(*const Object); +pub(crate) struct AVSpeechSynthesisVoice(*const Object); impl AVSpeechSynthesisVoice { pub fn new(identifier: &str) -> Self { diff --git a/src/voices.rs b/src/voices.rs new file mode 100644 index 0000000..031fcdd --- /dev/null +++ b/src/voices.rs @@ -0,0 +1,17 @@ + +pub use unic_langid::LanguageIdentifier; + +pub enum Gender { + Other, + Male, + Female, +} + +pub trait Backend: Sized { + type Backend: crate::Backend; + fn list() -> Vec; + fn name(self) -> String; + fn gender(self) -> Gender; + fn id(self) -> String; + fn language(self) -> LanguageIdentifier; +}