fix: 修复表情包打字时间

This commit is contained in:
SengokuCola
2025-04-05 12:28:43 +08:00
parent 0e23cb5f59
commit bd753acd2c
3 changed files with 11 additions and 2 deletions

View File

@@ -334,16 +334,18 @@ def process_llm_response(text: str) -> List[str]:
return sentences
def calculate_typing_time(input_string: str, chinese_time: float = 0.2, english_time: float = 0.1) -> float:
def calculate_typing_time(input_string: str, chinese_time: float = 0.2, english_time: float = 0.1, is_emoji: bool = False) -> float:
"""
计算输入字符串所需的时间,中文和英文字符有不同的输入时间
input_string (str): 输入的字符串
chinese_time (float): 中文字符的输入时间默认为0.2秒
english_time (float): 英文字符的输入时间默认为0.1秒
is_emoji (bool): 是否为emoji默认为False
特殊情况:
- 如果只有一个中文字符将使用3倍的中文输入时间
- 在所有输入结束后额外加上回车时间0.3秒
- 如果is_emoji为True将使用固定1秒的输入时间
"""
# 如果输入是列表,将其连接成字符串
@@ -376,6 +378,9 @@ def calculate_typing_time(input_string: str, chinese_time: float = 0.2, english_
else: # 其他字符(如英文)
total_time += english_time
if is_emoji:
total_time = 0.7
return total_time + 0.3 # 加上回车时间