From c6ca5bbaf013a8a7beade95f346275c0888aa32d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Thu, 11 Apr 2024 08:53:25 +0900 Subject: [PATCH 01/16] Update test_basic.py --- tests/test_basic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_basic.py b/tests/test_basic.py index 7aa2573..1220a63 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -1,6 +1,6 @@ import pytest -from voicevox import Client +from vvclient import Client @pytest.mark.asyncio From 92e4da5fd8d0848f5d11933e2762cd24a5d5ac37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Thu, 11 Apr 2024 08:53:50 +0900 Subject: [PATCH 02/16] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index d4c99aa..f396f95 100644 --- a/README.rst +++ b/README.rst @@ -29,7 +29,7 @@ Example .. code:: python - from voicevox import Client + from vvclient import Client import asyncio From 24d2644b9c50fb20e4c378df8b46ebc8dc06298b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Thu, 11 Apr 2024 08:54:09 +0900 Subject: [PATCH 03/16] Update test_fetch_version.py --- tests/test_fetch_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_fetch_version.py b/tests/test_fetch_version.py index f144fa6..5f815ca 100644 --- a/tests/test_fetch_version.py +++ b/tests/test_fetch_version.py @@ -1,6 +1,6 @@ import pytest -from voicevox import Client +from vvclient import Client @pytest.mark.asyncio From d2968cecc940a139251d25f30a38cd2605ede212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Thu, 11 Apr 2024 08:54:21 +0900 Subject: [PATCH 04/16] Update test_init.py --- tests/test_init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_init.py b/tests/test_init.py index 43ab4a5..e32e5d7 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -1,6 +1,6 @@ import pytest -from voicevox import Client +from vvclient import Client @pytest.mark.asyncio From a115f2cb41fdf7d237d154c79831ba146741899d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Thu, 11 Apr 2024 08:54:50 +0900 Subject: [PATCH 05/16] Update basic.py --- examples/basic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/basic.py b/examples/basic.py index 6e9c14d..1ae65a0 100644 --- a/examples/basic.py +++ b/examples/basic.py @@ -1,4 +1,4 @@ -from voicevox import Client +from vvclient import Client import asyncio From 2480b82a20ec552a130a10e79be129fd73fb5984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Thu, 11 Apr 2024 08:55:06 +0900 Subject: [PATCH 06/16] Update get_speakers.py --- examples/get_speakers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/get_speakers.py b/examples/get_speakers.py index 410b3f8..953df73 100644 --- a/examples/get_speakers.py +++ b/examples/get_speakers.py @@ -1,4 +1,4 @@ -from voicevox import Client +from vvclient import Client import asyncio From 7e560e7df8e200527227a38d20bceeadf0284442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Thu, 11 Apr 2024 08:55:23 +0900 Subject: [PATCH 07/16] Update multi_synthesis.py --- examples/multi_synthesis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/multi_synthesis.py b/examples/multi_synthesis.py index f7eb385..31d0643 100644 --- a/examples/multi_synthesis.py +++ b/examples/multi_synthesis.py @@ -1,4 +1,4 @@ -from voicevox import Client +from vvclient import Client import asyncio From 7810a7a0f3828d51d6a01e3f647d8139cb869028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Sat, 13 Apr 2024 01:36:05 +0900 Subject: [PATCH 08/16] Fixed base url --- vvclient/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vvclient/client.py b/vvclient/client.py index 0e362f8..c49819b 100644 --- a/vvclient/client.py +++ b/vvclient/client.py @@ -12,7 +12,7 @@ class Client: ---------- base_uri : str Base URI of the VOICEVOX Engine""" - def __init__(self, base_uri: str) -> None: + def __init__(self, base_uri: str = "http://localhost:50021") -> None: self.http = HTTPClient(base_uri) async def close(self) -> None: From ff86e47b07096b8c662653c433b483a0fb1bd653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Sat, 13 Apr 2024 01:40:50 +0900 Subject: [PATCH 09/16] Update client.py --- vvclient/client.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/vvclient/client.py b/vvclient/client.py index c49819b..8ea8547 100644 --- a/vvclient/client.py +++ b/vvclient/client.py @@ -3,6 +3,7 @@ from typing import Optional from .http import HTTPClient +from .audio_query import AudioQuery class Client: @@ -20,7 +21,25 @@ async def close(self) -> None: async def create_audio_query( self, text: str, speaker: int, *, core_version: Optional[str] = None - ): + ) -> AudioQuery: + """ + Create audio query + + Parameters + ---------- + text: str + Voice text + speaker: int + speaker type + core_version: Optional[str] + voicevox_core version + + Returns + ------- + audio_query: AudioQuery + Audio query + """ params = {"text": text, "speaker": speaker} if core_version: params["core_version"] = core_version + await self.http.create_audio_query(params) From 9dd42c3895851a9ba62c8ba16b512e6434531e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Sat, 13 Apr 2024 01:41:43 +0900 Subject: [PATCH 10/16] Update client.py --- vvclient/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vvclient/client.py b/vvclient/client.py index 8ea8547..a11c5f5 100644 --- a/vvclient/client.py +++ b/vvclient/client.py @@ -42,4 +42,4 @@ async def create_audio_query( params = {"text": text, "speaker": speaker} if core_version: params["core_version"] = core_version - await self.http.create_audio_query(params) + return AudioQuery(self.http, await self.http.create_audio_query(params)) From c3f0911a14d60ed061ebc21f50180ba96b011526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Sat, 13 Apr 2024 01:44:19 +0900 Subject: [PATCH 11/16] Update client.py --- vvclient/client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vvclient/client.py b/vvclient/client.py index a11c5f5..e3967a6 100644 --- a/vvclient/client.py +++ b/vvclient/client.py @@ -16,6 +16,12 @@ class Client: def __init__(self, base_uri: str = "http://localhost:50021") -> None: self.http = HTTPClient(base_uri) + async def __aenter__(self) -> "Client": + return self + + async def __aexit__(self, *args): + await self.close() + async def close(self) -> None: await self.http.close() From 4490d2b063e6eb282088f930df9086dfc71abacc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Sat, 13 Apr 2024 01:47:35 +0900 Subject: [PATCH 12/16] Fixed --- tests/test_basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_basic.py b/tests/test_basic.py index 1220a63..1c8a262 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -6,5 +6,5 @@ @pytest.mark.asyncio async def test_basic(): async with Client() as client: - audio_query = await client.create_audio_query("こんにちは!", style_id=1) - await audio_query.synthesis(style_id=1) + audio_query = await client.create_audio_query("こんにちは!", speaker=1) + await audio_query.synthesis(speaker=1) From 96633b22522bdd2c35d9287d441c2afabe88724e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Sat, 13 Apr 2024 01:49:16 +0900 Subject: [PATCH 13/16] Fixed namederror --- vvclient/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vvclient/http.py b/vvclient/http.py index 5f9d0c2..8a5951d 100644 --- a/vvclient/http.py +++ b/vvclient/http.py @@ -31,7 +31,7 @@ async def request(self, route: Route, **kwargs) -> Any: return await response.json() else: return await response.read() - elif res.status == 404: + elif response.status == 404: raise NotFoundError("Not found") else: raise HTTPException(await response.text(), response.status) From d839b012a1077dd707125d40fe74cf877f0c1ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Sat, 13 Apr 2024 01:52:45 +0900 Subject: [PATCH 14/16] Fix: json to parameters --- vvclient/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vvclient/http.py b/vvclient/http.py index 8a5951d..5fd882d 100644 --- a/vvclient/http.py +++ b/vvclient/http.py @@ -42,7 +42,7 @@ async def close(self) -> None: async def create_audio_query( self, params: Dict[str, Union[str, int]] ) -> AudioQueryType: - return await self.request(Route("POST", "/audio_query"), json=params) + return await self.request(Route("POST", "/audio_query"), params=params) async def synthesis( self, params: Dict[str, Union[str, int]], audio_query: AudioQueryType From 06d4946d4a319c7b05d25d4415ed9c47cdd1d7bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Sat, 13 Apr 2024 01:55:33 +0900 Subject: [PATCH 15/16] Fixed not audio query to synthesis --- vvclient/audio_query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vvclient/audio_query.py b/vvclient/audio_query.py index 6f1a718..744339f 100644 --- a/vvclient/audio_query.py +++ b/vvclient/audio_query.py @@ -24,4 +24,4 @@ async def synthesis( } if core_version: params["core_version"] = core_version - return await self._http.create_audio_query(params, self.data) + return await self._http.synthesis(params, self.data) From 685bf7137034daa492a92168406e2656be800f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=AA=E3=83=B3=E8=A6=AA=E8=A1=9B?= =?UTF-8?q?=E9=9A=8A?= Date: Sat, 13 Apr 2024 02:00:01 +0900 Subject: [PATCH 16/16] Bool to str --- vvclient/audio_query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vvclient/audio_query.py b/vvclient/audio_query.py index 744339f..2ac8107 100644 --- a/vvclient/audio_query.py +++ b/vvclient/audio_query.py @@ -20,7 +20,7 @@ async def synthesis( ) -> bytes: params = { "speaker": speaker, - "enable_interrogative_upspeak": enable_interrogative_upspeak, + "enable_interrogative_upspeak": "true" if enable_interrogative_upspeak else "false", } if core_version: params["core_version"] = core_version