Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -442,21 +442,21 @@ language_dict = {
|
|
| 442 |
}
|
| 443 |
|
| 444 |
|
| 445 |
-
async def
|
| 446 |
-
|
|
|
|
| 447 |
if len(text) > char_limit:
|
| 448 |
-
return f"Error: The input text exceeds the character limit of {char_limit} characters."
|
| 449 |
-
|
| 450 |
-
#
|
| 451 |
-
|
| 452 |
-
voice = language_dict[language_code][speaker]
|
| 453 |
communicate = edge_tts.Communicate(text, voice)
|
| 454 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
| 455 |
-
|
| 456 |
-
|
|
|
|
| 457 |
return text, tmp_path
|
| 458 |
-
|
| 459 |
-
return f"Error: {str(e)}"
|
| 460 |
|
| 461 |
|
| 462 |
def get_speakers(language):
|
|
|
|
| 442 |
}
|
| 443 |
|
| 444 |
|
| 445 |
+
async def text_to_speech_edge(text, language_code, speaker, tashkeel_checkbox=False):
|
| 446 |
+
# Define the character limit
|
| 447 |
+
char_limit = 10000
|
| 448 |
if len(text) > char_limit:
|
| 449 |
+
return f"Error: The input text exceeds the character limit of {char_limit} characters.", None
|
| 450 |
+
|
| 451 |
+
# Get the voice for the selected language and speaker
|
| 452 |
+
voice = language_dict[language_code][speaker]
|
|
|
|
| 453 |
communicate = edge_tts.Communicate(text, voice)
|
| 454 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
| 455 |
+
tmp_path = tmp_file.name
|
| 456 |
+
await communicate.save(tmp_path)
|
| 457 |
+
|
| 458 |
return text, tmp_path
|
| 459 |
+
|
|
|
|
| 460 |
|
| 461 |
|
| 462 |
def get_speakers(language):
|