2026-05-16 08:29:32 +00:00
|
|
|
import asyncio
|
2026-05-16 08:41:42 +00:00
|
|
|
import os
|
2026-05-16 08:29:32 +00:00
|
|
|
import edge_tts
|
|
|
|
|
|
|
|
|
|
|
2026-05-16 08:41:42 +00:00
|
|
|
async def _synthesize(text: str, output_path: str, voice: str):
|
|
|
|
|
communicate = edge_tts.Communicate(text, voice)
|
2026-05-16 08:29:32 +00:00
|
|
|
await communicate.save(output_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_audio(text: str, output_path: str):
|
2026-05-16 08:41:42 +00:00
|
|
|
voice = os.environ.get("BOT_VOICE", "en-US-ChristopherNeural")
|
|
|
|
|
asyncio.run(_synthesize(text, output_path, voice))
|