From 4d024d07a79435015bc3724656261930fc39f1d4 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Tue, 7 Nov 2023 23:29:41 -0800 Subject: [PATCH] Implement volume control --- discord-tts-bot/src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/discord-tts-bot/src/main.rs b/discord-tts-bot/src/main.rs index 141c634..5f9466d 100644 --- a/discord-tts-bot/src/main.rs +++ b/discord-tts-bot/src/main.rs @@ -14,10 +14,16 @@ pub struct Data { } lazy_static! { - static ref NARRATOR: GTTSClient = GTTSClient { - volume: 1.0, - language: Languages::English, - tld: "com", + static ref NARRATOR: GTTSClient = { + dotenv::dotenv().expect("Failed to load .env file"); + GTTSClient { + volume: std::env::var("VOLUME") + .ok() + .and_then(|str| Some(str.parse().unwrap())) + .unwrap_or(1.0), + language: Languages::English, + tld: "com", + } }; }