Add optional voices for each engine
This commit is contained in:
1 parent
7ad1492318
commit
36cb5c91a5
5 files changed
+19
-8
No files matched your search
+11
-2
@@ -66,8 +66,17 @@ OPACITY="1" #.8
|
||||
VOICE="Matthew" #en_us_002
|
||||
#EXPLANATION sets the voice the TTS uses
|
||||
|
||||
TTsChoice="polly" #polly
|
||||
#EXPLANATION the backend used for TTS, default is polly
|
||||
TTSCHOICE=""
|
||||
#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
|
||||
STORYMODE="False"
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ class TikTok: # TikTok Text-to-Speech Wrapper
|
||||
voice = (
|
||||
self.randomvoice()
|
||||
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:
|
||||
r = requests.post(
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ class AWSPolly:
|
||||
return ValueError(
|
||||
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:
|
||||
# Request speech synthesis
|
||||
response = polly.synthesize_speech(
|
||||
|
||||
@@ -39,7 +39,7 @@ class StreamlabsPolly:
|
||||
return ValueError(
|
||||
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"}
|
||||
response = requests.post(self.url, data=body)
|
||||
try:
|
||||
|
||||
@@ -29,9 +29,11 @@ def save_text_to_mp3(reddit_obj):
|
||||
Args:
|
||||
reddit_obj : The reddit object you received from the reddit API in the askreddit.py file.
|
||||
"""
|
||||
env = os.getenv("TTS_PROVIDER", "")
|
||||
if env in TTSProviders:
|
||||
text_to_mp3 = TTSEngine(env, reddit_obj)
|
||||
env = os.getenv("TTSCHOICE", "")
|
||||
if env.casefold in map(lambda _: _.casefold(), TTSProviders):
|
||||
text_to_mp3 = TTSEngine(
|
||||
get_case_insensitive_key_value(TTSProviders, env), reddit_obj
|
||||
)
|
||||
else:
|
||||
chosen = False
|
||||
choice = ""
|
||||
|
||||
Reference in new issue
Block a user