diff --git a/voicevox/client.py b/voicevox/client.py index f68902a..950eaa8 100644 --- a/voicevox/client.py +++ b/voicevox/client.py @@ -9,6 +9,7 @@ from .http import HttpClient from .speakers import Speaker from .speaker_info import SpeakerInfo +from .supported_devices import SupportedDevices logger = logging.getLogger(__name__) @@ -150,6 +151,12 @@ async def fetch_speaker_info( """ return SpeakerInfo(await self.http.get_speaker_info(speaker_uuid, core_version)) + async def check_devices(self, core_version: Optional[str] = None) -> SupportedDevices: + params = {} + if core_version: + params["core_version"] = core_version + return SupportedDevices(await self.http.supported_devices(params)) + async def multi_synthesis( self, audio_queries: List[AudioQuery], speaker: int, *, core_version: Optional[str] = None diff --git a/voicevox/http.py b/voicevox/http.py index 30614e3..b0d1b5f 100644 --- a/voicevox/http.py +++ b/voicevox/http.py @@ -1,6 +1,6 @@ # voicevox - http -from typing import List, Optional +from typing import List, Optional, Dict import logging @@ -98,5 +98,5 @@ async def initialize_speaker(self, params: dict) -> None: async def is_initialized_speaker(self, params: dict) -> bool: return await self.request("GET", "/is_initialized_speaker", params=params) - - + async def supported_devices(self, params: dict) -> Dict[str, bool]: + return await self.request("GET", "/supported_devices") diff --git a/voicevox/supported_devices.py b/voicevox/supported_devices.py new file mode 100644 index 0000000..8585363 --- /dev/null +++ b/voicevox/supported_devices.py @@ -0,0 +1,31 @@ +# voicevox-client - supported devices + +from typing import Dict + + +class SupportedDevices: + """Supported devices + + Attributes + ---------- + cpu : bool + Check cpu support + cuda : bool + Check cuda support + dml : bool + Check directml support + """ + def __init__(self, payload: Dict[str, bool]): + self.__data = payload + + @property + def cpu(self) -> bool: + return self.__data["cpu"] + + @property + def cuda(self) -> bool: + return self.__data["cuda"] + + @property + def dml(self) -> bool: + return self.__data["dml"]