You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Converter texto para áudio usando uma voz selecionada.
Obter todas as vozes locais
fromMSpeechPyimportSpeechpyClient# Inicializa o clienteengine=SpeechpyClient()
# Obter todas as vozes locaisvoices=engine.get_voices.get_all_local_voices()
print("Todas as vozes locais:")
forvinvoices:
print(v)
Obter vozes por localidade
fromMSpeechPyimportSpeechpyClientengine=SpeechpyClient()
# Obter vozes por localidadelocal='Portuguese (Brazil)'voices_pt_br=engine.get_voices.filter_voices_by_locale_name(local)
print(f"\nVozes para a localidade '{local}':")
forvinvoices_pt_br:
print(v)
fromMSpeechPyimportSpeechpyClient# Inicializa o clienteengine=SpeechpyClient()
# Nome curto da vozshort_name='pt-BR-Daniel'# Obtém as informações da voz pelo nome curtovoice_info=engine.get_voices.filter_voices_by_voice_name(short_name=short_name)
# Imprime os detalhes da vozprint(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
importosfromMSpeechPyimportSpeechpyClient# Inicializa o clienteengine=SpeechpyClient()
# Nome curto da vozshort_name='pt-BR-Daniel'# Obtém as informações da voz pelo nome curtovoice_info=engine.get_voices.filter_voices_by_voice_name(short_name=short_name)
# Verifica se a voz foi encontradaifnotvoice_info:
print(f"Nenhuma voz encontrada com o nome curto '{short_name}'")
exit()
# Texto para conversãotext="Eu sou o Daniel e vou me livrar da maldição dizendo olá mundo!"# Diretório de saídaout_dir='daniel_teste'os.makedirs(out_dir, exist_ok=True)
try:
# Converte o texto em áudioaudio_file_path=engine.text_to_speech.text_to_speech(
text=text,
voice_name=short_name,
output_name='daniel_helloWorld', # Nome do arquivovolume='loud', # Ajusta o volume da vozpitch='-50%', # Adiciona o valor do pitch (tom de voz)output_format='audio-16khz-128kbitrate-mono-mp3', # Formato de saídaoutput_dir=out_dir
)
# Verifica se o arquivo foi gerado corretamenteifos.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.")
exceptExceptionase:
print(f"Ocorreu um erro: {e}")
Contribuições e Suporte
Se tiver dúvidas ou sugestões, abra uma issue aqui