Skip to content

Commit

Permalink
refactor: Cancellable の version を core_version へ変更して整理
Browse files Browse the repository at this point in the history
  • Loading branch information
tarepan committed Jun 25, 2024
1 parent 5bc60a0 commit dfc4bd0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
4 changes: 1 addition & 3 deletions voicevox_engine/app/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ def generate_app(
metas_store = MetasStore(speaker_info_dir, resource_manager)

app.include_router(
generate_tts_pipeline_router(
tts_engines, core_manager, preset_manager, cancellable_engine
)
generate_tts_pipeline_router(tts_engines, preset_manager, cancellable_engine)
)
app.include_router(generate_morphing_router(tts_engines, core_manager, metas_store))
app.include_router(
Expand Down
5 changes: 1 addition & 4 deletions voicevox_engine/app/routers/tts_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
CancellableEngine,
CancellableEngineInternalError,
)
from voicevox_engine.core.core_initializer import CoreManager
from voicevox_engine.metas.Metas import StyleId
from voicevox_engine.model import AudioQuery
from voicevox_engine.preset.preset_manager import (
Expand Down Expand Up @@ -65,7 +64,6 @@ def __init__(self, err: ParseKanaError):

def generate_tts_pipeline_router(
tts_engines: TTSEngineManager,
core_manager: CoreManager,
preset_manager: PresetManager,
cancellable_engine: CancellableEngine | None,
) -> APIRouter:
Expand Down Expand Up @@ -287,10 +285,9 @@ def cancellable_synthesis(
status_code=404,
detail="実験的機能はデフォルトで無効になっています。使用するには引数を指定してください。",
)
version = core_version or core_manager.latest_version()
try:
f_name = cancellable_engine._synthesis_impl(
query, style_id, request, version=version
query, style_id, request, core_version=core_version
)
except CancellableEngineInternalError as e:
raise HTTPException(status_code=500, detail=str(e))
Expand Down
14 changes: 7 additions & 7 deletions voicevox_engine/cancellable_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def _synthesis_impl(
query: AudioQuery,
style_id: StyleId,
request: Request,
version: str,
core_version: str | None,
) -> str:
"""
音声合成を行う関数
Expand All @@ -163,7 +163,7 @@ def _synthesis_impl(
request: fastapi.Request
接続確立時に受け取ったものをそのまま渡せばよい
https://fastapi.tiangolo.com/advanced/using-request-directly/
version: str
core_version
Returns
-------
Expand All @@ -173,7 +173,7 @@ def _synthesis_impl(
proc, sub_proc_con1 = self.procs_and_cons.get()
self.watch_con_list.append((request, proc))
try:
sub_proc_con1.send((query, style_id, version))
sub_proc_con1.send((query, style_id, core_version))
f_name = sub_proc_con1.recv()
if isinstance(f_name, str):
audio_file_name = f_name
Expand Down Expand Up @@ -244,10 +244,10 @@ def start_synthesis_subprocess(
assert len(tts_engines.versions()) != 0, "音声合成エンジンがありません。"
while True:
try:
query, style_id, version = sub_proc_con.recv()
if tts_engines.has_engine(version):
_engine = tts_engines.get_engine(version)
else:
query, style_id, core_version = sub_proc_con.recv()
try:
_engine = tts_engines.get_engine(core_version)
except Exception:
# バージョンが見つからないエラー
sub_proc_con.send("")
continue
Expand Down

0 comments on commit dfc4bd0

Please sign in to comment.