From 28f4a1be06e29bb3bbb3dbf4f9307308783450ab Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Fri, 13 Sep 2024 13:04:16 +0200 Subject: Text-to-speach API for alert sound generation --- src/graphql/types/alert.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/graphql') 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) } } -- cgit v1.2.3-18-g5258