🚀 Auto-deploy: BotVPS atualizado em 28/03/2026 23:32:56
This commit is contained in:
@@ -26,20 +26,25 @@ def transcribe_audio(file_path: str) -> str:
|
||||
|
||||
async def text_to_speech_async(text: str) -> str:
|
||||
"""Sintetiza texto em áudio MP3 usando Edge TTS (Versão ASYNC)."""
|
||||
# Limpeza para narração
|
||||
# Limpeza para narração: remove tudo o que a voz tenta ler literalmente mas não deve
|
||||
texto_limpo = text.replace("🤖", "").replace("🧑🏫", "").replace("*", "").replace("`", "")
|
||||
texto_limpo = re.sub(r'<REFINED>.*?</REFINED>', '', texto_limpo, flags=re.DOTALL).strip()
|
||||
texto_limpo = texto_limpo.replace("#", "").replace("- ", " ").replace("> ", " ")
|
||||
# Remove blocos <REFINED>
|
||||
texto_limpo = re.sub(r'<REFINED>.*?</REFINED>', '', texto_limpo, flags=re.DOTALL)
|
||||
# Remove URLs e links [texto](url)
|
||||
texto_limpo = re.sub(r'\[([^\]]+)\]\([^\)]+\)', r'\1', texto_limpo)
|
||||
texto_limpo = re.sub(r'http[s]?://\S+', '', texto_limpo).strip()
|
||||
|
||||
if not texto_limpo:
|
||||
texto_limpo = "Prompt vazio."
|
||||
texto_limpo = "Prompt processado."
|
||||
|
||||
filename = f"audio_reply_{uuid.uuid4().hex[:8]}.mp3"
|
||||
filepath = os.path.join("/tmp", filename)
|
||||
|
||||
# Voz Masculina PT-BR: Antonio
|
||||
# Rate +20% para ser mais rápido
|
||||
voice = "pt-BR-AntonioNeural"
|
||||
communicate = edge_tts.Communicate(texto_limpo, voice, rate="+20%")
|
||||
# Voz Masculina PT-BR: Donato é uma das mais realistas para comandos rápidos
|
||||
voice = "pt-BR-DonatoNeural"
|
||||
# Rate +35% para ser dinâmico e direto como solicitado
|
||||
communicate = edge_tts.Communicate(texto_limpo, voice, rate="+35%")
|
||||
await communicate.save(filepath)
|
||||
return filename
|
||||
|
||||
|
||||
Reference in New Issue
Block a user