Skip to content

Commit 0937862

Browse files
committedNov 28, 2024
refactor: 移除不必要的异常处理和事件参数
1 parent cc67f8e commit 0937862

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed
 

‎nonebot_plugin_fishspeech_tts/fish_speech_api.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
from httpx import (
22
AsyncClient,
3-
ConnectError,
4-
ConnectTimeout,
53
HTTPStatusError,
64
RequestError,
7-
ReadTimeout,
85
)
96
from nonebot.log import logger
107
from pathlib import Path
@@ -96,11 +93,8 @@ async def generate_tts(self, request: ServeTTSRequest) -> bytes:
9693
)
9794
return response.content
9895
except (
99-
ReadTimeout,
100-
ConnectTimeout,
101-
ConnectError,
102-
RequestError,
10396
HTTPStatusError,
97+
RequestError,
10498
) as e:
10599
logger.error(f"获取TTS音频失败: {e}")
106100
raise HTTPException("获取TTS音频超时, 你的文本太长啦!")

‎nonebot_plugin_fishspeech_tts/matcher.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from nonebot import on_command, on_regex, get_driver
22
from nonebot.rule import to_me
3-
from nonebot.adapters import Event, Message
3+
from nonebot.adapters import Message
44
from nonebot_plugin_alconna import UniMessage, Reply, UniMsg, Text
55

66
from .fish_audio_api import FishAudioAPI
@@ -73,7 +73,7 @@ async def tts_handle(message: UniMsg):
7373

7474

7575
@speaker_list.handle()
76-
async def speaker_list_handle(event: Event):
76+
async def speaker_list_handle():
7777
try:
7878
fish_audio_api = FishAudioAPI()
7979
fish_speech_api = FishSpeechAPI()
@@ -88,7 +88,7 @@ async def speaker_list_handle(event: Event):
8888

8989

9090
@balance.handle()
91-
async def balance_handle(event: Event):
91+
async def balance_handle():
9292
try:
9393
fish_audio_api = FishAudioAPI()
9494
if is_online:

0 commit comments

Comments
 (0)
Failed to load comments.