events: start moving towards a more control-handle based task architecture
This commit is contained in:
+15
-2
@@ -1,6 +1,17 @@
|
||||
use std::process::Command;
|
||||
|
||||
pub async fn start_tts() -> tokio::sync::mpsc::Sender<String> {
|
||||
#[derive(Debug)]
|
||||
pub struct TtsControl {
|
||||
request_sink: tokio::sync::mpsc::Sender<String>
|
||||
}
|
||||
|
||||
impl TtsControl {
|
||||
pub async fn speak(&self, text: String) {
|
||||
self.request_sink.send(text).await.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn start_tts() -> TtsControl {
|
||||
|
||||
let (tts_request_sender, mut tts_request_receiver) = tokio::sync::mpsc::channel(3);
|
||||
|
||||
@@ -12,5 +23,7 @@ pub async fn start_tts() -> tokio::sync::mpsc::Sender<String> {
|
||||
}
|
||||
});
|
||||
|
||||
tts_request_sender
|
||||
TtsControl {
|
||||
request_sink: tts_request_sender
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user