FluentQ / app /text_to_speech.py
tommytracx's picture
Upload 4 files
42c727a verified
raw
history blame contribute delete
311 Bytes
import asyncio
import edge_tts
async def generate_tts(text: str):
communicate = edge_tts.Communicate(text, "en-US-JennyNeural")
await communicate.save("speech.mp3")
with open("speech.mp3", "rb") as f:
return f.read()
def synthesize_speech(text):
return asyncio.run(generate_tts(text))