Skip to main content

Converter texto para voz

Project description

MSpeechPy

Converter textos para voz usando Python!

Versão Licença Sponsor


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

Sponsor

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mspeechpy-0.2.2.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

MSpeechPy-0.2.2-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file mspeechpy-0.2.2.tar.gz.

File metadata

  • Download URL: mspeechpy-0.2.2.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for mspeechpy-0.2.2.tar.gz
Algorithm Hash digest
SHA256 93ac91b950203b8c0e848ead3a3914206843719cca7de15a97c49a83b38f4a1f
MD5 3d22b50d0af2f10ac746d2a968470d7a
BLAKE2b-256 9a238c767864422dd4df94b439348d82189d40b2f05afb3f77d0ac7f6aab11d5

See more details on using hashes here.

File details

Details for the file MSpeechPy-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: MSpeechPy-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for MSpeechPy-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0346f5bbeb0b54b38297a299419e50ffe6a914382ddc226128e622fcfeaacf73
MD5 21113e473d3d22dd4a51fca79108f03d
BLAKE2b-256 a0ccdaa7dee8b67d0e38f2abaa603cef7d5871d31a2820fb9a5aca318a7e804c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page