2022-12-26 20:07:58 +00:00
|
|
|
#[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};
|
2020-11-11 16:27:03 +00:00
|
|
|
use std::{thread, time};
|
|
|
|
use tts::*;
|
|
|
|
|
|
|
|
fn main() -> Result<(), Error> {
|
|
|
|
env_logger::init();
|
2021-03-31 15:40:42 +00:00
|
|
|
let mut tts = Tts::default()?;
|
2020-11-11 16:27:03 +00:00
|
|
|
let mut phrase = 1;
|
|
|
|
loop {
|
2020-11-17 22:00:02 +00:00
|
|
|
tts.speak(format!("Phrase {}", phrase), false)?;
|
2022-12-26 20:07:58 +00:00
|
|
|
#[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];
|
|
|
|
}
|
|
|
|
}
|
2020-11-11 16:27:03 +00:00
|
|
|
let time = time::Duration::from_secs(5);
|
|
|
|
thread::sleep(time);
|
|
|
|
phrase += 1;
|
|
|
|
}
|
|
|
|
}
|