diff options
author | Santo Cariotti <santo@dcariotti.me> | 2024-09-13 13:04:16 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2024-09-13 13:04:16 +0200 |
commit | 28f4a1be06e29bb3bbb3dbf4f9307308783450ab (patch) | |
tree | cf006f2d02e31b02e9636228475095cddfb4c470 /src/graphql | |
parent | 50f16bb68fb6b28a1049ca25bb4273847c77ea93 (diff) |
Text-to-speach API for alert sound generation
Diffstat (limited to 'src/graphql')
-rw-r--r-- | src/graphql/types/alert.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/graphql/types/alert.rs b/src/graphql/types/alert.rs index 6be723c..2ee0087 100644 --- a/src/graphql/types/alert.rs +++ b/src/graphql/types/alert.rs @@ -132,6 +132,8 @@ pub mod query { } pub mod mutations { + use crate::audio; + use super::*; /// Create a new alert @@ -330,6 +332,44 @@ pub mod mutations { .await .unwrap(); + if let Err(e) = audio::tts( + alert.text1.clone(), + format!("alert-{}-text-1.mp3", alert.id), + ) + .await + { + eprintln!( + "Error for `{}`: {}", + format!("alert-{}-text-1.mp3", alert.id), + e + ); + } + + if let Err(e) = audio::tts( + alert.text2.clone(), + format!("alert-{}-text-2.mp3", alert.id), + ) + .await + { + eprintln!( + "Error for `{}`: {}", + format!("alert-{}-text-2.mp3", alert.id), + e + ); + } + if let Err(e) = audio::tts( + alert.text3.clone(), + format!("alert-{}-text-3.mp3", alert.id), + ) + .await + { + eprintln!( + "Error for `{}`: {}", + format!("alert-{}-text-3.mp3", alert.id), + e + ); + } + Ok(alert) } } |