From c874607afe5b1f66d702059caad83ee7d093762f Mon Sep 17 00:00:00 2001 From: Alexey Stolybko Date: Mon, 26 Dec 2022 20:07:58 +0000 Subject: [PATCH] Add support for inline pronounciation --- examples/ramble.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/examples/ramble.rs b/examples/ramble.rs index e327374..5242bac 100644 --- a/examples/ramble.rs +++ b/examples/ramble.rs @@ -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;