Spaces:
Running
on
Zero
Running
on
Zero
edge tts api
Browse files- app/tts/edge.py +10 -0
app/tts/edge.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import edge_tts
|
2 |
+
import tempfile
|
3 |
+
|
4 |
+
def edge_text_to_speech(text, voice):
|
5 |
+
voice_short_name = voice.split(" - ")[0]
|
6 |
+
communicate = edge_tts.Communicate(text, voice_short_name)
|
7 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
8 |
+
tmp_path = tmp_file.name
|
9 |
+
communicate.save_sync(tmp_path)
|
10 |
+
return tmp_path
|