Spaces:
Building
Building
Create tts_module.py
Browse files- tts_module.py +13 -0
tts_module.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
import tempfile
|
3 |
+
import edge_tts
|
4 |
+
|
5 |
+
async def text_to_speech(text):
|
6 |
+
voice = "en-US-AriaNeural" # Puedes cambiar esto por otras voces disponibles
|
7 |
+
rate = "0%" # Ajuste de velocidad
|
8 |
+
pitch = "0Hz" # Ajuste de tono
|
9 |
+
|
10 |
+
communicate = edge_tts.Communicate(text, voice, rate=rate, pitch=pitch)
|
11 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
12 |
+
await communicate.save(tmp_file.name)
|
13 |
+
return tmp_file.name
|