Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add supported devices #30

Merged
merged 3 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]