From 6869a949d60204a1af4427267f491cc160530bff Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:26:17 +0900 Subject: [PATCH 01/41] /audio_query: return type hint --- run.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/run.py b/run.py index eea5fad11..d81f009e5 100644 --- a/run.py +++ b/run.py @@ -222,7 +222,11 @@ def get_engine(core_version: Optional[str]) -> SynthesisEngineBase: tags=["クエリ作成"], summary="音声合成用のクエリを作成する", ) - def audio_query(text: str, speaker: int, core_version: Optional[str] = None): + def audio_query( + text: str, + speaker: int, + core_version: str | None = None, + ) -> AudioQuery: """ クエリの初期値を得ます。ここで得られたクエリはそのまま音声合成に利用できます。各値の意味は`Schemas`を参照してください。 """ From 6b8b360268282daff5d3436dd05c749b99d0e4b9 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:26:39 +0900 Subject: [PATCH 02/41] /audio_query_from_preset: return type hint --- run.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index d81f009e5..7d2ba6ed2 100644 --- a/run.py +++ b/run.py @@ -252,8 +252,10 @@ def audio_query( summary="音声合成用のクエリをプリセットを用いて作成する", ) def audio_query_from_preset( - text: str, preset_id: int, core_version: Optional[str] = None - ): + text: str, + preset_id: int, + core_version: str | None = None, + ) -> AudioQuery: """ クエリの初期値を得ます。ここで得られたクエリはそのまま音声合成に利用できます。各値の意味は`Schemas`を参照してください。 """ From 98e6b9e5ffa80da5e7e728871d3602b90f17ef1f Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:27:01 +0900 Subject: [PATCH 03/41] /accent_phrases: return type hint --- run.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run.py b/run.py index 7d2ba6ed2..ca4151a7b 100644 --- a/run.py +++ b/run.py @@ -289,7 +289,7 @@ def audio_query_from_preset( @app.post( "/accent_phrases", - response_model=List[AccentPhrase], + response_model=list[AccentPhrase], tags=["クエリ編集"], summary="テキストからアクセント句を得る", responses={ @@ -303,8 +303,8 @@ def accent_phrases( text: str, speaker: int, is_kana: bool = False, - core_version: Optional[str] = None, - ): + core_version: str | None = None, + ) -> list[AccentPhrase]: """ テキストからアクセント句を得ます。 is_kanaが`true`のとき、テキストは次のようなAquesTalkライクな記法に従う読み仮名として処理されます。デフォルトは`false`です。 From 3afbd5436e38eb52f1edde6bcd58450e4da31e0b Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:27:23 +0900 Subject: [PATCH 04/41] /mora_length: return type hint --- run.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/run.py b/run.py index ca4151a7b..134699f06 100644 --- a/run.py +++ b/run.py @@ -333,29 +333,29 @@ def accent_phrases( @app.post( "/mora_data", - response_model=List[AccentPhrase], + response_model=list[AccentPhrase], tags=["クエリ編集"], summary="アクセント句から音高・音素長を得る", ) def mora_data( - accent_phrases: List[AccentPhrase], + accent_phrases: list[AccentPhrase], speaker: int, - core_version: Optional[str] = None, - ): + core_version: str | None = None, + ) -> list[AccentPhrase]: engine = get_engine(core_version) return engine.replace_mora_data(accent_phrases, speaker_id=speaker) @app.post( "/mora_length", - response_model=List[AccentPhrase], + response_model=list[AccentPhrase], tags=["クエリ編集"], summary="アクセント句から音素長を得る", ) def mora_length( - accent_phrases: List[AccentPhrase], + accent_phrases: list[AccentPhrase], speaker: int, - core_version: Optional[str] = None, - ): + core_version: str | None = None, + ) -> list[AccentPhrase]: engine = get_engine(core_version) return engine.replace_phoneme_length( accent_phrases=accent_phrases, speaker_id=speaker From 54e0b7d051013e651fd410531fd29771e91f03a3 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:27:40 +0900 Subject: [PATCH 05/41] /mora_pitch: return type hint --- run.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/run.py b/run.py index 134699f06..2bf90598d 100644 --- a/run.py +++ b/run.py @@ -363,15 +363,15 @@ def mora_length( @app.post( "/mora_pitch", - response_model=List[AccentPhrase], + response_model=list[AccentPhrase], tags=["クエリ編集"], summary="アクセント句から音高を得る", ) def mora_pitch( - accent_phrases: List[AccentPhrase], + accent_phrases: list[AccentPhrase], speaker: int, - core_version: Optional[str] = None, - ): + core_version: str | None = None, + ) -> list[AccentPhrase]: engine = get_engine(core_version) return engine.replace_mora_pitch( accent_phrases=accent_phrases, speaker_id=speaker From b1eb5bac34541403c4e550a8633315fed0d2fcb9 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:27:58 +0900 Subject: [PATCH 06/41] /synthesis: return type hint --- run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index 2bf90598d..0affe99ab 100644 --- a/run.py +++ b/run.py @@ -397,8 +397,8 @@ def synthesis( default=True, description="疑問系のテキストが与えられたら語尾を自動調整する", ), - core_version: Optional[str] = None, - ): + core_version: str | None = None, + ) -> FileResponse: engine = get_engine(core_version) wave = engine.synthesis( query=query, From 03f0f2a207d31e450d95bd55875b342d12afd9c9 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:28:15 +0900 Subject: [PATCH 07/41] /cancellable_synthesis: return type hint --- run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index 0affe99ab..3d50b5023 100644 --- a/run.py +++ b/run.py @@ -434,8 +434,8 @@ def cancellable_synthesis( query: AudioQuery, speaker: int, request: Request, - core_version: Optional[str] = None, - ): + core_version: str | None = None, + ) -> FileResponse: if cancellable_engine is None: raise HTTPException( status_code=404, From 8ee554c31a70c7313835856a5b2b8dc3e1209b49 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:29:48 +0900 Subject: [PATCH 08/41] /multi_synthesis: return type hint --- run.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run.py b/run.py index 3d50b5023..93d4ce2a1 100644 --- a/run.py +++ b/run.py @@ -472,10 +472,10 @@ def cancellable_synthesis( summary="複数まとめて音声合成する", ) def multi_synthesis( - queries: List[AudioQuery], + queries: list[AudioQuery], speaker: int, - core_version: Optional[str] = None, - ): + core_version: str | None = None, + ) -> FileResponse: engine = get_engine(core_version) sampling_rate = queries[0].outputSamplingRate From 4a74f82aa0d8e640ef0b3d3df20c8dcb58e55e1e Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:30:05 +0900 Subject: [PATCH 09/41] /morphable_targets: return type hint --- run.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/run.py b/run.py index 93d4ce2a1..4b7c0b7a6 100644 --- a/run.py +++ b/run.py @@ -510,14 +510,14 @@ def multi_synthesis( @app.post( "/morphable_targets", - response_model=List[Dict[str, MorphableTargetInfo]], + response_model=list[dict[str, MorphableTargetInfo]], tags=["音声合成"], summary="指定した話者に対してエンジン内の話者がモーフィングが可能か判定する", ) def morphable_targets( - base_speakers: List[int], - core_version: Optional[str] = None, - ): + base_speakers: list[int], + core_version: str | None = None, + ) -> list[dict[str, MorphableTargetInfo]]: """ 指定されたベース話者に対してエンジン内の各話者がモーフィング機能を利用可能か返します。 モーフィングの許可/禁止は`/speakers`の`speaker.supported_features.synthesis_morphing`に記載されています。 From 8758967741b510cceb6d4b11ab5dda1a002026cd Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:30:18 +0900 Subject: [PATCH 10/41] /synthesis_morphing: return type hint --- run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.py b/run.py index 4b7c0b7a6..409606c61 100644 --- a/run.py +++ b/run.py @@ -560,7 +560,7 @@ def _synthesis_morphing( target_speaker: int, morph_rate: float = Query(..., ge=0.0, le=1.0), # noqa: B008 core_version: Optional[str] = None, - ): + ) -> FileResponse: """ 指定された2人の話者で音声を合成、指定した割合でモーフィングした音声を得ます。 モーフィングの割合は`morph_rate`で指定でき、0.0でベースの話者、1.0でターゲットの話者に近づきます。 From 91b823ae6ce7f0229a90b137f9aa7996e5d78412 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:30:41 +0900 Subject: [PATCH 11/41] /connect_waves: return type hint --- run.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/run.py b/run.py index 409606c61..b910db29b 100644 --- a/run.py +++ b/run.py @@ -625,7 +625,9 @@ def _synthesis_morphing( tags=["その他"], summary="base64エンコードされた複数のwavデータを一つに結合する", ) - def connect_waves(waves: List[str]): + def connect_waves( + waves: list[str], + ) -> FileResponse: """ base64エンコードされたwavデータを一纏めにし、wavファイルで返します。 """ From 9c046a9097bff2fc72bf40a03a722c2f31f1e0a6 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:31:15 +0900 Subject: [PATCH 12/41] /presets: return type hint --- run.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run.py b/run.py index b910db29b..346488391 100644 --- a/run.py +++ b/run.py @@ -650,14 +650,14 @@ def connect_waves( background=BackgroundTask(delete_file, f.name), ) - @app.get("/presets", response_model=List[Preset], tags=["その他"]) - def get_presets(): + @app.get("/presets", response_model=list[Preset], tags=["その他"]) + def get_presets() -> list[Preset]: """ エンジンが保持しているプリセットの設定を返します Returns ------- - presets: List[Preset] + presets: list[Preset] プリセットのリスト """ try: From 1725e50232ab6366d12a734ea2684b0022db59b0 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:31:30 +0900 Subject: [PATCH 13/41] /add_preset: return type hint --- run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.py b/run.py index 346488391..37b1e5496 100644 --- a/run.py +++ b/run.py @@ -667,7 +667,7 @@ def get_presets() -> list[Preset]: return presets @app.post("/add_preset", response_model=int, tags=["その他"]) - def add_preset(preset: Preset): + def add_preset(preset: Preset) -> int: """ 新しいプリセットを追加します From 3510c3eecc62c3e3c8cb905d4c80db1cd971d103 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:31:38 +0900 Subject: [PATCH 14/41] /update_preset: return type hint --- run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.py b/run.py index 37b1e5496..7541f4b4d 100644 --- a/run.py +++ b/run.py @@ -689,7 +689,7 @@ def add_preset(preset: Preset) -> int: return id @app.post("/update_preset", response_model=int, tags=["その他"]) - def update_preset(preset: Preset): + def update_preset(preset: Preset) -> int: """ 既存のプリセットを更新します From 2bdca94bcdef42f94b42ae6044f8f2f1274407e6 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:31:44 +0900 Subject: [PATCH 15/41] /delete_preset: return type hint --- run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.py b/run.py index 7541f4b4d..28dff669c 100644 --- a/run.py +++ b/run.py @@ -711,7 +711,7 @@ def update_preset(preset: Preset) -> int: return id @app.post("/delete_preset", status_code=204, tags=["その他"]) - def delete_preset(id: int): + def delete_preset(id: int) -> Response: """ 既存のプリセットを削除します From ce378c2f1072983b894aa3e656ea813f54d765b2 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:32:03 +0900 Subject: [PATCH 16/41] /core_versions: return type hint --- run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index 28dff669c..b50768f66 100644 --- a/run.py +++ b/run.py @@ -731,8 +731,8 @@ def delete_preset(id: int) -> Response: def version() -> str: return __version__ - @app.get("/core_versions", response_model=List[str], tags=["その他"]) - def core_versions() -> List[str]: + @app.get("/core_versions", response_model=list[str], tags=["その他"]) + def core_versions() -> list[str]: return Response( content=json.dumps(list(synthesis_engines.keys())), media_type="application/json", From 196e092d95d3be79c3a096bbcc7ef74421b6c5de Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:33:01 +0900 Subject: [PATCH 17/41] /speakers: return type hint --- run.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run.py b/run.py index b50768f66..b204d3319 100644 --- a/run.py +++ b/run.py @@ -738,10 +738,10 @@ def core_versions() -> list[str]: media_type="application/json", ) - @app.get("/speakers", response_model=List[Speaker], tags=["その他"]) + @app.get("/speakers", response_model=list[Speaker], tags=["その他"]) def speakers( - core_version: Optional[str] = None, - ): + core_version: str | None = None, + ) -> list[Speaker]: engine = get_engine(core_version) return metas_store.load_combined_metas(engine=engine) From c32d4e06b1de4e9276c18a190bc3b382fb43533f Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:33:44 +0900 Subject: [PATCH 18/41] /downloadable_libraries: return type hint --- run.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run.py b/run.py index b204d3319..48c6f4fa7 100644 --- a/run.py +++ b/run.py @@ -816,16 +816,16 @@ def speaker_info(speaker_uuid: str, core_version: Optional[str] = None): @app.get( "/downloadable_libraries", - response_model=List[DownloadableLibrary], + response_model=list[DownloadableLibrary], tags=["音声ライブラリ管理"], ) - def downloadable_libraries(): + def downloadable_libraries() -> list[DownloadableLibrary]: """ ダウンロード可能な音声ライブラリの情報を返します。 Returns ------- - ret_data: List[DownloadableLibrary] + ret_data: list[DownloadableLibrary] """ if not engine_manifest_data.supported_features.manage_library: raise HTTPException(status_code=404, detail="この機能は実装されていません") From 6afb461e0c6dccaa21312fa39d9156fac59f3c11 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:34:28 +0900 Subject: [PATCH 19/41] /installed_libraries: return type hint --- run.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run.py b/run.py index 48c6f4fa7..e40229d3f 100644 --- a/run.py +++ b/run.py @@ -833,16 +833,16 @@ def downloadable_libraries() -> list[DownloadableLibrary]: @app.get( "/installed_libraries", - response_model=Dict[str, InstalledLibrary], + response_model=dict[str, InstalledLibrary], tags=["音声ライブラリ管理"], ) - def installed_libraries(): + def installed_libraries() -> dict[str, InstalledLibrary]: """ インストールした音声ライブラリの情報を返します。 Returns ------- - ret_data: List[DownloadableLibrary] + ret_data: dict[str, InstalledLibrary] """ if not engine_manifest_data.supported_features.manage_library: raise HTTPException(status_code=404, detail="この機能は実装されていません") From 3d6771c2acd7a73ca4144f42e0bc67ac459e85e7 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:35:09 +0900 Subject: [PATCH 20/41] /install_library: return type hint --- run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.py b/run.py index e40229d3f..44dee4dff 100644 --- a/run.py +++ b/run.py @@ -853,7 +853,7 @@ def installed_libraries() -> dict[str, InstalledLibrary]: status_code=204, tags=["音声ライブラリ管理"], ) - async def install_library(library_uuid: str, request: Request): + async def install_library(library_uuid: str, request: Request) -> Response: """ 音声ライブラリをインストールします。 音声ライブラリのZIPファイルをリクエストボディとして送信してください。 From 68044d6e24a2f508d37346eda45ed8c912139e6d Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:35:30 +0900 Subject: [PATCH 21/41] /uninstall_library: return type hint --- run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.py b/run.py index 44dee4dff..fb0ca011f 100644 --- a/run.py +++ b/run.py @@ -877,7 +877,7 @@ async def install_library(library_uuid: str, request: Request) -> Response: status_code=204, tags=["音声ライブラリ管理"], ) - def uninstall_library(library_uuid: str): + def uninstall_library(library_uuid: str) -> Response: """ 音声ライブラリをアンインストールします。 From 386d2165bae1a23cf2aa4f1e1d836b61e8d0d253 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:35:50 +0900 Subject: [PATCH 22/41] /initialize_speaker: return type hint --- run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index fb0ca011f..e8cf9381d 100644 --- a/run.py +++ b/run.py @@ -897,8 +897,8 @@ def initialize_speaker( skip_reinit: bool = Query( # noqa: B008 False, description="既に初期化済みの話者の再初期化をスキップするかどうか" ), - core_version: Optional[str] = None, - ): + core_version: str | None = None, + ) -> Response: """ 指定されたspeaker_idの話者を初期化します。 実行しなくても他のAPIは使用できますが、初回実行時に時間がかかることがあります。 From 293d0225abc52ea0369ff47f7e7f7a5982c00669 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:36:59 +0900 Subject: [PATCH 23/41] /is_initialized_speaker: return type hint --- run.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/run.py b/run.py index e8cf9381d..932dee5df 100644 --- a/run.py +++ b/run.py @@ -908,7 +908,10 @@ def initialize_speaker( return Response(status_code=204) @app.get("/is_initialized_speaker", response_model=bool, tags=["その他"]) - def is_initialized_speaker(speaker: int, core_version: Optional[str] = None): + def is_initialized_speaker( + speaker: int, + core_version: str | None = None, + ) -> bool: """ 指定されたspeaker_idの話者が初期化されているかどうかを返します。 """ From 9d33e2ed06255eb6b3f8299f4159b9d4793151fb Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:37:33 +0900 Subject: [PATCH 24/41] /user_dict: return type hint --- run.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run.py b/run.py index 932dee5df..a3f89cb18 100644 --- a/run.py +++ b/run.py @@ -918,15 +918,15 @@ def is_initialized_speaker( engine = get_engine(core_version) return engine.is_initialized_speaker_synthesis(speaker) - @app.get("/user_dict", response_model=Dict[str, UserDictWord], tags=["ユーザー辞書"]) - def get_user_dict_words(): + @app.get("/user_dict", response_model=dict[str, UserDictWord], tags=["ユーザー辞書"]) + def get_user_dict_words() -> dict[str, UserDictWord]: """ ユーザー辞書に登録されている単語の一覧を返します。 単語の表層形(surface)は正規化済みの物を返します。 Returns ------- - Dict[str, UserDictWord] + dict[str, UserDictWord] 単語のUUIDとその詳細 """ try: From 2337a90232fe658be5b1f4b21126379187afae5b Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:38:30 +0900 Subject: [PATCH 25/41] /add_user_dict_word: return type hint --- run.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run.py b/run.py index a3f89cb18..f9e14118e 100644 --- a/run.py +++ b/run.py @@ -940,9 +940,9 @@ def add_user_dict_word( surface: str, pronunciation: str, accent_type: int, - word_type: Optional[WordTypes] = None, - priority: Optional[conint(ge=MIN_PRIORITY, le=MAX_PRIORITY)] = None, - ): + word_type: WordTypes | None = None, + priority: conint(ge=MIN_PRIORITY, le=MAX_PRIORITY) | None = None, + ) -> Response: """ ユーザー辞書に言葉を追加します。 From 39df7153411a43d6170282d68de238dfb870557b Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:39:08 +0900 Subject: [PATCH 26/41] rewrite_user_dict_word: return type hint --- run.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run.py b/run.py index f9e14118e..aba95d13e 100644 --- a/run.py +++ b/run.py @@ -982,9 +982,9 @@ def rewrite_user_dict_word( pronunciation: str, accent_type: int, word_uuid: str, - word_type: Optional[WordTypes] = None, - priority: Optional[conint(ge=MIN_PRIORITY, le=MAX_PRIORITY)] = None, - ): + word_type: WordTypes | None = None, + priority: conint(ge=MIN_PRIORITY, le=MAX_PRIORITY) | None = None, + ) -> Response: """ ユーザー辞書に登録されている言葉を更新します。 From 59f46bc00edad3c8170f3303a18051297514bb88 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:39:37 +0900 Subject: [PATCH 27/41] delete_user_dict_word: return type hint --- run.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/run.py b/run.py index aba95d13e..c9254edb2 100644 --- a/run.py +++ b/run.py @@ -1024,7 +1024,9 @@ def rewrite_user_dict_word( raise HTTPException(status_code=422, detail="ユーザー辞書の更新に失敗しました。") @app.delete("/user_dict_word/{word_uuid}", status_code=204, tags=["ユーザー辞書"]) - def delete_user_dict_word(word_uuid: str): + def delete_user_dict_word( + word_uuid: str, + ) -> Response: """ ユーザー辞書に登録されている言葉を削除します。 From 1eca719a7051b13d03faf9b70cfc39377899ce50 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:40:07 +0900 Subject: [PATCH 28/41] /import_user_dict: return type hint --- run.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/run.py b/run.py index c9254edb2..318dcda23 100644 --- a/run.py +++ b/run.py @@ -1046,14 +1046,15 @@ def delete_user_dict_word( @app.post("/import_user_dict", status_code=204, tags=["ユーザー辞書"]) def import_user_dict_words( - import_dict_data: Dict[str, UserDictWord], override: bool - ): + import_dict_data: dict[str, UserDictWord], + override: bool, + ) -> Response: """ 他のユーザー辞書をインポートします。 Parameters ---------- - import_dict_data: Dict[str, UserDictWord] + import_dict_data: dict[str, UserDictWord] インポートするユーザー辞書のデータ override: bool 重複したエントリがあった場合、上書きするかどうか From d3f7f9a5f0db94796f8ddc6e4de13b6580644170 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:40:38 +0900 Subject: [PATCH 29/41] /supported_devices: return type hint --- run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index 318dcda23..b2d424f1c 100644 --- a/run.py +++ b/run.py @@ -1068,8 +1068,8 @@ def import_user_dict_words( @app.get("/supported_devices", response_model=SupportedDevicesInfo, tags=["その他"]) def supported_devices( - core_version: Optional[str] = None, - ): + core_version: str | None = None, + ) -> Response: supported_devices = get_engine(core_version).supported_devices if supported_devices is None: raise HTTPException(status_code=422, detail="非対応の機能です。") From ec10dcb4127bfea41b0bf5fb296727453121da6d Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:40:53 +0900 Subject: [PATCH 30/41] /engine_manifest: return type hint --- run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.py b/run.py index b2d424f1c..826c33edf 100644 --- a/run.py +++ b/run.py @@ -1079,7 +1079,7 @@ def supported_devices( ) @app.get("/engine_manifest", response_model=EngineManifest, tags=["その他"]) - def engine_manifest(): + def engine_manifest() -> EngineManifest: return engine_manifest_data @app.post( From e330ad7e26d3883e496c9c2442a76dbd581af69c Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:42:02 +0900 Subject: [PATCH 31/41] /validate_kana: return type hint --- run.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/run.py b/run.py index 826c33edf..97cb26b8b 100644 --- a/run.py +++ b/run.py @@ -1094,7 +1094,9 @@ def engine_manifest() -> EngineManifest: } }, ) - def validate_kana(text: str): + def validate_kana( + text: str, + ) -> bool: """ テキストがAquesTalkライクな記法に従っているかどうかを判定します。 従っていない場合はエラーが返ります。 From 3e92a0e6f5400b57f6b2cace0be619358ed11cb6 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:42:36 +0900 Subject: [PATCH 32/41] setting_get: return type hint --- run.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/run.py b/run.py index 97cb26b8b..e7e36a71c 100644 --- a/run.py +++ b/run.py @@ -1116,7 +1116,9 @@ def validate_kana( ) @app.get("/setting", response_class=HTMLResponse, tags=["設定"]) - def setting_get(request: Request): + def setting_get( + request: Request, + ) -> Response: settings = setting_loader.load_setting_file() cors_policy_mode = settings.cors_policy_mode From e8009669c3e07078bff46f6285efd000283637ce Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:44:21 +0900 Subject: [PATCH 33/41] setting_get: fix invalid response class (TemplateResponse is not subclass of HTMLResponse) --- run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.py b/run.py index e7e36a71c..dbba78b1d 100644 --- a/run.py +++ b/run.py @@ -1115,7 +1115,7 @@ def validate_kana( detail=ParseKanaBadRequest(err).dict(), ) - @app.get("/setting", response_class=HTMLResponse, tags=["設定"]) + @app.get("/setting", response_class=Response, tags=["設定"]) def setting_get( request: Request, ) -> Response: From cee166e3dcecd66994b8780a1e6c57517f0b2894 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:45:29 +0900 Subject: [PATCH 34/41] setting_post: return type hint --- run.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run.py b/run.py index dbba78b1d..6beedb94b 100644 --- a/run.py +++ b/run.py @@ -1139,9 +1139,9 @@ def setting_get( @app.post("/setting", response_class=HTMLResponse, tags=["設定"]) def setting_post( request: Request, - cors_policy_mode: Optional[str] = Form(None), # noqa: B008 - allow_origin: Optional[str] = Form(None), # noqa: B008 - ): + cors_policy_mode: str | None = Form(None), # noqa: B008 + allow_origin: str | None = Form(None), # noqa: B008 + ) -> Response: settings = Setting( cors_policy_mode=cors_policy_mode, allow_origin=allow_origin, From 2fbe45be814d6092b6375194a13e1da24b9ca2ec Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:45:45 +0900 Subject: [PATCH 35/41] setting_post: fix invalid response class (TemplateResponse is not subclass of HTMLResponse) --- run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.py b/run.py index 6beedb94b..7fb1b80fd 100644 --- a/run.py +++ b/run.py @@ -1136,7 +1136,7 @@ def setting_get( }, ) - @app.post("/setting", response_class=HTMLResponse, tags=["設定"]) + @app.post("/setting", response_class=Response, tags=["設定"]) def setting_post( request: Request, cors_policy_mode: str | None = Form(None), # noqa: B008 From d6efd185bc297090cb507d69324ea4e63e76248d Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:46:45 +0900 Subject: [PATCH 36/41] remove unused import HTMLResponse --- run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.py b/run.py index 7fb1b80fd..aca245c62 100644 --- a/run.py +++ b/run.py @@ -19,7 +19,7 @@ from fastapi import FastAPI, Form, HTTPException, Query, Request, Response from fastapi.middleware.cors import CORSMiddleware from fastapi.openapi.utils import get_openapi -from fastapi.responses import HTMLResponse, JSONResponse +from fastapi.responses import JSONResponse from fastapi.templating import Jinja2Templates from pydantic import ValidationError, conint from starlette.background import BackgroundTask From ea34962d9bdecbb7984d82b426c47d70c73f91ee Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:49:13 +0900 Subject: [PATCH 37/41] /core_versions: fix invalid return type hint --- run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.py b/run.py index aca245c62..84e8085c4 100644 --- a/run.py +++ b/run.py @@ -732,7 +732,7 @@ def version() -> str: return __version__ @app.get("/core_versions", response_model=list[str], tags=["その他"]) - def core_versions() -> list[str]: + def core_versions() -> Response: return Response( content=json.dumps(list(synthesis_engines.keys())), media_type="application/json", From 5ba808c6daa3e04fcfd78b09842213bcca715afb Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 16:52:25 +0900 Subject: [PATCH 38/41] format --- run.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/run.py b/run.py index 84e8085c4..ef0ff1baf 100644 --- a/run.py +++ b/run.py @@ -853,7 +853,10 @@ def installed_libraries() -> dict[str, InstalledLibrary]: status_code=204, tags=["音声ライブラリ管理"], ) - async def install_library(library_uuid: str, request: Request) -> Response: + async def install_library( + library_uuid: str, + request: Request, + ) -> Response: """ 音声ライブラリをインストールします。 音声ライブラリのZIPファイルをリクエストボディとして送信してください。 From fc075b5621f176e2a1ebd23be836951ef2dc8827 Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 17:04:59 +0900 Subject: [PATCH 39/41] /speaker_info: return type hint --- run.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index ef0ff1baf..1b0adbd9f 100644 --- a/run.py +++ b/run.py @@ -12,7 +12,7 @@ from io import BytesIO, TextIOWrapper from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryFile -from typing import Dict, List, Optional +from typing import Any, Dict, List, Optional import soundfile import uvicorn @@ -746,7 +746,10 @@ def speakers( return metas_store.load_combined_metas(engine=engine) @app.get("/speaker_info", response_model=SpeakerInfo, tags=["その他"]) - def speaker_info(speaker_uuid: str, core_version: Optional[str] = None): + def speaker_info( + speaker_uuid: str, + core_version: str | None = None, + ) -> dict[str, Any]: """ 指定されたspeaker_uuidに関する情報をjson形式で返します。 画像や音声はbase64エンコードされたものが返されます。 From ecabb6a56b8d538512fadcff9bf0d0780489764f Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 17:10:15 +0900 Subject: [PATCH 40/41] /synthesis_morphing: remove optional --- run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.py b/run.py index 1b0adbd9f..29aa89d74 100644 --- a/run.py +++ b/run.py @@ -559,7 +559,7 @@ def _synthesis_morphing( base_speaker: int, target_speaker: int, morph_rate: float = Query(..., ge=0.0, le=1.0), # noqa: B008 - core_version: Optional[str] = None, + core_version: str | None = None, ) -> FileResponse: """ 指定された2人の話者で音声を合成、指定した割合でモーフィングした音声を得ます。 From f4593b59b60afd77b3aa33f4bef07f22b1fc274e Mon Sep 17 00:00:00 2001 From: aoirint Date: Mon, 9 Oct 2023 23:38:15 +0900 Subject: [PATCH 41/41] revert single argument function code style to previous format --- run.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/run.py b/run.py index 29aa89d74..cd397b33b 100644 --- a/run.py +++ b/run.py @@ -625,9 +625,7 @@ def _synthesis_morphing( tags=["その他"], summary="base64エンコードされた複数のwavデータを一つに結合する", ) - def connect_waves( - waves: list[str], - ) -> FileResponse: + def connect_waves(waves: list[str]) -> FileResponse: """ base64エンコードされたwavデータを一纏めにし、wavファイルで返します。 """ @@ -1030,9 +1028,7 @@ def rewrite_user_dict_word( raise HTTPException(status_code=422, detail="ユーザー辞書の更新に失敗しました。") @app.delete("/user_dict_word/{word_uuid}", status_code=204, tags=["ユーザー辞書"]) - def delete_user_dict_word( - word_uuid: str, - ) -> Response: + def delete_user_dict_word(word_uuid: str) -> Response: """ ユーザー辞書に登録されている言葉を削除します。 @@ -1100,9 +1096,7 @@ def engine_manifest() -> EngineManifest: } }, ) - def validate_kana( - text: str, - ) -> bool: + def validate_kana(text: str) -> bool: """ テキストがAquesTalkライクな記法に従っているかどうかを判定します。 従っていない場合はエラーが返ります。 @@ -1122,9 +1116,7 @@ def validate_kana( ) @app.get("/setting", response_class=Response, tags=["設定"]) - def setting_get( - request: Request, - ) -> Response: + def setting_get(request: Request) -> Response: settings = setting_loader.load_setting_file() cors_policy_mode = settings.cors_policy_mode