|
|
@ -1,4 +1,5 @@
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
from rich.console import Console
|
|
|
|
from rich.console import Console
|
|
|
@ -31,33 +32,23 @@ def save_text_to_mp3(reddit_obj):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
env = os.getenv("TTSCHOICE", "")
|
|
|
|
env = os.getenv("TTSCHOICE", "")
|
|
|
|
if env.casefold in map(lambda _: _.casefold(), TTSProviders):
|
|
|
|
if env.casefold in map(lambda _: _.casefold(), TTSProviders):
|
|
|
|
text_to_mp3 = TTSEngine(
|
|
|
|
text_to_mp3 = TTSEngine(get_case_insensitive_key_value(TTSProviders, env), reddit_obj)
|
|
|
|
get_case_insensitive_key_value(TTSProviders, env), reddit_obj
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
chosen = False
|
|
|
|
|
|
|
|
choice = ""
|
|
|
|
choice = ""
|
|
|
|
while not chosen:
|
|
|
|
while True:
|
|
|
|
print_step("Please choose one of the following TTS providers: ")
|
|
|
|
print_step("Please choose one of the following TTS providers: ")
|
|
|
|
print_table(TTSProviders)
|
|
|
|
print_table(TTSProviders)
|
|
|
|
choice = input("\n")
|
|
|
|
choice = input("\n")
|
|
|
|
if choice.casefold() not in map(lambda _: _.casefold(), TTSProviders):
|
|
|
|
if choice.casefold() in map(lambda _: _.casefold(), TTSProviders):
|
|
|
|
print("Unknown Choice")
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
print("Unknown Choice")
|
|
|
|
chosen = True
|
|
|
|
text_to_mp3 = TTSEngine(get_case_insensitive_key_value(TTSProviders, choice), reddit_obj)
|
|
|
|
text_to_mp3 = TTSEngine(
|
|
|
|
|
|
|
|
get_case_insensitive_key_value(TTSProviders, choice), reddit_obj
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return text_to_mp3.run()
|
|
|
|
return text_to_mp3.run()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_case_insensitive_key_value(input_dict, key):
|
|
|
|
def get_case_insensitive_key_value(input_dict, key):
|
|
|
|
return next(
|
|
|
|
return next(
|
|
|
|
(
|
|
|
|
(value for dict_key, value in input_dict.items() if dict_key.lower() == key.lower()),
|
|
|
|
value
|
|
|
|
|
|
|
|
for dict_key, value in input_dict.items()
|
|
|
|
|
|
|
|
if dict_key.lower() == key.lower()
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
)
|
|
|
|
)
|
|
|
|