yasserrmd commited on
Commit
22cf94f
·
verified ·
1 Parent(s): a623156

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
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")