hivecorp commited on
Commit
2359dec
·
verified ·
1 Parent(s): 4339ed2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -442,21 +442,21 @@ language_dict = {
442
  }
443
 
444
 
445
- async def generate_tts(text, language_code, speaker, tashkeel_checkbox=False):
446
- char_limit = 10000 # Define the character limit
 
447
  if len(text) > char_limit:
448
- return f"Error: The input text exceeds the character limit of {char_limit} characters."
449
-
450
- # Proceed with the existing logic
451
- try:
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
  return text, tmp_path
458
- except Exception as e:
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):