mirror of
https://github.com/ndarilek/tts-rs.git
synced 2024-11-17 13:09:37 +00:00
the voices::Backend trait is almost stable
This commit is contained in:
parent
3294a82485
commit
d2c42d97f5
|
@ -101,7 +101,7 @@ impl AvFoundation {
|
|||
rate: 0.5,
|
||||
volume: 1.,
|
||||
pitch: 1.,
|
||||
voice: AVSpeechSynthesisVoice::new(""),
|
||||
voice: AVSpeechSynthesisVoice::new(),
|
||||
}
|
||||
};
|
||||
*backend_id += 1;
|
||||
|
@ -231,7 +231,7 @@ impl Backend for AvFoundation {
|
|||
}
|
||||
|
||||
fn set_voice(&mut self, voice: &str) -> Result<(),Error> {
|
||||
self.voice = AVSpeechSynthesisVoice::new(voice);
|
||||
self.voice = AVSpeechSynthesisVoice::new();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,11 +14,10 @@ use crate::voices::Gender;
|
|||
pub(crate) struct AVSpeechSynthesisVoice(*const Object);
|
||||
|
||||
impl AVSpeechSynthesisVoice {
|
||||
pub fn new(identifier: &str) -> Self {
|
||||
pub fn new() -> Self {
|
||||
let voice: *const Object;
|
||||
unsafe{
|
||||
let i: id = NSString::alloc(nil).init_str(identifier);
|
||||
voice = msg_send![class!(AVSpeechSynthesisVoice), voiceWithIdentifier:i];
|
||||
voice = msg_send![class!(AVSpeechSynthesisVoice), new];
|
||||
};
|
||||
AVSpeechSynthesisVoice{0:voice}
|
||||
}
|
||||
|
@ -27,6 +26,14 @@ impl AVSpeechSynthesisVoice {
|
|||
impl voices::Backend for AVSpeechSynthesisVoice {
|
||||
type Backend = AvFoundation;
|
||||
|
||||
fn from_id(id: String) -> Self {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn from_language(lang: voices::LanguageIdentifier) -> Self {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn list() -> Vec<Self> {
|
||||
let voices: CFArray = unsafe{msg_send![class!(AVSpeechSynthesisVoice), speechVoices]};
|
||||
voices.iter().map(|v| {
|
||||
|
|
|
@ -9,9 +9,13 @@ pub enum Gender {
|
|||
|
||||
pub trait Backend: Sized {
|
||||
type Backend: crate::Backend;
|
||||
fn from_id(id: String) -> Self;
|
||||
fn from_language(lang: LanguageIdentifier) -> Self;
|
||||
fn list() -> Vec<Self>;
|
||||
fn name(self) -> String;
|
||||
fn gender(self) -> Gender;
|
||||
fn id(self) -> String;
|
||||
fn language(self) -> LanguageIdentifier;
|
||||
}
|
||||
|
||||
pub struct Voice<T: Backend + Sized>(Box<T>);
|
||||
|
|
Loading…
Reference in New Issue
Block a user