hivecorp commited on
Commit
1110741
·
verified ·
1 Parent(s): 73a31ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -443,18 +443,22 @@ language_dict = {
443
 
444
 
445
  async def text_to_speech_edge(text, language_code, speaker, tashkeel_checkbox=False):
446
-
447
-
 
 
 
448
  # Get the voice for the selected language and speaker
449
  voice = language_dict[language_code][speaker]
450
  communicate = edge_tts.Communicate(text, voice)
451
  with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
452
- tmp_path = tmp_file.name
453
- await communicate.save(tmp_path)
454
 
455
  return text, tmp_path
456
 
457
 
 
458
  def get_speakers(language):
459
  print(language)
460
  speakers = list(language_dict[language].keys())
@@ -465,9 +469,9 @@ default_language = None
465
  default_speaker = None
466
  with gr.Blocks(title="Writoo AI V2") as demo:
467
  gr.HTML(" ")
468
- gr.HTML(f"<h2 style='color:Tomato;'> 🎥 **Exciting News: 60+ Minutes File Creation is also Free !!** 🎥 </h3>")
469
 
470
- gr.Markdown("✨ Features: • Convert text to speech with 60+ audio files. Choose from 72+ languages • Its Free 😍")
471
  with gr.Row():
472
  with gr.Column():
473
  input_text = gr.Textbox(lines=5, label="Input Text", placeholder="Enter text to convert to speech")
 
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: Use {char_limit} Characters at a time. Upgrade to Premium if you want Unlimited. ", 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):
463
  print(language)
464
  speakers = list(language_dict[language].keys())
 
469
  default_speaker = None
470
  with gr.Blocks(title="Writoo AI V2") as demo:
471
  gr.HTML(" ")
472
+ gr.HTML(f"<h2 style='color:Tomato;'🎶 Exciting News: 15 More Voice Added to Premium Plans 🎶 </h3>")
473
 
474
+ gr.Markdown("✨ Features: • Convert text to speech in seconds . Choose from 72+ languages • Its Free 😍")
475
  with gr.Row():
476
  with gr.Column():
477
  input_text = gr.Textbox(lines=5, label="Input Text", placeholder="Enter text to convert to speech")