Skip to content

Commit

Permalink
Add supported devices (#30)
Browse files Browse the repository at this point in the history
* Add supported devices

* Add: supported devices

* Add
  • Loading branch information
tuna2134 authored May 9, 2023
1 parent 1ed7084 commit 97e1282
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
7 changes: 7 additions & 0 deletions voicevox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions voicevox/http.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# voicevox - http

from typing import List, Optional
from typing import List, Optional, Dict

import logging

Expand Down Expand Up @@ -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")
31 changes: 31 additions & 0 deletions voicevox/supported_devices.py
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 97e1282

Please sign in to comment.