Skip to content

Commit ae4077e

Browse files
committed
fix: config adjust
1 parent 6eb3c90 commit ae4077e

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

bridge/bridge.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def __init__(self):
2727
self.btype["chat"] = const.BAIDU
2828
if model_type in ["xunfei"]:
2929
self.btype["chat"] = const.XUNFEI
30+
if model_type in [const.QWEN]:
31+
self.btype["chat"] = const.QWEN
3032
if conf().get("use_linkai") and conf().get("linkai_api_key"):
3133
self.btype["chat"] = const.LINKAI
3234
if not conf().get("voice_to_text") or conf().get("voice_to_text") in ["openai"]:
@@ -35,8 +37,6 @@ def __init__(self):
3537
self.btype["text_to_voice"] = const.LINKAI
3638
if model_type in ["claude"]:
3739
self.btype["chat"] = const.CLAUDEAI
38-
if model_type in [const.QWEN]:
39-
self.btype["chat"] = const.QWEN
4040
self.bots = {}
4141
self.chat_bots = {}
4242

voice/ali/ali_voice.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from voice.voice import Voice
1919
from voice.ali.ali_api import AliyunTokenGenerator
2020
from voice.ali.ali_api import text_to_speech_aliyun
21+
from config import conf
2122

2223

2324
class AliVoice(Voice):
@@ -32,10 +33,11 @@ def __init__(self):
3233
config = json.load(fr)
3334
self.token = None
3435
self.token_expire_time = 0
36+
# 默认复用阿里云千问的 access_key 和 access_secret
3537
self.api_url = config.get("api_url")
36-
self.appkey = config.get("appkey")
37-
self.access_key_id = config.get("access_key_id")
38-
self.access_key_secret = config.get("access_key_secret")
38+
self.app_key = config.get("app_key")
39+
self.access_key_id = conf().get("qwen_access_key_id") or config.get("access_key_id")
40+
self.access_key_secret = conf().get("qwen_access_key_secret") or config.get("access_key_secret")
3941
except Exception as e:
4042
logger.warn("AliVoice init failed: %s, ignore " % e)
4143

@@ -51,7 +53,7 @@ def textToVoice(self, text):
5153
r'äöüÄÖÜáéíóúÁÉÍÓÚàèìòùÀÈÌÒÙâêîôûÂÊÎÔÛçÇñÑ,。!?,.]', '', text)
5254
# 提取有效的token
5355
token_id = self.get_valid_token()
54-
fileName = text_to_speech_aliyun(self.api_url, text, self.appkey, token_id)
56+
fileName = text_to_speech_aliyun(self.api_url, text, self.app_key, token_id)
5557
if fileName:
5658
logger.info("[Ali] textToVoice text={} voice file name={}".format(text, fileName))
5759
reply = Reply(ReplyType.VOICE, fileName)

voice/ali/config.json.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"api_url": "https://nls-gateway-cn-shanghai.aliyuncs.com/stream/v1/tts",
3-
"appkey": "",
3+
"app_key": "",
44
"access_key_id": "",
55
"access_key_secret": ""
66
}

0 commit comments

Comments
 (0)