From d483d85834db8b6bfc517bd641338b9654bcbaa0 Mon Sep 17 00:00:00 2001 From: Rodrigo <55567123+rodrigodasilv@users.noreply.github.com> Date: Tue, 5 Nov 2024 20:59:47 -0300 Subject: [PATCH] Fixed GTTS argument error 'random_voice' --- TTS/engine_wrapper.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/TTS/engine_wrapper.py b/TTS/engine_wrapper.py index 6d498d2..b3f9ac2 100644 --- a/TTS/engine_wrapper.py +++ b/TTS/engine_wrapper.py @@ -144,11 +144,18 @@ class TTSEngine: print("OSError") def call_tts(self, filename: str, text: str): - self.tts_module.run( - text, - filepath=f"{self.path}/{filename}.mp3", - random_voice=settings.config["settings"]["tts"]["random_voice"], - ) + if settings.config["settings"]["tts"]["voice_choice"] == "googletranslate": + # GTTS does not have the argument 'random_voice' + self.tts_module.run( + text, + filepath=f"{self.path}/{filename}.mp3", + ) + else: + self.tts_module.run( + text, + filepath=f"{self.path}/{filename}.mp3", + random_voice=settings.config["settings"]["tts"]["random_voice"], + ) # try: # self.length += MP3(f"{self.path}/{filename}.mp3").info.length # except (MutagenError, HeaderNotFoundError):