Compare commits

...

6 Commits

Author SHA1 Message Date
Nolan Darilek bf8eb07866 Bump version. 2023-03-06 14:36:48 -06:00
Nolan Darilek f5be2b7657 Bump jni dependency. 2023-03-06 14:34:49 -06:00
Nolan Darilek b7e7ed46dd Appease Clippy. 2023-03-06 14:34:49 -06:00
Nolan Darilek 69eebf2ffa Bump windows dependency. 2023-03-06 14:34:49 -06:00
Nolan Darilek 6c6089daf9
Merge pull request #41 from ninjaboy:fix-macos-inline-play-example
Add support for inline pronounciation
2023-03-06 14:34:30 -06:00
Alexey Stolybko c874607afe Add support for inline pronounciation 2022-12-26 20:07:58 +00:00
3 changed files with 31 additions and 13 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tts" name = "tts"
version = "0.25.0" version = "0.25.1"
authors = ["Nolan Darilek <nolan@thewordnerd.info>"] authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
repository = "https://github.com/ndarilek/tts-rs" repository = "https://github.com/ndarilek/tts-rs"
description = "High-level Text-To-Speech (TTS) interface" description = "High-level Text-To-Speech (TTS) interface"
@ -30,7 +30,7 @@ env_logger = "0.10"
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]
tolk = { version = "0.5", optional = true } 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] [target.'cfg(target_os = "linux")'.dependencies]
speech-dispatcher = { version = "0.16", default-features = false } 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", ] } web-sys = { version = "0.3", features = ["EventTarget", "SpeechSynthesis", "SpeechSynthesisErrorCode", "SpeechSynthesisErrorEvent", "SpeechSynthesisEvent", "SpeechSynthesisUtterance", "SpeechSynthesisVoice", "Window", ] }
[target.'cfg(target_os="android")'.dependencies] [target.'cfg(target_os="android")'.dependencies]
jni = "0.20" jni = "0.21"
ndk-context = "0.1" ndk-context = "0.1"
ndk-glue = "0.7" ndk-glue = "0.7"

View File

@ -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 std::{thread, time};
use tts::*; use tts::*;
fn main() -> Result<(), Error> { fn main() -> Result<(), Error> {
@ -8,6 +17,14 @@ fn main() -> Result<(), Error> {
let mut phrase = 1; let mut phrase = 1;
loop { loop {
tts.speak(format!("Phrase {}", phrase), false)?; 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); let time = time::Duration::from_secs(5);
thread::sleep(time); thread::sleep(time);
phrase += 1; phrase += 1;

View File

@ -95,15 +95,15 @@ impl fmt::Display for BackendId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self { match self {
#[cfg(target_os = "android")] #[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"))] #[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")] #[cfg(target_os = "linux")]
BackendId::SpeechDispatcher(id) => writeln!(f, "{}", id), BackendId::SpeechDispatcher(id) => writeln!(f, "SpeechDispatcher({id})"),
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
BackendId::Web(id) => writeln!(f, "Web({})", id), BackendId::Web(id) => writeln!(f, "Web({id})"),
#[cfg(windows)] #[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> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self { match self {
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
UtteranceId::Android(id) => writeln!(f, "{}", id), UtteranceId::Android(id) => writeln!(f, "Android({id})"),
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
UtteranceId::SpeechDispatcher(id) => writeln!(f, "{}", id), UtteranceId::SpeechDispatcher(id) => writeln!(f, "SpeechDispatcher({id})"),
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
UtteranceId::Web(id) => writeln!(f, "Web({})", id), UtteranceId::Web(id) => writeln!(f, "Web({})", id),
#[cfg(windows)] #[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 { impl fmt::Display for Features {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { 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> { pub fn default() -> Result<Tts, Error> {
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
let tts = Tts::new(Backends::SpeechDispatcher); let tts = Tts::new(Backends::SpeechDispatcher);