mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-22 14:48:41 +08:00
Merge branch 'zhayujie:master' into master
This commit is contained in:
@@ -44,6 +44,7 @@ class GoogleGeminiBot(Bot):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("[Gemini] fetch reply error, may contain unsafe content")
|
logger.error("[Gemini] fetch reply error, may contain unsafe content")
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
|
return Reply(ReplyType.ERROR, "invoke [Gemini] api failed!")
|
||||||
|
|
||||||
def _convert_to_gemini_messages(self, messages: list):
|
def _convert_to_gemini_messages(self, messages: list):
|
||||||
res = []
|
res = []
|
||||||
@@ -63,6 +64,8 @@ class GoogleGeminiBot(Bot):
|
|||||||
def _filter_messages(self, messages: list):
|
def _filter_messages(self, messages: list):
|
||||||
res = []
|
res = []
|
||||||
turn = "user"
|
turn = "user"
|
||||||
|
if not messages:
|
||||||
|
return res
|
||||||
for i in range(len(messages) - 1, -1, -1):
|
for i in range(len(messages) - 1, -1, -1):
|
||||||
message = messages[i]
|
message = messages[i]
|
||||||
if message.get("role") != turn:
|
if message.get("role") != turn:
|
||||||
|
|||||||
@@ -20,5 +20,9 @@
|
|||||||
"url": "https://github.com/6vision/Apilot.git",
|
"url": "https://github.com/6vision/Apilot.git",
|
||||||
"desc": "通过api直接查询早报、热榜、快递、天气等实用信息的插件"
|
"desc": "通过api直接查询早报、热榜、快递、天气等实用信息的插件"
|
||||||
}
|
}
|
||||||
|
"pictureChange": {
|
||||||
|
"url": "https://github.com/Yanyutin753/pictureChange.git",
|
||||||
|
"desc": "利用stable-diffusion和百度Ai进行图生图或者画图的插件"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,9 @@ def any_to_wav(any_path, wav_path):
|
|||||||
if any_path.endswith(".sil") or any_path.endswith(".silk") or any_path.endswith(".slk"):
|
if any_path.endswith(".sil") or any_path.endswith(".silk") or any_path.endswith(".slk"):
|
||||||
return sil_to_wav(any_path, wav_path)
|
return sil_to_wav(any_path, wav_path)
|
||||||
audio = AudioSegment.from_file(any_path)
|
audio = AudioSegment.from_file(any_path)
|
||||||
audio.export(wav_path, format="wav")
|
audio.set_frame_rate(8000) # 百度语音转写支持8000采样率, pcm_s16le, 单通道语音识别
|
||||||
|
audio.set_channels(1)
|
||||||
|
audio.export(wav_path, format="wav", codec='pcm_s16le')
|
||||||
|
|
||||||
|
|
||||||
def any_to_sil(any_path, sil_path):
|
def any_to_sil(any_path, sil_path):
|
||||||
|
|||||||
@@ -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", 16000, {"dev_pid": self.dev_id})
|
res = self.client.asr(pcm, "pcm", 8000, {"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"])
|
||||||
|
|||||||
Reference in New Issue
Block a user