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)