fix: raise ValueErrors rather than return

This commit is contained in:
Callum Leslie committed 2022-07-12 16:46:22 +01:00
1 parent 1d3410646d
commit 3068cead0c
2 files changed
+7 -5

No files matched your search

+5 -3
View File
@@ -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):
+2 -2
View File
@@ -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.")