Added user infos about max number sentences
Browse files
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 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
|
|
|
| 174 |
|
| 175 |
gr.Info("Generating audio from prompt")
|
| 176 |
-
tts.tts_to_file(text=
|
| 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 |
-
|
| 204 |
-
|
|
|
|
|
|
|
| 205 |
|
| 206 |
-
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
|
| 209 |
-
|
| 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}")
|