mirror of https://github.com/ndarilek/tts-rs.git
parent
e19eb56169
commit
3294a82485
|
@ -10,9 +10,10 @@ use objc::runtime::{Object, Sel};
|
||||||
use objc::{class, declare::ClassDecl, msg_send, sel, sel_impl};
|
use objc::{class, declare::ClassDecl, msg_send, sel, sel_impl};
|
||||||
|
|
||||||
use crate::{Backend, BackendId, Error, Features, UtteranceId, CALLBACKS};
|
use crate::{Backend, BackendId, Error, Features, UtteranceId, CALLBACKS};
|
||||||
|
use crate::voices::Backend as VoiceBackend;
|
||||||
|
|
||||||
mod voices;
|
mod voices;
|
||||||
use voices::AVSpeechSynthesisVoice;
|
use voices::*;
|
||||||
|
|
||||||
pub(crate) struct AvFoundation {
|
pub(crate) struct AvFoundation {
|
||||||
id: BackendId,
|
id: BackendId,
|
||||||
|
@ -100,7 +101,7 @@ impl AvFoundation {
|
||||||
rate: 0.5,
|
rate: 0.5,
|
||||||
volume: 1.,
|
volume: 1.,
|
||||||
pitch: 1.,
|
pitch: 1.,
|
||||||
voice: AVSpeechSynthesisVoice::default(),
|
voice: AVSpeechSynthesisVoice::new(""),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
*backend_id += 1;
|
*backend_id += 1;
|
||||||
|
@ -222,11 +223,11 @@ impl Backend for AvFoundation {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn voice(&self) -> Result<String,Error> {
|
fn voice(&self) -> Result<String,Error> {
|
||||||
Ok(self.voice.identifier())
|
Ok(self.voice.id())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_voices(&self) -> Vec<String> {
|
fn list_voices(&self) -> Vec<String> {
|
||||||
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> {
|
fn set_voice(&mut self, voice: &str) -> Result<(),Error> {
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::voices;
|
||||||
use crate::voices::Gender;
|
use crate::voices::Gender;
|
||||||
|
|
||||||
#[derive(Copy,Clone)]
|
#[derive(Copy,Clone)]
|
||||||
pub struct AVSpeechSynthesisVoice(*const Object);
|
pub(crate) struct AVSpeechSynthesisVoice(*const Object);
|
||||||
|
|
||||||
impl AVSpeechSynthesisVoice {
|
impl AVSpeechSynthesisVoice {
|
||||||
pub fn new(identifier: &str) -> Self {
|
pub fn new(identifier: &str) -> Self {
|
||||||
|
|
|
@ -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<Self>;
|
||||||
|
fn name(self) -> String;
|
||||||
|
fn gender(self) -> Gender;
|
||||||
|
fn id(self) -> String;
|
||||||
|
fn language(self) -> LanguageIdentifier;
|
||||||
|
}
|
Loading…
Reference in New Issue