@@ -94,7 +94,7 @@ class BaiduWenxinBot(Bot): | |||||
logger.warn("[BAIDU] Exception: {}".format(e)) | logger.warn("[BAIDU] Exception: {}".format(e)) | ||||
need_retry = False | need_retry = False | ||||
self.sessions.clear_session(session.session_id) | self.sessions.clear_session(session.session_id) | ||||
result = {"completion_tokens": 0, "content": "出错了: {}".format(e)} | |||||
result = {"total_tokens": 0, "completion_tokens": 0, "content": "出错了: {}".format(e)} | |||||
return result | return result | ||||
def get_access_token(self): | def get_access_token(self): | ||||
@@ -102,7 +102,7 @@ available_setting = { | |||||
"baidu_api_key": "", | "baidu_api_key": "", | ||||
"baidu_secret_key": "", | "baidu_secret_key": "", | ||||
# 1536普通话(支持简单的英文识别) 1737英语 1637粤语 1837四川话 1936普通话远场 | # 1536普通话(支持简单的英文识别) 1737英语 1637粤语 1837四川话 1936普通话远场 | ||||
"baidu_dev_pid": "1536", | |||||
"baidu_dev_pid": 1536, | |||||
# azure 语音api配置, 使用azure语音识别和语音合成时需要 | # azure 语音api配置, 使用azure语音识别和语音合成时需要 | ||||
"azure_voice_api_key": "", | "azure_voice_api_key": "", | ||||
"azure_voice_region": "japaneast", | "azure_voice_region": "japaneast", | ||||
@@ -62,7 +62,7 @@ class BaiduVoice(Voice): | |||||
# 识别本地文件 | # 识别本地文件 | ||||
logger.debug("[Baidu] voice file name={}".format(voice_file)) | logger.debug("[Baidu] voice file name={}".format(voice_file)) | ||||
pcm = get_pcm_from_wav(voice_file) | pcm = get_pcm_from_wav(voice_file) | ||||
res = self.client.asr(pcm, "pcm", 8000, {"dev_pid": self.dev_id}) | |||||
res = self.client.asr(pcm, "pcm", 16000, {"dev_pid": self.dev_id}) | |||||
if res["err_no"] == 0: | if res["err_no"] == 0: | ||||
logger.info("百度语音识别到了:{}".format(res["result"])) | logger.info("百度语音识别到了:{}".format(res["result"])) | ||||
text = "".join(res["result"]) | text = "".join(res["result"]) | ||||