Funcionalidades
- Obter todas as vozes locais.
- Filtrar vozes por localidade.
- Listar vozes multilíngues.
- Obter detalhes de uma voz específica.
- Converter texto para áudio usando uma voz selecionada.
Obter todas as vozes locais
from MSpeechPy import SpeechpyClient
# Inicializa o cliente
engine = SpeechpyClient()
# Obter todas as vozes locais
voices = engine.get_voices.get_all_local_voices()
print("Todas as vozes locais:")
for v in voices:
print(v)
Obter vozes por localidade
from MSpeechPy import SpeechpyClient
engine = SpeechpyClient()
# Obter vozes por localidade
local = 'Portuguese (Brazil)'
voices_pt_br = engine.get_voices.filter_voices_by_locale_name(local)
print(f"\nVozes para a localidade '{local}':")
for v in voices_pt_br:
print(v)
Obter vozes multilíngues
from MSpeechPy import SpeechpyClient
engine = SpeechpyClient()
# Obter vozes multilíngues
voices_multilingual = engine.get_voices.get_all_multilingual()
print("\nTodas as vozes multilíngues:")
for v in voices_multilingual:
print(v)
Obter detalhes de uma voz específica
from MSpeechPy import SpeechpyClient
# Inicializa o cliente
engine = SpeechpyClient()
# Nome curto da voz
short_name = 'pt-BR-Daniel'
# Obtém as informações da voz pelo nome curto
voice_info = engine.get_voices.filter_voices_by_voice_name(short_name=short_name)
# Imprime os detalhes da voz
print(f"Voice Type: {voice_info.voice_type}")
print(f"Sample Rate Hertz: {voice_info.sample_rate_hertz}")
print(f"Name: {voice_info.name}")
print(f"Short Name: {voice_info.short_name}")
print(f"Status: {voice_info.status}")
print(f"Output Format: {voice_info.get_output_format}")
print(f"Display Name: {voice_info.display_name}")
print(f"Gender: {voice_info.gender}")
print(f"Locale Name: {voice_info.locale_name}")
print(f"Style List: {voice_info.style_list}")
print(f"Words Per Minute: {voice_info.words_per_minute}")
Converter texto para voz usando uma voz
import os
from MSpeechPy import SpeechpyClient
# Inicializa o cliente
engine = SpeechpyClient()
# Nome curto da voz
short_name = 'pt-BR-Daniel'
# Obtém as informações da voz pelo nome curto
voice_info = engine.get_voices.filter_voices_by_voice_name(short_name=short_name)
# Verifica se a voz foi encontrada
if not voice_info:
print(f"Nenhuma voz encontrada com o nome curto '{short_name}'")
exit()
# Texto para conversão
text = "Eu sou o Daniel e vou me livrar da maldição dizendo olá mundo!"
# Diretório de saída
out_dir = 'daniel_teste'
os.makedirs(out_dir, exist_ok=True)
try:
# Converte o texto em áudio
audio_file_path = engine.text_to_speech.text_to_speech(
text=text,
voice_name=short_name,
output_name='daniel_helloWorld', # Nome do arquivo
volume='loud', # Ajusta o volume da voz
pitch='-50%', # Adiciona o valor do pitch (tom de voz)
output_format='audio-16khz-128kbitrate-mono-mp3', # Formato de saída
output_dir=out_dir
)
# Verifica se o arquivo foi gerado corretamente
if os.path.exists(audio_file_path):
print(f"Arquivo de áudio gerado com sucesso: {audio_file_path}")
else:
print("Falha ao gerar o arquivo de áudio.")
except Exception as e:
print(f"Ocorreu um erro: {e}")
Contribuições e Suporte
Se tiver dúvidas ou sugestões, abra uma issue aqui
Release files for MSpeechPy 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mspeechpy-0.2.2.tar.gz | 21.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| MSpeechPy-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:32.7 kB
Release files / mspeechpy-0.2.2.tar.gz
| Download URL | mspeechpy-0.2.2.tar.gz |
|---|---|
| Size | 21.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93ac91b950203b8c0e848ead3a3914206843719cca7de15a97c49a83b38f4a1f
|
|
BLAKE2b-256 checksum How to use checksums |
9a238c767864422dd4df94b439348d82189d40b2f05afb3f77d0ac7f6aab11d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.2
|
Release files / MSpeechPy-0.2.2-py3-none-any.whl
| Download URL | MSpeechPy-0.2.2-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0346f5bbeb0b54b38297a299419e50ffe6a914382ddc226128e622fcfeaacf73
|
|
BLAKE2b-256 checksum How to use checksums |
a0ccdaa7dee8b67d0e38f2abaa603cef7d5871d31a2820fb9a5aca318a7e804c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.2
|