From 3068cead0c0e4479b93ce3041cc698c92cba96d3 Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Tue, 12 Jul 2022 16:46:22 +0100 Subject: [PATCH] fix: raise ValueErrors rather than return --- TTS/aws_polly.py | 8 +++++--- TTS/streamlabs_polly.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/TTS/aws_polly.py b/TTS/aws_polly.py index e1d5318..efd762b 100644 --- a/TTS/aws_polly.py +++ b/TTS/aws_polly.py @@ -37,7 +37,7 @@ class AWSPolly: voice = self.randomvoice() else: if not settings.config["settings"]["tts"]["aws_polly_voice"]: - return ValueError( + raise ValueError( f"Please set the TOML variable AWS_VOICE to a valid voice. options are: {voices}" ) voice = str(settings.config["settings"]["tts"]["aws_polly_voice"]).capitalize() @@ -64,10 +64,12 @@ class AWSPolly: sys.exit(-1) except ProfileNotFound: print("You need to install the AWS CLI and configure your profile") - print(""" + print( + """ Linux: https://docs.aws.amazon.com/polly/latest/dg/setup-aws-cli.html Windows: https://docs.aws.amazon.com/polly/latest/dg/install-voice-plugin2.html - """) + """ + ) sys.exit(-1) def randomvoice(self): diff --git a/TTS/streamlabs_polly.py b/TTS/streamlabs_polly.py index bcfa175..8078af5 100644 --- a/TTS/streamlabs_polly.py +++ b/TTS/streamlabs_polly.py @@ -37,7 +37,7 @@ class StreamlabsPolly: voice = self.randomvoice() else: if not settings.config["settings"]["tts"]["streamlabs_polly_voice"]: - return ValueError( + raise ValueError( f"Please set the config variable STREAMLABS_VOICE to a valid voice. options are: {voices}" ) voice = str(settings.config["settings"]["tts"]["streamlabs_polly_voice"]).capitalize() @@ -51,7 +51,7 @@ class StreamlabsPolly: voice_data = requests.get(response.json()["speak_url"]) with open(filepath, "wb") as f: f.write(voice_data.content) - except (KeyError, JSONDecodeError) as e: + except (KeyError, JSONDecodeError): try: if response.json()["error"] == "No text specified!": raise ValueError("Please specify a text to convert to speech.")