Flux9665 commited on
Commit
ec841b5
1 Parent(s): 8480fce

add messages for prompts which are too long

Browse files
Files changed (1) hide show
  1. app.py +29 -3
app.py CHANGED
@@ -48,7 +48,7 @@ class TTS_Interface:
48
  'Italian' : "it",
49
  }
50
  self.speaker_path_lookup = {
51
- "English Speaker's Voice" : "reference_audios/english.wav",
52
  "German Speaker's Voice" : "reference_audios/german.wav",
53
  "Greek Speaker's Voice" : "reference_audios/greek.wav",
54
  "Spanish Speaker's Voice" : "reference_audios/spanish.wav",
@@ -59,10 +59,36 @@ class TTS_Interface:
59
  "French Speaker's Voice" : "reference_audios/french.wav",
60
  "Polish Speaker's Voice" : "reference_audios/polish.flac",
61
  "Portuguese Speaker's Voice": "reference_audios/portuguese.flac",
62
- "Italian Speaker's Voice" : "reference_audios/italian.flac",
63
  }
64
 
65
  def read(self, prompt, language, speaker):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  if self.current_language != language:
67
  self.model.set_language(self.language_id_lookup[language])
68
  self.current_language = language
@@ -78,7 +104,7 @@ article = "<p style='text-align: left'>This is still a work in progress, models
78
 
79
  iface = gr.Interface(fn=meta_model.read,
80
  inputs=[gr.inputs.Textbox(lines=2,
81
- placeholder="write what you want the synthesis to read here...",
82
  label=" "),
83
  gr.inputs.Dropdown(['English',
84
  'German',
 
48
  'Italian' : "it",
49
  }
50
  self.speaker_path_lookup = {
51
+ "English Speaker's Voice" : "reference_audios/english.wav",
52
  "German Speaker's Voice" : "reference_audios/german.wav",
53
  "Greek Speaker's Voice" : "reference_audios/greek.wav",
54
  "Spanish Speaker's Voice" : "reference_audios/spanish.wav",
 
59
  "French Speaker's Voice" : "reference_audios/french.wav",
60
  "Polish Speaker's Voice" : "reference_audios/polish.flac",
61
  "Portuguese Speaker's Voice": "reference_audios/portuguese.flac",
62
+ "Italian Speaker's Voice" : "reference_audios/italian.flac",
63
  }
64
 
65
  def read(self, prompt, language, speaker):
66
+ if len(prompt) > 2000:
67
+ if language == "English":
68
+ prompt = "Your input was too long. Please try either a shorter text or split it into several parts."
69
+ elif language == "German":
70
+ prompt = "Deine Eingabe war zu lang. Bitte versuche es entweder mit einem kürzeren Text oder teile ihn in mehrere Teile auf."
71
+ elif language == "Greek":
72
+ prompt = "Η εισήγησή σας ήταν πολύ μεγάλη. Παρακαλώ δοκιμάστε είτε ένα μικρότερο κείμενο είτε χωρίστε το σε διάφορα μέρη."
73
+ elif language == "Spanish":
74
+ prompt = "Su entrada es demasiado larga. Por favor, intente un texto más corto o divídalo en varias partes."
75
+ elif language == "Finnish":
76
+ prompt = "Vastauksesi oli liian pitkä. Kokeile joko lyhyempää tekstiä tai jaa se useampaan osaan."
77
+ elif language == "Russian":
78
+ prompt = "Ваш текст слишком длинный. Пожалуйста, попробуйте либо сократить текст, либо разделить его на несколько частей."
79
+ elif language == "Hungarian":
80
+ prompt = "Túl hosszú volt a bevitele. Kérjük, próbáljon meg rövidebb szöveget írni, vagy ossza több részre."
81
+ elif language == "Dutch":
82
+ prompt = "Uw input was te lang. Probeer een kortere tekst of splits het in verschillende delen."
83
+ elif language == "French":
84
+ prompt = "Votre saisie était trop longue. Veuillez essayer un texte plus court ou le diviser en plusieurs parties."
85
+ elif language == 'Polish':
86
+ prompt = "Twój wpis był zbyt długi. Spróbuj skrócić tekst lub podzielić go na kilka części."
87
+ elif language == 'Portuguese':
88
+ prompt = "O seu contributo foi demasiado longo. Por favor, tente um texto mais curto ou divida-o em várias partes."
89
+ elif language == 'Italian':
90
+ prompt = "Il tuo input era troppo lungo. Per favore, prova un testo più corto o dividilo in più parti."
91
+
92
  if self.current_language != language:
93
  self.model.set_language(self.language_id_lookup[language])
94
  self.current_language = language
 
104
 
105
  iface = gr.Interface(fn=meta_model.read,
106
  inputs=[gr.inputs.Textbox(lines=2,
107
+ placeholder="write what you want the synthesis to read here... (2000 character maximum)",
108
  label=" "),
109
  gr.inputs.Dropdown(['English',
110
  'German',