removed pyglet because playsound appears to work just fine

added documentation to several functions in tty.py
This commit is contained in:
dtookey 2020-09-20 13:51:14 -04:00
parent f02bb4d3ee
commit 0c3733e2c0
2 changed files with 17 additions and 2 deletions

View File

@ -6,4 +6,3 @@ pandas
numpy numpy
gTTS gTTS
playsound playsound
pyglet

16
tts.py
View File

@ -16,6 +16,11 @@ def tts(inputText: str, *args):
def create_speech_gtts(input_text: str): def create_speech_gtts(input_text: str):
"""
Will create a sound file for the provided text by using gTTS
:param input_text: any reasonable english text
:return: returns the path of the file for the sound
"""
path = os.path.join(get_tts_dir(), create_file_name(input_text, "mp3")) path = os.path.join(get_tts_dir(), create_file_name(input_text, "mp3"))
if not os.path.exists(path): if not os.path.exists(path):
sound_digest = gTTS(text=input_text, lang='en') sound_digest = gTTS(text=input_text, lang='en')
@ -24,6 +29,11 @@ def create_speech_gtts(input_text: str):
def create_speech_streamlabs(text: str): def create_speech_streamlabs(text: str):
"""
Will create a sound file for the provided text by querying and downloading a file from streamlabs
:param text: any reasonable english text
:return: returns the path of the file for the sound
"""
path = os.path.join(get_tts_dir(), create_file_name(text, "ogg")) path = os.path.join(get_tts_dir(), create_file_name(text, "ogg"))
if not os.path.exists(path): if not os.path.exists(path):
body = {"voice": config.streamlabsVoice.value, "text": text} body = {"voice": config.streamlabsVoice.value, "text": text}
@ -44,6 +54,12 @@ speechCreationFunctions = { # this is a mapping of the Speaker enum to function
def create_speech_file(text: str): def create_speech_file(text: str):
"""
Helper function that will create a sound file for the provided text. This will use the configuration in config.py
to use TTS engines and name the file
:param text: the text you would like to turn into a sound file
:return: returns the path of the sound file
"""
text_creation_function = speechCreationFunctions.get(config.currentSpeaker) text_creation_function = speechCreationFunctions.get(config.currentSpeaker)
output_path = text_creation_function(text) output_path = text_creation_function(text)
return output_path return output_path