|
@@ -12,6 +12,9 @@ logger = logging.getLogger("jarvis")
|
|
|
|
|
|
|
|
|
|
class TTS:
|
|
class TTS:
|
|
|
|
+ TTS_CONTENT_TYPE = "audio/mpeg"
|
|
|
|
+ TTS_TIMEOUT_SEC = 30
|
|
|
|
+
|
|
def __init__(self, cache_extension=None, volume=0.8):
|
|
def __init__(self, cache_extension=None, volume=0.8):
|
|
self.cache = Cache(module_name=self.__class__.__name__, cache_extension=cache_extension)
|
|
self.cache = Cache(module_name=self.__class__.__name__, cache_extension=cache_extension)
|
|
self.audio_player = AudioPlayer(volume=volume)
|
|
self.audio_player = AudioPlayer(volume=volume)
|
|
@@ -24,7 +27,7 @@ class TTS:
|
|
def say_generic(self, cache, language, words, get_audio_specific, audio_type, audio_frequency, voice=None):
|
|
def say_generic(self, cache, language, words, get_audio_specific, audio_type, audio_frequency, voice=None):
|
|
file_path = self.cache.get_audio_file_cache_path(words, language, voice)
|
|
file_path = self.cache.get_audio_file_cache_path(words, language, voice)
|
|
|
|
|
|
- if get_audio_specific(language, words, file_path, cache):
|
|
|
|
|
|
+ if get_audio_specific(language=language, words=words, file_path=file_path, cache=cache, voice=voice):
|
|
self.play_audio(file_path, audio_type, audio_frequency, cache)
|
|
self.play_audio(file_path, audio_type, audio_frequency, cache)
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
@@ -32,7 +35,7 @@ class TTS:
|
|
return key.lower()
|
|
return key.lower()
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
- def get_audio(file_path, cache, payload, url, content_type_expected, timeout_expected=30):
|
|
|
|
|
|
+ def get_audio(file_path, cache, payload, url, content_type_expected=TTS_CONTENT_TYPE, timeout_expected=TTS_TIMEOUT_SEC):
|
|
if not cache or not os.path.exists(file_path) or FileManager.file_is_empty(file_path):
|
|
if not cache or not os.path.exists(file_path) or FileManager.file_is_empty(file_path):
|
|
|
|
|
|
r = requests.get(url, params=payload, stream=True, timeout=timeout_expected)
|
|
r = requests.get(url, params=payload, stream=True, timeout=timeout_expected)
|