From 4e589cf53de08e3689ab5c62ca7efe90f4ac9f48 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Fri, 29 Nov 2024 15:40:55 +0100 Subject: Set audio folder --- src/audio.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/audio.rs') diff --git a/src/audio.rs b/src/audio.rs index a67f3da..961af4a 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -14,7 +14,6 @@ use std::{ pub async fn tts(text: String, filename: String) -> Result<(), String> { let url = "https://api.v7.unrealspeech.com/stream"; let api_key = format!("Bearer {}", CONFIG.unrealspeech_token); - let filepath = format!("./assets/sounds/{}", filename); // Request JSON body let body = serde_json::json!({ @@ -45,6 +44,8 @@ pub async fn tts(text: String, filename: String) -> Result<(), String> { // Check for successful response if response.status().is_success() { + let filepath = format!("{}/{}", CONFIG.audio_path, filename); + let mut file = File::create(filepath).unwrap(); let content = response.bytes().await.unwrap(); let _ = file.write_all(&content); @@ -75,7 +76,7 @@ pub async fn show_file( ); } - let file_name = format!("./assets/sounds/{}", id); + let file_name = format!("{}/{}", CONFIG.audio_path, id); let file_path = StdPath::new(&file_name); if !file_path.exists() { -- cgit v1.2.3-18-g5258