1
0
mirror of https://github.com/ndarilek/tts-rs.git synced 2024-11-17 13:09:37 +00:00

some fixes

now build on macOS
This commit is contained in:
François Caddet 2020-09-27 20:35:40 +02:00
parent e19eb56169
commit 3294a82485
3 changed files with 23 additions and 5 deletions

View File

@ -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<String,Error> {
Ok(self.voice.identifier())
Ok(self.voice.id())
}
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> {

View File

@ -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 {

17
src/voices.rs Normal file
View File

@ -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;
}