parent
f4daa9d587
commit
d7b4fc92cb
Binary file not shown.
Binary file not shown.
@ -0,0 +1,11 @@
|
||||
DROP TABLE IF EXISTS `t_chat_log`;
|
||||
CREATE TABLE `t_chat_log` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`session_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户人员编号',
|
||||
`user_input` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户提出的问题',
|
||||
`model_response` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '大模型的反馈',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `idx_session_id` (`session_id`) USING BTREE,
|
||||
INDEX `idx_create_time` (`create_time`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
|
@ -1,37 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import nls
|
||||
from GetToken import *
|
||||
from TtsConfig import *
|
||||
URL = "wss://nls-gateway-cn-shanghai.aliyuncs.com/ws/v1"
|
||||
|
||||
class TTS:
|
||||
def __init__(self, _file):
|
||||
self._file = _file
|
||||
self._f = None
|
||||
|
||||
def start(self, text):
|
||||
self._text = text
|
||||
# 确保目录存在
|
||||
# os.makedirs(os.path.dirname(self._file), exist_ok=True)
|
||||
self._f = open(self._file, "wb")
|
||||
TOKEN = getToken() # 参考https://help.aliyun.com/document_detail/450255.html获取token
|
||||
# 初始化 TTS
|
||||
tts = nls.NlsSpeechSynthesizer(
|
||||
url=URL,
|
||||
token=TOKEN,
|
||||
appkey=APPKEY,
|
||||
on_data=self.on_data,
|
||||
on_close=self.on_close
|
||||
)
|
||||
|
||||
# 同步执行 TTS 生成
|
||||
tts.start(self._text, voice="xiaobei", aformat="mp3")
|
||||
|
||||
def on_close(self, *args):
|
||||
if self._f:
|
||||
self._f.close()
|
||||
print("TTS 生成完成,文件已关闭")
|
||||
|
||||
def on_data(self, data, *args):
|
||||
if self._f:
|
||||
self._f.write(data)
|
@ -1,5 +1,6 @@
|
||||
import redis
|
||||
from TtsConfig import *
|
||||
from WxMini.Milvus.Config.MulvusConfig import *
|
||||
|
||||
|
||||
# 初始化 Redis 连接池
|
||||
pool = redis.ConnectionPool(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB, password=REDIS_PASSWORD)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue