From 55d4bbf783a50a1056896097652c4703d98247e6 Mon Sep 17 00:00:00 2001 From: Daiki Arai Date: Sat, 30 Dec 2023 16:21:27 +0900 Subject: [PATCH] add text URL decoding option(encoding param) --- server_fastapi.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server_fastapi.py b/server_fastapi.py index 28e9a40..6d6f1e4 100644 --- a/server_fastapi.py +++ b/server_fastapi.py @@ -146,6 +146,7 @@ if __name__ == "__main__": async def voice( request: Request, text: str = Query(..., description="セリフ"), + encoding: str = Query(None, description="'utf-8'と指定するとtextをUTF8でURLデコードする。"), model_id: int = Query(0, description="モデルID。`GET /models/info`のkeyの値を指定ください。"), speaker_name: str = Query( None, description="話者名(speaker_idより優先)。esd.listの2列目記載の文字列を指定。" @@ -165,14 +166,14 @@ if __name__ == "__main__": style_weight: float = Query(DEFAULT_STYLE_WEIGHT, description="style_textの強さ"), emotion: Optional[Union[int, str]] = Query(DEFAULT_EMOTION, description="スタイル"), emotion_weight: float = Query(DEFAULT_EMOTION_WEIGHT, description="emotionの強さ"), - reference_audio_path: Optional[str] = Query(None, description="emotionを音声ファイルで行う"), + reference_audio_path: Optional[str] = Query(None, description="emotionを音声ファイルで行う。"), ): """Infer text to speech(テキストから感情付き音声を生成する)""" logger.info( f"{request.client.host}:{request.client.port}/voice { unquote(str(request.query_params) )}" ) return await _voice( - text=text, + text=text if encoding is None else unquote(text, encoding=encoding), model_id=model_id, speaker_name=speaker_name, speaker_id=speaker_id,