|
|
@@ -7,14 +7,11 @@ from gtts import gTTS
|
|
|
import pygame.mixer
|
|
|
|
|
|
import base
|
|
|
-from voice_control.conf import CLIPS_FOLDER
|
|
|
+from voice_control.conf import CLIPS_FOLDER, TTS_CACHE_FOLDER
|
|
|
|
|
|
_CLIP_DATA_CACHE = {}
|
|
|
-if not os.path.isdir('/tmp/snowboy'):
|
|
|
- os.mkdir('/tmp/snowboy')
|
|
|
-TMP_DIR = '/tmp/snowboy/tts-cache'
|
|
|
-if not os.path.isdir(TMP_DIR):
|
|
|
- os.mkdir(TMP_DIR)
|
|
|
+if not os.path.isdir(TTS_CACHE_FOLDER):
|
|
|
+ os.makedirs(TTS_CACHE_FOLDER)
|
|
|
|
|
|
class Clips(object):
|
|
|
SUCCESS = 'ding.wav'
|
|
|
@@ -47,7 +44,7 @@ def _play_clip(clip):
|
|
|
class AudioOutput(base.Base):
|
|
|
def tts(self, msg):
|
|
|
tts_hash = hashlib.md5(msg.lower()).hexdigest()
|
|
|
- cache_fname = os.path.join(TMP_DIR, tts_hash) + '.mp3'
|
|
|
+ cache_fname = os.path.join(TTS_CACHE_FOLDER, tts_hash) + '.mp3'
|
|
|
if os.path.isfile(cache_fname):
|
|
|
_play(cache_fname, True)
|
|
|
return
|