Saboteur7 5 месяцев назад
Родитель
Сommit
1f6f9103d9
4 измененных файлов: 25 добавлений и 20 удалений
  1. +1
    -1
      README.md
  2. +22
    -17
      config.py
  3. +1
    -1
      voice/xunfei/xunfei_asr.py
  4. +1
    -1
      voice/xunfei/xunfei_tts.py

+ 1
- 1
README.md Просмотреть файл

@@ -42,7 +42,7 @@

# 🏷 更新日志

>**2024.05.14:** [1.6.5版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.6.5),新增 gpt-4o 模型支持
>**2024.06.04:** [1.6.6版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.6.6) 和 [1.6.5版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.6.5),gpt-4o模型、钉钉流式卡片、讯飞语音识别/合成

>**2024.04.26:** [1.6.0版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.6.0),新增 Kimi 接入、gpt-4-turbo版本升级、文件总结和语音识别问题修复



+ 22
- 17
config.py Просмотреть файл

@@ -4,6 +4,7 @@ import json
import logging
import os
import pickle
import copy

from common.log import logger

@@ -233,20 +234,26 @@ config = Config()


def drag_sensitive(config):
if isinstance(config, str):
conf_dict: dict = json.loads(config)
for key in conf_dict:
if "key" in key or "secret" in key:
if isinstance(key, str):
conf_dict[key] = conf_dict[key][0:3] + "*" * 5 + conf_dict[key][-3:]
return json.dumps(conf_dict, indent=4)
elif isinstance(config, dict):
for key in config:
if "key" in key or "secret" in key:
if isinstance(key, str):
config[key] = config[key][0:3] + "*" * 5 + config[key][-3:]
try:
if isinstance(config, str):
conf_dict: dict = json.loads(config)
conf_dict_copy = copy.deepcopy(conf_dict)
for key in conf_dict_copy:
if "key" in key or "secret" in key:
if isinstance(key, str):
conf_dict_copy[key] = conf_dict_copy[key][0:3] + "*" * 5 + conf_dict_copy[key][-3:]
return json.dumps(conf_dict_copy, indent=4)

elif isinstance(config, dict):
config_copy = copy.deepcopy(config)
for key in config:
if "key" in key or "secret" in key:
if isinstance(key, str):
config_copy[key] = config_copy[key][0:3] + "*" * 5 + config_copy[key][-3:]
return config_copy
except Exception as e:
logger.exception(e)
return config

return config


@@ -258,7 +265,7 @@ def load_config():
config_path = "./config-template.json"

config_str = read_file(config_path)
logger.debug("[INIT] config str: {}".format(config_str))
logger.debug("[INIT] config str: {}".format(drag_sensitive(config_str)))

# 将json字符串反序列化为dict类型
config = Config(json.loads(config_str))
@@ -283,13 +290,11 @@ def load_config():
logger.setLevel(logging.DEBUG)
logger.debug("[INIT] set log level to DEBUG")

logger.info("[INIT] load config: {}".format(config))
logger.info("[INIT] load config: {}".format(drag_sensitive(config)))

config.load_user_datas()




def get_root():
return os.path.dirname(os.path.abspath(__file__))



+ 1
- 1
voice/xunfei/xunfei_asr.py Просмотреть файл

@@ -195,7 +195,7 @@ def xunfei_asr(APPID,APISecret,APIKey,BusinessArgsASR,AudioFile):
AudioFile=AudioFile)
#wsParam是global变量,给上面on_open函数调用使用的
wsParam = wsParam1
websocket.enableTrace(True)
websocket.enableTrace(False)
wsUrl = wsParam.create_url()
ws = websocket.WebSocketApp(wsUrl, on_message=on_message, on_error=on_error, on_close=on_close)
ws.on_open = on_open


+ 1
- 1
voice/xunfei/xunfei_tts.py Просмотреть файл

@@ -129,7 +129,7 @@ def on_open(ws):
"data": wsParam.Data,
}
d = json.dumps(d)
print("------>开始发送文本数据")
# print("------>开始发送文本数据")
ws.send(d)
if os.path.exists(outfile):
os.remove(outfile)


Загрузка…
Отмена
Сохранить