voicevox package#
Subpackages#
Submodules#
voicevox.audio_query module#
- class voicevox.audio_query.AccentPhrase(payload: AccentPhraseType)#
Bases:
objectAccent phrase class
- accent#
アクセント箇所
- Type:
int
- is_interrogative#
疑問系かどうか
- Type:
bool
- to_dict() AccentPhraseType#
- class voicevox.audio_query.AudioQuery(http: HttpClient, payload: AudioQueryType)#
Bases:
objectAudio query
Audio query to do synthesis.
- accent_phrases#
アクセント句のリスト
- Type:
dict
- speed_scale#
Speech speed
- Type:
float
- pitch_scale#
Speech pitch
- Type:
float
- intonation_scale#
Speech intonation
- Type:
float
- volume_scale#
Speech volume
- Type:
float
- pre_phoneme_length#
音声の前の無音時間
- Type:
float
- post_phoneme_length#
音声の後の無音時間
- Type:
float
- output_sampling_rate#
音声データの出力サンプリングレート
- Type:
int
- output_stereo#
音声データをステレオ出力するか否か
- Type:
bool
- kana#
[読み取り専用]AquesTalkライクな読み仮名。音声合成クエリとしては無視される
- Type:
str
- property kana: str#
- async synthesis(*, enable_interrogative_upspeak: bool = True, speaker: int, core_version: str | None = None) bytes#
- to_dict() AudioQueryType#
- class voicevox.audio_query.Mora(payload: MoraType)#
Bases:
objectMora class
- text#
Text to synthesize
- Type:
str
- consonant#
Start of consonants
- Type:
str
- consonant_length#
Pronounciation length of consonants
- Type:
int
- vowel#
Start of vowels
- Type:
str
- vowel_length#
Length of vowels
- Type:
int
- pitch#
ピッチ //Pitch of the voice
- Type:
int
- to_dict() dict#
voicevox.client module#
- class voicevox.client.Client(base_url: str = 'http://localhost:50021', timeout: int | None = None)#
Bases:
objectVoicevox client class
Wrap voicevox engine api.
- Parameters:
base_url (str) – Voicevox engine endpoint uri.
- http#
Http client attribute.
- Type:
- timeout#
You can customize timeout. If you use cpu mode, I recommend to use this.
- Type:
Optional[int]
- async check_devices(core_version: str | None = None) SupportedDevices#
- async check_inited_speaker(speaker: int, *, core_version: str | None = None)#
Check initialized speaker
Returns whether the speaker with the specified speaker_id is initialized or not.
- Parameters:
speaker (int) – speaker id
core_version (Optional[str]) – core version
- Returns:
If initialized speaker, it return True.
- Return type:
bool
- async close() None#
Close http client
You must run this function, when you finish process.
- async create_audio_query(text: str, speaker: int, *, core_version: str | None = None) AudioQuery#
Create audio query
If you want do tts, you must run first.
- Parameters:
text (str) – Text message
style_id (int) – Speaker id
core_version (str) – Core version
- Returns:
Audio query, that run synthesis.
- Return type:
- async create_audio_query_from_preset(text: str, preset_id: int, *, core_version: str | None = None) AudioQuery#
- async fetch_core_versions() List[str]#
Fetch core versions
This can fetch voicevox core versions.
- Returns:
Core versions
- Return type:
List[str]
- async fetch_engine_version() str#
Fetch engine version
This can fetch voicevox engine version.
- Returns:
Engine version
- Return type:
str
- async fetch_speaker_info(speaker_uuid: str, core_version: str | None = None) SpeakerInfo#
Fetch speaker’s info by given uuid.
This function retrieves additional information about a specific speaker, including its voice samples, icon, and portrait images.
- Parameters:
speaker_uuid (str) – speaker’s uuid
core_version (Optional[str]) – voicevox core version
- Returns:
Contains additional information of the speaker.
- Return type:
SpeakerInfo
- async fetch_speakers(core_version: str | None = None) List[Speaker]#
Fetch speakers
This can fetch voicevox speakers.
- Returns:
Speakers
- Return type:
List[Speaker]
- async init_speaker(speaker: int, *, skip_reinit: bool = False, core_version: str | None = None) None#
Initilize speaker
Initializes the speaker with the specified speaker_id. Other APIs can be used without executing this function, but it may take some time when it is executed for the first time.
- Parameters:
speaker (int) – speaker id
skip_reinit (bool) – Whether to skip reinitialization of speakers who have already been initialized
core_version (Optional[str]) – core version
- async multi_synthesis(audio_queries: List[AudioQuery], speaker: int, *, core_version: str | None = None) bytes#
Multi synthe
This function is like AudioQuery.synthesis, but it can synthesis multi!
- Parameters:
audio_queries (List[AudioQuery]) – Array of audio query
speaker (int) – speaker id
core_version (Optional[str]) – voicevox core version
- Returns:
Return zip file
- Return type:
bytes
voicevox.errors module#
- exception voicevox.errors.HttpException#
Bases:
Exception
- exception voicevox.errors.NotfoundError#
Bases:
HttpException
voicevox.http module#
- class voicevox.http.HttpClient(base_url: str, timeout: int | None = None)#
Bases:
objectVOICEVOX Engine HTTP Client.
- async close() None#
- async create_audio_query(params: dict) AudioQueryType#
- async create_audio_query_from_preset(params: dict) AudioQueryType#
- async get_core_versions() List[str]#
- async get_speaker_info(speaker_uuid: str, core_version: str | None) SpeakerInfoType#
- async get_speakers(core_version: str | None) List[SpeakerType]#
- async get_version() str#
- async initialize_speaker(params: dict) None#
- async is_initialized_speaker(params: dict) bool#
- async multi_synthesis(params: dict, payload: List[dict]) bytes#
- async request(method: str, path: str, **kwargs) dict#
- async supported_devices(params: dict) Dict[str, bool]#
- async synthesis(params: dict, payload: dict) bytes#
voicevox.speakers module#
- class voicevox.speakers.Speaker(payload: SpeakerType)#
Bases:
objectReturn speaker info
- supported_features#
return supported_features
- Type:
- name#
speaker name
- Type:
str
- uuid#
speaker uuid
- Type:
str
- version#
speaker version
- Type:
str
- class voicevox.speakers.Style(payload: StyleType)#
Bases:
objectReturn style info
- name#
style name
- Type:
str
- id#
style id
- Type:
int
- property id: int#
- property name: str#
- class voicevox.speakers.SupportedFeature(payload: SupportedFeatureType)#
Bases:
objectReturn supported feature info
- permitted_synthesis_morphing#
return permitted_synthesis_morphing
- Type:
str
Module contents#
voicevox client for python.#
Unoffical API wrapper that you can use voicevox easy!
Requirements#
Voicevox engine only!
Well if you want install voicevox engine, please read this.
Install#
pip install voicevox-client
All that!
Example#
from voicevox import Client
import asyncio
async def main():
async with Client() as client:
audio_query = await client.create_audio_query(
"こんにちは!", style_id=1
)
with open("voice.wav", "wb") as f:
f.write(await audio_query.synthesis(style_id=1))
if __name__ == "__main__":
## already in asyncio (in a Jupyter notebook, for example)
# await main()
## otherwise
asyncio.run(main())
- class voicevox.AudioQuery(http: HttpClient, payload: AudioQueryType)#
Bases:
objectAudio query
Audio query to do synthesis.
- accent_phrases#
アクセント句のリスト
- Type:
dict
- speed_scale#
Speech speed
- Type:
float
- pitch_scale#
Speech pitch
- Type:
float
- intonation_scale#
Speech intonation
- Type:
float
- volume_scale#
Speech volume
- Type:
float
- pre_phoneme_length#
音声の前の無音時間
- Type:
float
- post_phoneme_length#
音声の後の無音時間
- Type:
float
- output_sampling_rate#
音声データの出力サンプリングレート
- Type:
int
- output_stereo#
音声データをステレオ出力するか否か
- Type:
bool
- kana#
[読み取り専用]AquesTalkライクな読み仮名。音声合成クエリとしては無視される
- Type:
str
- property kana: str#
- async synthesis(*, enable_interrogative_upspeak: bool = True, speaker: int, core_version: str | None = None) bytes#
- to_dict() AudioQueryType#
- class voicevox.Client(base_url: str = 'http://localhost:50021', timeout: int | None = None)#
Bases:
objectVoicevox client class
Wrap voicevox engine api.
- Parameters:
base_url (str) – Voicevox engine endpoint uri.
- http#
Http client attribute.
- Type:
- timeout#
You can customize timeout. If you use cpu mode, I recommend to use this.
- Type:
Optional[int]
- async check_devices(core_version: str | None = None) SupportedDevices#
- async check_inited_speaker(speaker: int, *, core_version: str | None = None)#
Check initialized speaker
Returns whether the speaker with the specified speaker_id is initialized or not.
- Parameters:
speaker (int) – speaker id
core_version (Optional[str]) – core version
- Returns:
If initialized speaker, it return True.
- Return type:
bool
- async close() None#
Close http client
You must run this function, when you finish process.
- async create_audio_query(text: str, speaker: int, *, core_version: str | None = None) AudioQuery#
Create audio query
If you want do tts, you must run first.
- Parameters:
text (str) – Text message
style_id (int) – Speaker id
core_version (str) – Core version
- Returns:
Audio query, that run synthesis.
- Return type:
- async create_audio_query_from_preset(text: str, preset_id: int, *, core_version: str | None = None) AudioQuery#
- async fetch_core_versions() List[str]#
Fetch core versions
This can fetch voicevox core versions.
- Returns:
Core versions
- Return type:
List[str]
- async fetch_engine_version() str#
Fetch engine version
This can fetch voicevox engine version.
- Returns:
Engine version
- Return type:
str
- async fetch_speaker_info(speaker_uuid: str, core_version: str | None = None) SpeakerInfo#
Fetch speaker’s info by given uuid.
This function retrieves additional information about a specific speaker, including its voice samples, icon, and portrait images.
- Parameters:
speaker_uuid (str) – speaker’s uuid
core_version (Optional[str]) – voicevox core version
- Returns:
Contains additional information of the speaker.
- Return type:
SpeakerInfo
- async fetch_speakers(core_version: str | None = None) List[Speaker]#
Fetch speakers
This can fetch voicevox speakers.
- Returns:
Speakers
- Return type:
List[Speaker]
- async init_speaker(speaker: int, *, skip_reinit: bool = False, core_version: str | None = None) None#
Initilize speaker
Initializes the speaker with the specified speaker_id. Other APIs can be used without executing this function, but it may take some time when it is executed for the first time.
- Parameters:
speaker (int) – speaker id
skip_reinit (bool) – Whether to skip reinitialization of speakers who have already been initialized
core_version (Optional[str]) – core version
- async multi_synthesis(audio_queries: List[AudioQuery], speaker: int, *, core_version: str | None = None) bytes#
Multi synthe
This function is like AudioQuery.synthesis, but it can synthesis multi!
- Parameters:
audio_queries (List[AudioQuery]) – Array of audio query
speaker (int) – speaker id
core_version (Optional[str]) – voicevox core version
- Returns:
Return zip file
- Return type:
bytes
- exception voicevox.HttpException#
Bases:
Exception
- exception voicevox.NotfoundError#
Bases:
HttpException
- class voicevox.Speaker(payload: SpeakerType)#
Bases:
objectReturn speaker info
- supported_features#
return supported_features
- Type:
- name#
speaker name
- Type:
str
- uuid#
speaker uuid
- Type:
str
- version#
speaker version
- Type:
str
- class voicevox.Style(payload: StyleType)#
Bases:
objectReturn style info
- name#
style name
- Type:
str
- id#
style id
- Type:
int
- property id: int#
- property name: str#
- class voicevox.SupportedFeature(payload: SupportedFeatureType)#
Bases:
objectReturn supported feature info
- permitted_synthesis_morphing#
return permitted_synthesis_morphing
- Type:
str