From e094b528aadbf54535264b2b7baa1275e33c300a Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Thu, 31 Oct 2024 02:20:14 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20Python=20API=E3=81=A8example/python/run.?= =?UTF-8?q?py=E3=81=AE=E5=9E=8B=E4=BB=98=E3=81=91=E3=82=92=E7=9B=B4?= =?UTF-8?q?=E3=81=99=20(#864)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: https://github.com/VOICEVOX/voicevox_core/pull/854#discussion_r1806646080 --- .../python/voicevox_core/_rust/blocking.pyi | 18 ++++++++++++++++++ .../python/voicevox_core/blocking.py | 10 +++++++++- example/python/run.py | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/crates/voicevox_core_python_api/python/voicevox_core/_rust/blocking.pyi b/crates/voicevox_core_python_api/python/voicevox_core/_rust/blocking.pyi index cf4f1f5c6..9d73c032b 100644 --- a/crates/voicevox_core_python_api/python/voicevox_core/_rust/blocking.pyi +++ b/crates/voicevox_core_python_api/python/voicevox_core/_rust/blocking.pyi @@ -139,6 +139,12 @@ class OpenJtalk: """ ... +class AudioFeature: + @property + def frame_length(self) -> int: ... + @property + def frame_rate(self) -> float: ... + class Synthesizer: """ 音声シンセサイザ。 @@ -351,6 +357,18 @@ class Synthesizer: スタイルID。 """ ... + def precompute_render( + self, + audio_query: AudioQuery, + style_id: Union[StyleId, int], + enable_interrogative_upspeak: bool = True, + ) -> AudioFeature: ... + def render( + self, + audio: AudioFeature, + start: int, + end: int, + ) -> bytes: ... def synthesis( self, audio_query: AudioQuery, diff --git a/crates/voicevox_core_python_api/python/voicevox_core/blocking.py b/crates/voicevox_core_python_api/python/voicevox_core/blocking.py index 01ea45029..631eb6a81 100644 --- a/crates/voicevox_core_python_api/python/voicevox_core/blocking.py +++ b/crates/voicevox_core_python_api/python/voicevox_core/blocking.py @@ -1,5 +1,6 @@ # pyright: reportMissingModuleSource=false from ._rust.blocking import ( + AudioFeature, Onnxruntime, OpenJtalk, Synthesizer, @@ -7,4 +8,11 @@ VoiceModelFile, ) -__all__ = ["Onnxruntime", "OpenJtalk", "Synthesizer", "UserDict", "VoiceModelFile"] +__all__ = [ + "AudioFeature", + "Onnxruntime", + "OpenJtalk", + "Synthesizer", + "UserDict", + "VoiceModelFile", +] diff --git a/example/python/run.py b/example/python/run.py index 64a871bc2..17f7e688f 100644 --- a/example/python/run.py +++ b/example/python/run.py @@ -71,7 +71,7 @@ def main() -> None: logger.info("%s", f"Wrote `{out}`") -def parse_args() -> Tuple[AccelerationMode, Path, str, Path, str, Path, int]: +def parse_args() -> Tuple[AccelerationMode, Path, str, Path, str, Path, int, bool]: argparser = ArgumentParser() argparser.add_argument( "--mode",