mirror of https://github.com/ndarilek/tts-rs.git
Compare commits
6 Commits
2667d4e943
...
bf8eb07866
Author | SHA1 | Date |
---|---|---|
Nolan Darilek | bf8eb07866 | |
Nolan Darilek | f5be2b7657 | |
Nolan Darilek | b7e7ed46dd | |
Nolan Darilek | 69eebf2ffa | |
Nolan Darilek | 6c6089daf9 | |
Alexey Stolybko | c874607afe |
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "tts"
|
||||
version = "0.25.0"
|
||||
version = "0.25.1"
|
||||
authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
|
||||
repository = "https://github.com/ndarilek/tts-rs"
|
||||
description = "High-level Text-To-Speech (TTS) interface"
|
||||
|
@ -30,7 +30,7 @@ env_logger = "0.10"
|
|||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
tolk = { version = "0.5", optional = true }
|
||||
windows = { version = "0.43", features = ["Foundation", "Foundation_Collections", "Media_Core", "Media_Playback", "Media_SpeechSynthesis", "Storage_Streams"] }
|
||||
windows = { version = "0.44", features = ["Foundation", "Foundation_Collections", "Media_Core", "Media_Playback", "Media_SpeechSynthesis", "Storage_Streams"] }
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
speech-dispatcher = { version = "0.16", default-features = false }
|
||||
|
@ -46,7 +46,7 @@ wasm-bindgen = "0.2"
|
|||
web-sys = { version = "0.3", features = ["EventTarget", "SpeechSynthesis", "SpeechSynthesisErrorCode", "SpeechSynthesisErrorEvent", "SpeechSynthesisEvent", "SpeechSynthesisUtterance", "SpeechSynthesisVoice", "Window", ] }
|
||||
|
||||
[target.'cfg(target_os="android")'.dependencies]
|
||||
jni = "0.20"
|
||||
jni = "0.21"
|
||||
ndk-context = "0.1"
|
||||
ndk-glue = "0.7"
|
||||
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
#[cfg(target_os = "macos")]
|
||||
use cocoa_foundation::base::id;
|
||||
#[cfg(target_os = "macos")]
|
||||
use cocoa_foundation::foundation::NSDefaultRunLoopMode;
|
||||
#[cfg(target_os = "macos")]
|
||||
use cocoa_foundation::foundation::NSRunLoop;
|
||||
#[cfg(target_os = "macos")]
|
||||
use objc::class;
|
||||
#[cfg(target_os = "macos")]
|
||||
use objc::{msg_send, sel, sel_impl};
|
||||
use std::{thread, time};
|
||||
|
||||
use tts::*;
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
|
@ -8,6 +17,14 @@ fn main() -> Result<(), Error> {
|
|||
let mut phrase = 1;
|
||||
loop {
|
||||
tts.speak(format!("Phrase {}", phrase), false)?;
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
let run_loop: id = unsafe { NSRunLoop::currentRunLoop() };
|
||||
unsafe {
|
||||
let date: id = msg_send![class!(NSDate), distantFuture];
|
||||
let _: () = msg_send![run_loop, runMode:NSDefaultRunLoopMode beforeDate:date];
|
||||
}
|
||||
}
|
||||
let time = time::Duration::from_secs(5);
|
||||
thread::sleep(time);
|
||||
phrase += 1;
|
||||
|
|
19
src/lib.rs
19
src/lib.rs
|
@ -95,15 +95,15 @@ impl fmt::Display for BackendId {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
match self {
|
||||
#[cfg(target_os = "android")]
|
||||
BackendId::Android(id) => writeln!(f, "{}", id),
|
||||
BackendId::Android(id) => writeln!(f, "Android({id})"),
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
BackendId::AvFoundation(id) => writeln!(f, "{}", id),
|
||||
BackendId::AvFoundation(id) => writeln!(f, "AvFoundation({id})"),
|
||||
#[cfg(target_os = "linux")]
|
||||
BackendId::SpeechDispatcher(id) => writeln!(f, "{}", id),
|
||||
BackendId::SpeechDispatcher(id) => writeln!(f, "SpeechDispatcher({id})"),
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
BackendId::Web(id) => writeln!(f, "Web({})", id),
|
||||
BackendId::Web(id) => writeln!(f, "Web({id})"),
|
||||
#[cfg(windows)]
|
||||
BackendId::WinRt(id) => writeln!(f, "{}", id),
|
||||
BackendId::WinRt(id) => writeln!(f, "WinRT({id})"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,13 +143,13 @@ impl fmt::Display for UtteranceId {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
match self {
|
||||
#[cfg(target_os = "android")]
|
||||
UtteranceId::Android(id) => writeln!(f, "{}", id),
|
||||
UtteranceId::Android(id) => writeln!(f, "Android({id})"),
|
||||
#[cfg(target_os = "linux")]
|
||||
UtteranceId::SpeechDispatcher(id) => writeln!(f, "{}", id),
|
||||
UtteranceId::SpeechDispatcher(id) => writeln!(f, "SpeechDispatcher({id})"),
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
UtteranceId::Web(id) => writeln!(f, "Web({})", id),
|
||||
#[cfg(windows)]
|
||||
UtteranceId::WinRt(id) => writeln!(f, "{}", id),
|
||||
UtteranceId::WinRt(id) => writeln!(f, "WinRt({id})"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ pub struct Features {
|
|||
|
||||
impl fmt::Display for Features {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
writeln!(f, "{:#?}", self)
|
||||
writeln!(f, "{self:#?}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,6 +317,7 @@ impl Tts {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::should_implement_trait)]
|
||||
pub fn default() -> Result<Tts, Error> {
|
||||
#[cfg(target_os = "linux")]
|
||||
let tts = Tts::new(Backends::SpeechDispatcher);
|
||||
|
|
Loading…
Reference in New Issue