diff --git a/bot/baidu/baidu_wenxin.py b/bot/baidu/baidu_wenxin.py index f35e0fa..81b5748 100644 --- a/bot/baidu/baidu_wenxin.py +++ b/bot/baidu/baidu_wenxin.py @@ -94,7 +94,7 @@ class BaiduWenxinBot(Bot): logger.warn("[BAIDU] Exception: {}".format(e)) need_retry = False 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 def get_access_token(self): diff --git a/config.py b/config.py index 8dead78..5d5bc4c 100644 --- a/config.py +++ b/config.py @@ -102,7 +102,7 @@ available_setting = { "baidu_api_key": "", "baidu_secret_key": "", # 1536普通话(支持简单的英文识别) 1737英语 1637粤语 1837四川话 1936普通话远场 - "baidu_dev_pid": "1536", + "baidu_dev_pid": 1536, # azure 语音api配置, 使用azure语音识别和语音合成时需要 "azure_voice_api_key": "", "azure_voice_region": "japaneast", diff --git a/voice/baidu/baidu_voice.py b/voice/baidu/baidu_voice.py index 66ba4d8..fbf53ce 100644 --- a/voice/baidu/baidu_voice.py +++ b/voice/baidu/baidu_voice.py @@ -62,7 +62,7 @@ class BaiduVoice(Voice): # 识别本地文件 logger.debug("[Baidu] voice file name={}".format(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: logger.info("百度语音识别到了:{}".format(res["result"])) text = "".join(res["result"])