File size: 311 Bytes
42c727a
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
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))