From f1e78b51e52551a79ee485c3966ee1d8949e9f0e Mon Sep 17 00:00:00 2001 From: fanpt <320622572@qq.com> Date: Thu, 25 Sep 2025 15:00:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=AB=AF=E5=8F=A3=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper.py | 4 ++-- liveMan.py | 13 ++++++++++--- main.py | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/helper.py b/helper.py index 66a4eb2..9325465 100644 --- a/helper.py +++ b/helper.py @@ -256,8 +256,8 @@ class LiveChatConfig: for order_num, group_id, _type, msg in rows: by_order.setdefault(order_num, []) by_order[order_num].append({ - "order": int(order_num), - "group": int(group_id), + "order": order_num, + "group": group_id, "type": _type, "message": msg }) diff --git a/liveMan.py b/liveMan.py index 649aebe..5fa783c 100644 --- a/liveMan.py +++ b/liveMan.py @@ -1,3 +1,4 @@ +import unicodedata import asyncio import codecs import gzip @@ -418,13 +419,19 @@ class DouyinLiveWebReply: logger.info(f'入库文案:{_type} | {message}') + def text_to_adio_cost_predict(self, text): """ - 计算文本转语音的耗时 + 计算文本转语音的耗时(去除所有标点后再计算) :param text: 文本 - :return: 耗时 单位秒 + :return: 耗时(秒) """ - return len(text)/4.6 + if not text: + return 0.0 + + # 过滤所有属于 Unicode 标点类(category 以 'P' 开头)的字符 + no_punct = ''.join(ch for ch in text if unicodedata.category(ch)[0] != 'P') + return len(no_punct) / 4.62 def __call__(self): """ diff --git a/main.py b/main.py index baeabf3..cd5ecd0 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,7 @@ logger.add("log.log", encoding="utf-8", rotation="500MB") def start_fastapi_server(shared_config): from app import app app.shared_config = shared_config - uvicorn.run(app, host="0.0.0.0", port=8000) + uvicorn.run(app, host="0.0.0.0", port=8700) def fetch_user_chat_content(ws_open_event, queue): fetcher = DouyinLiveWebFetcher(ws_open_event, queue)