Skip to content

Commit

Permalink
整理: response_model を廃止 (VOICEVOX#1225)
Browse files Browse the repository at this point in the history
refactor: `response_model` を廃止
  • Loading branch information
tarepan authored May 14, 2024
1 parent 01fcc6d commit 8398406
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 24 deletions.
2 changes: 0 additions & 2 deletions voicevox_engine/app/routers/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def generate_library_router(

@router.get(
"/downloadable_libraries",
response_model=list[DownloadableLibraryInfo],
response_description="ダウンロード可能な音声ライブラリの情報リスト",
tags=["音声ライブラリ管理"],
)
Expand All @@ -37,7 +36,6 @@ def downloadable_libraries() -> list[DownloadableLibraryInfo]:

@router.get(
"/installed_libraries",
response_model=dict[str, InstalledLibraryInfo],
response_description="インストールした音声ライブラリの情報",
tags=["音声ライブラリ管理"],
)
Expand Down
1 change: 0 additions & 1 deletion voicevox_engine/app/routers/morphing.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def generate_morphing_router(

@router.post(
"/morphable_targets",
response_model=list[dict[str, MorphableTargetInfo]],
tags=["音声合成"],
summary="指定したスタイルに対してエンジン内の話者がモーフィングが可能か判定する",
)
Expand Down
3 changes: 0 additions & 3 deletions voicevox_engine/app/routers/preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def generate_preset_router(preset_manager: PresetManager) -> APIRouter:

@router.get(
"/presets",
response_model=list[Preset],
response_description="プリセットのリスト",
tags=["その他"],
)
Expand All @@ -35,7 +34,6 @@ def get_presets() -> list[Preset]:

@router.post(
"/add_preset",
response_model=int,
response_description="追加したプリセットのプリセットID",
tags=["その他"],
dependencies=[Depends(check_disabled_mutable_api)],
Expand All @@ -61,7 +59,6 @@ def add_preset(

@router.post(
"/update_preset",
response_model=int,
response_description="更新したプリセットのプリセットID",
tags=["その他"],
dependencies=[Depends(check_disabled_mutable_api)],
Expand Down
10 changes: 5 additions & 5 deletions voicevox_engine/app/routers/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def generate_speaker_router(
"""話者情報 API Router を生成する"""
router = APIRouter()

@router.get("/speakers", response_model=list[Speaker], tags=["その他"])
@router.get("/speakers", tags=["その他"])
def speakers(
core_version: str | None = None,
) -> list[Speaker]:
speakers = metas_store.load_combined_metas(get_core(core_version))
return filter_speakers_and_styles(speakers, "speaker")

@router.get("/speaker_info", response_model=SpeakerInfo, tags=["その他"])
@router.get("/speaker_info", tags=["その他"])
def speaker_info(
speaker_uuid: str,
core_version: str | None = None,
Expand Down Expand Up @@ -143,14 +143,14 @@ def _speaker_info(
)
return ret_data

@router.get("/singers", response_model=list[Speaker], tags=["その他"])
@router.get("/singers", tags=["その他"])
def singers(
core_version: str | None = None,
) -> list[Speaker]:
singers = metas_store.load_combined_metas(get_core(core_version))
return filter_speakers_and_styles(singers, "singer")

@router.get("/singer_info", response_model=SpeakerInfo, tags=["その他"])
@router.get("/singer_info", tags=["その他"])
def singer_info(
speaker_uuid: str,
core_version: str | None = None,
Expand Down Expand Up @@ -184,7 +184,7 @@ def initialize_speaker(
core.initialize_style_id_synthesis(style_id, skip_reinit=skip_reinit)
return Response(status_code=204)

@router.get("/is_initialized_speaker", response_model=bool, tags=["その他"])
@router.get("/is_initialized_speaker", tags=["その他"])
def is_initialized_speaker(
style_id: Annotated[StyleId, Query(alias="speaker")],
core_version: str | None = None,
Expand Down
9 changes: 0 additions & 9 deletions voicevox_engine/app/routers/tts_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def generate_tts_pipeline_router(

@router.post(
"/audio_query",
response_model=AudioQuery,
tags=["クエリ作成"],
summary="音声合成用のクエリを作成する",
)
Expand Down Expand Up @@ -72,7 +71,6 @@ def audio_query(

@router.post(
"/audio_query_from_preset",
response_model=AudioQuery,
tags=["クエリ作成"],
summary="音声合成用のクエリをプリセットを用いて作成する",
)
Expand Down Expand Up @@ -117,7 +115,6 @@ def audio_query_from_preset(

@router.post(
"/accent_phrases",
response_model=list[AccentPhrase],
tags=["クエリ編集"],
summary="テキストからアクセント句を得る",
responses={
Expand Down Expand Up @@ -155,7 +152,6 @@ def accent_phrases(

@router.post(
"/mora_data",
response_model=list[AccentPhrase],
tags=["クエリ編集"],
summary="アクセント句から音高・音素長を得る",
)
Expand All @@ -169,7 +165,6 @@ def mora_data(

@router.post(
"/mora_length",
response_model=list[AccentPhrase],
tags=["クエリ編集"],
summary="アクセント句から音素長を得る",
)
Expand All @@ -183,7 +178,6 @@ def mora_length(

@router.post(
"/mora_pitch",
response_model=list[AccentPhrase],
tags=["クエリ編集"],
summary="アクセント句から音高を得る",
)
Expand Down Expand Up @@ -322,7 +316,6 @@ def multi_synthesis(

@router.post(
"/sing_frame_audio_query",
response_model=FrameAudioQuery,
tags=["クエリ作成"],
summary="歌唱音声合成用のクエリを作成する",
)
Expand Down Expand Up @@ -351,7 +344,6 @@ def sing_frame_audio_query(

@router.post(
"/sing_frame_volume",
response_model=list[float],
tags=["クエリ編集"],
summary="スコア・歌唱音声合成用のクエリからフレームごとの音量を得る",
)
Expand Down Expand Up @@ -438,7 +430,6 @@ def connect_waves(waves: list[str]) -> FileResponse:

@router.post(
"/validate_kana",
response_model=bool,
tags=["その他"],
summary="テキストがAquesTalk 風記法に従っているか判定する",
responses={
Expand Down
6 changes: 2 additions & 4 deletions voicevox_engine/app/routers/user_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def generate_user_dict_router(user_dict: UserDictionary) -> APIRouter:

@router.get(
"/user_dict",
response_model=dict[str, UserDictWord],
response_description="単語のUUIDとその詳細",
tags=["ユーザー辞書"],
)
Expand All @@ -42,7 +41,6 @@ def get_user_dict_words() -> dict[str, UserDictWord]:

@router.post(
"/user_dict_word",
response_model=str,
tags=["ユーザー辞書"],
dependencies=[Depends(check_disabled_mutable_api)],
)
Expand All @@ -66,7 +64,7 @@ def add_user_dict_word(
description="単語の優先度(0から10までの整数)。数字が大きいほど優先度が高くなる。1から9までの値を指定することを推奨",
),
] = None,
) -> Response:
) -> str:
"""
ユーザー辞書に言葉を追加します。
"""
Expand All @@ -78,7 +76,7 @@ def add_user_dict_word(
word_type=word_type,
priority=priority,
)
return Response(content=word_uuid)
return word_uuid
except ValidationError as e:
raise HTTPException(
status_code=422, detail="パラメータに誤りがあります。\n" + str(e)
Expand Down

0 comments on commit 8398406

Please sign in to comment.