refactor: args

This commit is contained in:
Dan Chen
2024-03-21 15:20:09 +08:00
parent 49659dcc13
commit 726b926d98
6 changed files with 22 additions and 13 deletions

View File

@ -9,7 +9,7 @@ import time
class TTS(Blackbox):
def __init__(self) -> None:
def __init__(self, *args, **kwargs) -> None:
config = {
'paimon': ['resources/tts/models/paimon6k.json', 'resources/tts/models/paimon6k_390k.pth', 'character_paimon', 1],
'yunfei': ['resources/tts/models/yunfeimix2.json', 'resources/tts/models/yunfeimix2_53k.pth', 'character_yunfei', 1.1],
@ -18,12 +18,14 @@ class TTS(Blackbox):
self.tts_service = TTService(*config['catmaid'])
super().__init__(config)
def processing(self, text: str) -> io.BytesIO:
def processing(self, *args, **kwargs) -> io.BytesIO:
text = args[0]
audio = self.tts_service.read(text)
return audio
def valid(self, txt: any) -> bool:
return isinstance(txt, str)
def valid(self, *args, **kwargs) -> bool:
text = args[0]
return isinstance(text, str)
async def fast_api_handler(self, request: Request) -> Response:
try: