fffiloni commited on
Commit
b8896c6
1 Parent(s): b5a7718

Added user infos about max number sentences

Browse files
Files changed (1) hide show
  1. app.py +23 -12
app.py CHANGED
@@ -165,15 +165,21 @@ NEW INFERENCE:
165
 
166
  # Split the text into sentences based on common punctuation marks
167
  sentences = re.split(r'(?<=[.!?])\s+', prompt)
 
 
 
 
 
168
 
169
- # Keep only the first MAX_NUMBER_SENTENCES sentences
170
- first_nb_sentences = sentences[:MAX_NUMBER_SENTENCES]
171
-
172
- # Join the selected sentences back into a single string
173
- limited_prompt = ' '.join(first_nb_sentences)
 
174
 
175
  gr.Info("Generating audio from prompt")
176
- tts.tts_to_file(text=limited_prompt,
177
  file_path="output.wav",
178
  voice_dir="bark_voices/",
179
  speaker=f"{file_name}")
@@ -200,14 +206,19 @@ NEW INFERENCE:
200
  # Split the text into sentences based on common punctuation marks
201
  sentences = re.split(r'(?<=[.!?])\s+', prompt)
202
 
203
- # Keep only the first MAX_NUMBER_SENTENCES sentences
204
- first_nb_sentences = sentences[:MAX_NUMBER_SENTENCES]
 
 
205
 
206
- # Join the selected sentences back into a single string
207
- limited_prompt = ' '.join(first_nb_sentences)
 
 
 
 
208
 
209
- gr.Info(f"Generating audio from prompt with {c_name} ;)")
210
- tts.tts_to_file(text=limited_prompt,
211
  file_path="output.wav",
212
  voice_dir="examples/library/",
213
  speaker=f"{c_name}")
 
165
 
166
  # Split the text into sentences based on common punctuation marks
167
  sentences = re.split(r'(?<=[.!?])\s+', prompt)
168
+
169
+ if len(sentences) > MAX_NUMBER_SENTENCES:
170
+ gr.Info("Your text is too long. To keep this demo enjoyable for everyone, we only kept the first 10 sentences :) Duplicate this space and set MAX_NUMBER_SENTENCES for longer texts ;)")
171
+ # Keep only the first MAX_NUMBER_SENTENCES sentences
172
+ first_nb_sentences = sentences[:MAX_NUMBER_SENTENCES]
173
 
174
+ # Join the selected sentences back into a single string
175
+ limited_prompt = ' '.join(first_nb_sentences)
176
+ prompt = limited_prompt
177
+
178
+ else:
179
+ prompt = prompt
180
 
181
  gr.Info("Generating audio from prompt")
182
+ tts.tts_to_file(text=prompt,
183
  file_path="output.wav",
184
  voice_dir="bark_voices/",
185
  speaker=f"{file_name}")
 
206
  # Split the text into sentences based on common punctuation marks
207
  sentences = re.split(r'(?<=[.!?])\s+', prompt)
208
 
209
+ if len(sentences) > MAX_NUMBER_SENTENCES:
210
+ gr.Info("Your text is too long. To keep this demo enjoyable for everyone, we only kept the first 10 sentences :) Duplicate this space and set MAX_NUMBER_SENTENCES for longer texts ;)")
211
+ # Keep only the first MAX_NUMBER_SENTENCES sentences
212
+ first_nb_sentences = sentences[:MAX_NUMBER_SENTENCES]
213
 
214
+ # Join the selected sentences back into a single string
215
+ limited_prompt = ' '.join(first_nb_sentences)
216
+ prompt = limited_prompt
217
+
218
+ else:
219
+ prompt = promptrating audio from prompt with {c_name} ;)")
220
 
221
+ tts.tts_to_file(text=prompt,
 
222
  file_path="output.wav",
223
  voice_dir="examples/library/",
224
  speaker=f"{c_name}")