[voice] using baidu service to gen reply voice

This commit is contained in:
wanggang
2023-03-08 15:22:46 +08:00
parent d7a8854fa1
commit 3db452ef71
6 changed files with 48 additions and 17 deletions

View File

@@ -9,6 +9,7 @@ import time
import speech_recognition
import pyttsx3
from common.log import logger
from common.tmp_dir import TmpDir
from voice.voice import Voice
@@ -42,7 +43,7 @@ class GoogleVoice(Voice):
return "抱歉,无法连接到 Google 语音识别服务;{0}".format(e)
def textToVoice(self, text):
textFile = self.tmpFilePath + '语音回复_' + str(int(time.time())) + '.mp3'
textFile = TmpDir().path() + '语音回复_' + str(int(time.time())) + '.mp3'
self.engine.save_to_file(text, textFile)
self.engine.runAndWait()
logger.info(