Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -230,7 +230,16 @@ class VibeVoiceDemo:
|
|
230 |
return None, error_msg
|
231 |
|
232 |
|
233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
|
235 |
def load_example_scripts(self):
|
236 |
examples_dir = os.path.join(os.path.dirname(__file__), "text_examples")
|
|
|
230 |
return None, error_msg
|
231 |
|
232 |
|
233 |
+
@staticmethod
|
234 |
+
def _infer_num_speakers_from_script(script: str) -> int:
|
235 |
+
"""
|
236 |
+
Infer number of speakers by counting distinct 'Speaker X:' tags in the script.
|
237 |
+
Robust to 0- or 1-indexed labels and repeated turns.
|
238 |
+
Falls back to 1 if none found.
|
239 |
+
"""
|
240 |
+
import re
|
241 |
+
ids = re.findall(r'(?mi)^\s*Speaker\s+(\d+)\s*:', script)
|
242 |
+
return len({int(x) for x in ids}) if ids else 1
|
243 |
|
244 |
def load_example_scripts(self):
|
245 |
examples_dir = os.path.join(os.path.dirname(__file__), "text_examples")
|