s
File size: 235 Bytes
e8a4c92
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
from gtts import gTTS
import os
import uuid

def generate_speech(text: str) -> str:
    file_name = f"{uuid.uuid4()}.mp3"
    file_path = f"audio/{file_name}"
    tts = gTTS(text)
    tts.save(file_path)
    return file_path