init: scripts diversos (crawlers, conversores, scrapers)
This commit is contained in:
73
tts-generator/azure_tts_ptpt.py
Executable file
73
tts-generator/azure_tts_ptpt.py
Executable file
@@ -0,0 +1,73 @@
|
||||
"""
|
||||
azure_tts_ptpt.py
|
||||
|
||||
Author: Descomplicar® Crescimento Digital
|
||||
Link: https://descomplicar.pt
|
||||
Copyright: 2025 Descomplicar®
|
||||
"""
|
||||
|
||||
# Plano B: Azure Speech Services (Excelente PT-PT)
|
||||
# pip install azure-cognitiveservices-speech
|
||||
|
||||
import azure.cognitiveservices.speech as speechsdk
|
||||
import os
|
||||
|
||||
def generate_audio_azure():
|
||||
"""
|
||||
Gera áudio com Azure Speech (excelente PT-PT)
|
||||
"""
|
||||
# Configurar Azure Speech
|
||||
speech_key = os.environ.get("AZURE_SPEECH_KEY")
|
||||
service_region = "westeurope" # Região Europa para melhor PT-PT
|
||||
|
||||
# Configurar speech config
|
||||
speech_config = speechsdk.SpeechConfig(
|
||||
subscription=speech_key,
|
||||
region=service_region
|
||||
)
|
||||
|
||||
# Configurar voz PT-PT feminina
|
||||
speech_config.speech_synthesis_voice_name = "pt-PT-FernandaNeural"
|
||||
|
||||
# Texto da Descomplicar
|
||||
texto = """Bem-vindos à Descomplicar, a agência de aceleração digital que transforma a vossa presença online numa máquina de crescimento.
|
||||
|
||||
Somos especialistas em Marketing Digital, criação de websites profissionais e estratégias que geram resultados reais para o vosso negócio.
|
||||
|
||||
Na Descomplicar, a nossa filosofia é simples: tornar o complexo mais simples."""
|
||||
|
||||
# Configurar saída para ficheiro
|
||||
audio_config = speechsdk.audio.AudioOutputConfig(
|
||||
filename="descomplicar_azure_ptpt.wav"
|
||||
)
|
||||
|
||||
# Criar sintetizador
|
||||
synthesizer = speechsdk.SpeechSynthesizer(
|
||||
speech_config=speech_config,
|
||||
audio_config=audio_config
|
||||
)
|
||||
|
||||
print("🇵🇹 Gerando áudio com Azure Speech PT-PT...")
|
||||
|
||||
try:
|
||||
result = synthesizer.speak_text_async(texto).get()
|
||||
|
||||
if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
|
||||
print("✅ Áudio Azure PT-PT gerado: descomplicar_azure_ptpt.wav")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Erro: {result.reason}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Erro Azure: {e}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
if not os.environ.get("AZURE_SPEECH_KEY"):
|
||||
print("❌ AZURE_SPEECH_KEY não configurada!")
|
||||
print("🔗 Obtenha grátis: https://portal.azure.com/")
|
||||
print("💡 500.000 caracteres/mês gratuitos")
|
||||
exit(1)
|
||||
|
||||
generate_audio_azure()
|
||||
Reference in New Issue
Block a user