Add optional voices for each engine

pull/653/head
Callum Leslie 2 years ago
parent 7ad1492318
commit 36cb5c91a5

@ -66,8 +66,17 @@ OPACITY="1" #.8
VOICE="Matthew" #en_us_002 VOICE="Matthew" #en_us_002
#EXPLANATION sets the voice the TTS uses #EXPLANATION sets the voice the TTS uses
TTsChoice="polly" #polly TTSCHOICE=""
#EXPLANATION the backend used for TTS, default is polly #EXPLANATION the backend used for TTS. Without anything specified, the user will be prompted to choose one.
STREAMLABS_VOICE="Joanna"
#EXPLANATION Sets the voice for the Streamlabs Polly TTS Engine. Check the file for more information on different voices.
AWS_VOICE="Joanna"
#EXPLANATION Sets the voice for the AWS Polly TTS Engine. Check the file for more information on different voices.
TIKTOK_VOICE="en_us_006"
#EXPLANATION Sets the voice for the TikTok TTS Engine. Check the file for more information on different voices.
#OPTIONAL #OPTIONAL
STORYMODE="False" STORYMODE="False"

@ -73,7 +73,7 @@ class TikTok: # TikTok Text-to-Speech Wrapper
voice = ( voice = (
self.randomvoice() self.randomvoice()
if random_voice if random_voice
else (os.getenv("VOICE") or random.choice(self.voices["human"])) else (os.getenv("TIKTOK_VOICE") or random.choice(self.voices["human"]))
) )
try: try:
r = requests.post( r = requests.post(

@ -39,7 +39,7 @@ class AWSPolly:
return ValueError( return ValueError(
f"Please set the environment variable VOICE to a valid voice. options are: {voices}" f"Please set the environment variable VOICE to a valid voice. options are: {voices}"
) )
voice = str(os.getenv("VOICE")).capitalize() voice = str(os.getenv("AWS_VOICE")).capitalize()
try: try:
# Request speech synthesis # Request speech synthesis
response = polly.synthesize_speech( response = polly.synthesize_speech(

@ -39,7 +39,7 @@ class StreamlabsPolly:
return ValueError( return ValueError(
f"Please set the environment variable VOICE to a valid voice. options are: {voices}" f"Please set the environment variable VOICE to a valid voice. options are: {voices}"
) )
voice = str(os.getenv("VOICE")).capitalize() voice = str(os.getenv("STREAMLABS_VOICE")).capitalize()
body = {"voice": voice, "text": text, "service": "polly"} body = {"voice": voice, "text": text, "service": "polly"}
response = requests.post(self.url, data=body) response = requests.post(self.url, data=body)
try: try:

@ -29,9 +29,11 @@ def save_text_to_mp3(reddit_obj):
Args: Args:
reddit_obj : The reddit object you received from the reddit API in the askreddit.py file. reddit_obj : The reddit object you received from the reddit API in the askreddit.py file.
""" """
env = os.getenv("TTS_PROVIDER", "") env = os.getenv("TTSCHOICE", "")
if env in TTSProviders: if env.casefold in map(lambda _: _.casefold(), TTSProviders):
text_to_mp3 = TTSEngine(env, reddit_obj) text_to_mp3 = TTSEngine(
get_case_insensitive_key_value(TTSProviders, env), reddit_obj
)
else: else:
chosen = False chosen = False
choice = "" choice = ""

Loading…
Cancel
Save