From ae4077ed6cc91612751ec4fa89dccbe667a27397 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Fri, 8 Dec 2023 14:29:14 +0800 Subject: [PATCH] fix: config adjust --- bridge/bridge.py | 4 ++-- voice/ali/ali_voice.py | 10 ++++++---- voice/ali/config.json.template | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bridge/bridge.py b/bridge/bridge.py index be951af89..2b637c340 100644 --- a/bridge/bridge.py +++ b/bridge/bridge.py @@ -27,6 +27,8 @@ def __init__(self): self.btype["chat"] = const.BAIDU if model_type in ["xunfei"]: self.btype["chat"] = const.XUNFEI + if model_type in [const.QWEN]: + self.btype["chat"] = const.QWEN if conf().get("use_linkai") and conf().get("linkai_api_key"): self.btype["chat"] = const.LINKAI if not conf().get("voice_to_text") or conf().get("voice_to_text") in ["openai"]: @@ -35,8 +37,6 @@ def __init__(self): self.btype["text_to_voice"] = const.LINKAI if model_type in ["claude"]: self.btype["chat"] = const.CLAUDEAI - if model_type in [const.QWEN]: - self.btype["chat"] = const.QWEN self.bots = {} self.chat_bots = {} diff --git a/voice/ali/ali_voice.py b/voice/ali/ali_voice.py index 3a57442f3..79a9aaa78 100644 --- a/voice/ali/ali_voice.py +++ b/voice/ali/ali_voice.py @@ -18,6 +18,7 @@ from voice.voice import Voice from voice.ali.ali_api import AliyunTokenGenerator from voice.ali.ali_api import text_to_speech_aliyun +from config import conf class AliVoice(Voice): @@ -32,10 +33,11 @@ def __init__(self): config = json.load(fr) self.token = None self.token_expire_time = 0 + # 默认复用阿里云千问的 access_key 和 access_secret self.api_url = config.get("api_url") - self.appkey = config.get("appkey") - self.access_key_id = config.get("access_key_id") - self.access_key_secret = config.get("access_key_secret") + self.app_key = config.get("app_key") + self.access_key_id = conf().get("qwen_access_key_id") or config.get("access_key_id") + self.access_key_secret = conf().get("qwen_access_key_secret") or config.get("access_key_secret") except Exception as e: logger.warn("AliVoice init failed: %s, ignore " % e) @@ -51,7 +53,7 @@ def textToVoice(self, text): r'äöüÄÖÜáéíóúÁÉÍÓÚàèìòùÀÈÌÒÙâêîôûÂÊÎÔÛçÇñÑ,。!?,.]', '', text) # 提取有效的token token_id = self.get_valid_token() - fileName = text_to_speech_aliyun(self.api_url, text, self.appkey, token_id) + fileName = text_to_speech_aliyun(self.api_url, text, self.app_key, token_id) if fileName: logger.info("[Ali] textToVoice text={} voice file name={}".format(text, fileName)) reply = Reply(ReplyType.VOICE, fileName) diff --git a/voice/ali/config.json.template b/voice/ali/config.json.template index 7f8d0e6ac..6a4aaa9a5 100644 --- a/voice/ali/config.json.template +++ b/voice/ali/config.json.template @@ -1,6 +1,6 @@ { "api_url": "https://nls-gateway-cn-shanghai.aliyuncs.com/stream/v1/tts", - "appkey": "", + "app_key": "", "access_key_id": "", "access_key_secret": "" } \ No newline at end of file