refactor Google tts to take advantage of playback thread
parent
e528fa0bd3
commit
fb6fa54fd8
|
@ -19,7 +19,6 @@
|
||||||
from gtts import gTTS
|
from gtts import gTTS
|
||||||
|
|
||||||
from mycroft.tts import TTS, TTSValidator
|
from mycroft.tts import TTS, TTSValidator
|
||||||
from mycroft.util import play_mp3
|
|
||||||
|
|
||||||
__author__ = 'jdorleans'
|
__author__ = 'jdorleans'
|
||||||
|
|
||||||
|
@ -27,12 +26,12 @@ __author__ = 'jdorleans'
|
||||||
class GoogleTTS(TTS):
|
class GoogleTTS(TTS):
|
||||||
def __init__(self, lang, voice):
|
def __init__(self, lang, voice):
|
||||||
super(GoogleTTS, self).__init__(lang, voice, GoogleTTSValidator(self))
|
super(GoogleTTS, self).__init__(lang, voice, GoogleTTSValidator(self))
|
||||||
|
self.type = 'mp3'
|
||||||
|
|
||||||
def execute(self, sentence):
|
def get_tts(self, sentence, wav_file):
|
||||||
tts = gTTS(sentence, self.lang)
|
tts = gTTS(sentence, self.lang)
|
||||||
tts.save(self.filename)
|
tts.save(wav_file)
|
||||||
p = play_mp3(self.filename)
|
return (wav_file, None) # No phonemes
|
||||||
p.communicate() # Wait for termination
|
|
||||||
|
|
||||||
|
|
||||||
class GoogleTTSValidator(TTSValidator):
|
class GoogleTTSValidator(TTSValidator):
|
||||||
|
|
Loading…
Reference in New Issue