From db170106111922d8d21868f95a6e7db82b3461c2 Mon Sep 17 00:00:00 2001 From: Rqirus <1078045338@qq.com> Date: Sun, 21 Jan 2024 15:57:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20armv7=E6=A0=91=E8=8E=93=E6=B4=BE32?= =?UTF-8?q?=E4=BD=8D=E7=B3=BB=E7=BB=9F=E9=80=82=E7=94=A8=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index a3747a71..a7154543 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ python-dateutil==2.7.5 watchdog==0.9.0 pytz==2018.9 fire==0.1.3 -tornado==6.3.2 +tornado==6.2 markdown==3.0.1 semver==2.8.1 websocket==0.2.1 @@ -14,9 +14,9 @@ websocket-client pypinyin jieba pvporcupine -pvrecorder +pvrecorder==1.1.1 openai apscheduler asyncio edge-tts -nest_asyncio \ No newline at end of file +nest_asyncio From bf0aa2c9dc4080cb886bd1846642f269707ef16b Mon Sep 17 00:00:00 2001 From: Rqirus <1078045338@qq.com> Date: Sun, 21 Jan 2024 15:58:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=8E=A5?= =?UTF-8?q?=E5=85=A5bing=20AI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- robot/AI.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++ static/default.yml | 28 +++++++++++++++++++++--- 2 files changed, 78 insertions(+), 3 deletions(-) diff --git a/robot/AI.py b/robot/AI.py index 0888e19e..5ea8a96b 100644 --- a/robot/AI.py +++ b/robot/AI.py @@ -114,6 +114,59 @@ def chat(self, texts, parsed): return "抱歉, 百度UNIT服务回答失败" +class BingRobot(AbstractRobot): + + SLUG = "bing" + + def __init__(self, prefix, proxy, mode): + """ + bing + """ + super(self.__class__, self).__init__() + self.prefix = prefix + self.proxy = proxy + self.mode = mode + + @classmethod + def get_config(cls): + return config.get("bing", {}) + + def chat(self, texts, parsed): + """ + + Arguments: + texts -- user input, typically speech, to be parsed by a module + """ + msg = "".join(texts) + msg = utils.stripPunctuation(msg) + try: + import asyncio, json + from EdgeGPT.EdgeGPT import Chatbot, ConversationStyle + + async def query_bing(): + # Passing cookies is "optional" + bot = await Chatbot.create(proxy=self.proxy) + m2s = { + "creative": ConversationStyle.creative, + "balanced": ConversationStyle.balanced, + "precise": ConversationStyle.precise + } + response = await bot.ask(prompt=self.prefix + "\n" + msg, + conversation_style=m2s[self.mode], + simplify_response=True) + #print(json.dumps(response, indent=2)) # Returns + return response["text"] + await bot.close() + + result = asyncio.run(query_bing()) + + logger.info("{} 回答:{}".format(self.SLUG, result)) + return result + except Exception: + logger.critical("bing robot failed to response for %r", msg, exc_info=True) + return "抱歉, bing回答失败" + + class AnyQRobot(AbstractRobot): SLUG = "anyq" diff --git a/static/default.yml b/static/default.yml index 5570858e..479fb758 100755 --- a/static/default.yml +++ b/static/default.yml @@ -23,7 +23,7 @@ server: # 可选值: # porcupine # snowboy -detector: snowboy +detector: porcupine # 灵敏度 sensitivity: 0.5 @@ -33,11 +33,13 @@ sensitivity: 0.5 porcupine: keywords: - 'porcupine' + - 'hello bing' keyword_paths: # 支持追加多个唤醒词 # 自定义唤醒词请放到 $HOME/.wukong 目录中 # - 'spiderman.ppn' - access_key: 'xxxxxxxxxxxxxxxxxxxxxxxx' + - 'hello-bing_en_raspberry-pi_v3_0_0.ppn' + access_key: '' # snowboy 离线唤醒 # 建议使用 snowboy-seasalt (https://github.com/rhasspy/snowboy-seasalt) @@ -211,7 +213,27 @@ nlu_engine: unit # openai - OpenAI ChatGPT # anyq - AnyQ # tuling - 图灵机器人 -robot: unit +robot: bing + + +# 必应 bing +bing: + prefix: " + # 角色: 语音化必应智能音箱 + ## 目标 + - 您是一个语音化智能音箱,具备配合其他模块将你输出的文字转换为语音的能力。 + ## 约束 + - 您的回复必须以口语化的形式呈现,不能包含任何链接、emoji表情、图片、网站推荐以及其他形式的书面语言。 + - 请避免涉及到代码、图片生成等专业性的工作场景内容。 + ## 技能 + - 百科问答技能: 您可以解答各种百科性的问题,进行科普教育。 + - 咨询服务技能: 您可以接受各领域的咨询,为用户提供一对一的解答服务。 + - 常见智能音箱功能: 您还能讲笑话、阅读短新闻,提供今日头条、热点等信息。 + - 闲聊: 倾听倾诉给予建议" + + proxy: "http://127.0.0.1:7890" + # creative, balanced, precise + mode: "creative" # 百度 UNIT unit: