czyoung commited on
Commit
14a443b
·
verified ·
1 Parent(s): 8dd318d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -68,9 +68,7 @@ def processFile(filePath):
68
  print("Detecting speakers")
69
  annotations = pipeline({"waveform": waveformEnhanced, "sample_rate": sampleRate})
70
  print("Speakers Detected")
71
- speakerList = su.annotationToSpeakerList(annotations)
72
- print("Speakers split into list")
73
- return (speakerList, annotations, int(waveformEnhanced.shape[-1]/sampleRate))
74
 
75
  def addCategory():
76
  newCategory = st.session_state.categoryInput
@@ -128,7 +126,7 @@ def analyze(inFileName):
128
  print(f"Found at index {currFileIndex}")
129
  if len(st.session_state.results) > currFileIndex and len(st.session_state.summaries) > currFileIndex and len(st.session_state.results[currFileIndex]) > 0:
130
  # Handle
131
- currSpeakerList, currAnnotation, currTotalTime = st.session_state.results[currFileIndex]
132
  speakerNames = currAnnotation.labels()
133
 
134
  # Update other categories
@@ -363,7 +361,7 @@ else:
363
  start_time = time.time()
364
  totalFiles = len(valid_files)
365
  for i in range(totalFiles):
366
- if len(st.session_state.results) > i and len(st.session_state.results[i]) > 0 and st.session_state.results[i][0] == file_names[i]:
367
  continue
368
  # Text files use sample data
369
  if file_paths[i].endswith('.txt'):
@@ -376,16 +374,16 @@ else:
376
  for segment in annotations.itersegments():
377
  if segment.end > totalSeconds:
378
  totalSeconds = segment.end
379
- st.session_state.results[i] = (speakerList,annotations, totalSeconds)
380
  st.session_state.summaries[i] = {}
381
  speakerNames = annotations.labels()
382
  st.session_state.unusedSpeakers[i] = speakerNames
383
  else:
384
  #st.info(file_paths[i])
385
  with st.spinner(text=f'Processing File {i+1} of {totalFiles}'):
386
- speakerList, annotations, totalSeconds = processFile(file_paths[i])
387
  print(f"Finished processing {file_paths[i]}")
388
- st.session_state.results[i] = (speakerList,annotations, totalSeconds)
389
  print("Results saved")
390
  st.session_state.summaries[i] = {}
391
  print("Summaries saved")
@@ -405,7 +403,7 @@ try:
405
  currFileIndex = file_names.index(currFile)
406
  if len(st.session_state.results) > currFileIndex and len(st.session_state.summaries) > currFileIndex and len(st.session_state.results[currFileIndex]) > 0:
407
  # Handle
408
- currSpeakerList, currAnnotation, currTotalTime = st.session_state.results[currFileIndex]
409
  speakerNames = currAnnotation.labels()
410
  # Update other categories
411
  unusedSpeakers = st.session_state.unusedSpeakers[currFileIndex]
@@ -570,7 +568,7 @@ if len(st.session_state.results) > 0:
570
  }
571
  allCategories = copy.deepcopy(st.session_state.categories)
572
  for i in indices:
573
- currSpeakerList, currAnnotation, currTotalTime = st.session_state.results[i]
574
  categorySelections = st.session_state["categorySelect"][i]
575
  catSummary,extraCats = su.calcCategories(currAnnotation,categorySelections)
576
  st.session_state.summaries[i]["categories"] = (catSummary,extraCats)
 
68
  print("Detecting speakers")
69
  annotations = pipeline({"waveform": waveformEnhanced, "sample_rate": sampleRate})
70
  print("Speakers Detected")
71
+ return (annotations, int(waveformEnhanced.shape[-1]/sampleRate))
 
 
72
 
73
  def addCategory():
74
  newCategory = st.session_state.categoryInput
 
126
  print(f"Found at index {currFileIndex}")
127
  if len(st.session_state.results) > currFileIndex and len(st.session_state.summaries) > currFileIndex and len(st.session_state.results[currFileIndex]) > 0:
128
  # Handle
129
+ currAnnotation, currTotalTime = st.session_state.results[currFileIndex]
130
  speakerNames = currAnnotation.labels()
131
 
132
  # Update other categories
 
361
  start_time = time.time()
362
  totalFiles = len(valid_files)
363
  for i in range(totalFiles):
364
+ if len(st.session_state.results) > i and len(st.session_state.results[i]) > 0:
365
  continue
366
  # Text files use sample data
367
  if file_paths[i].endswith('.txt'):
 
374
  for segment in annotations.itersegments():
375
  if segment.end > totalSeconds:
376
  totalSeconds = segment.end
377
+ st.session_state.results[i] = (annotations, totalSeconds)
378
  st.session_state.summaries[i] = {}
379
  speakerNames = annotations.labels()
380
  st.session_state.unusedSpeakers[i] = speakerNames
381
  else:
382
  #st.info(file_paths[i])
383
  with st.spinner(text=f'Processing File {i+1} of {totalFiles}'):
384
+ annotations, totalSeconds = processFile(file_paths[i])
385
  print(f"Finished processing {file_paths[i]}")
386
+ st.session_state.results[i] = (annotations, totalSeconds)
387
  print("Results saved")
388
  st.session_state.summaries[i] = {}
389
  print("Summaries saved")
 
403
  currFileIndex = file_names.index(currFile)
404
  if len(st.session_state.results) > currFileIndex and len(st.session_state.summaries) > currFileIndex and len(st.session_state.results[currFileIndex]) > 0:
405
  # Handle
406
+ currAnnotation, currTotalTime = st.session_state.results[currFileIndex]
407
  speakerNames = currAnnotation.labels()
408
  # Update other categories
409
  unusedSpeakers = st.session_state.unusedSpeakers[currFileIndex]
 
568
  }
569
  allCategories = copy.deepcopy(st.session_state.categories)
570
  for i in indices:
571
+ currAnnotation, currTotalTime = st.session_state.results[i]
572
  categorySelections = st.session_state["categorySelect"][i]
573
  catSummary,extraCats = su.calcCategories(currAnnotation,categorySelections)
574
  st.session_state.summaries[i]["categories"] = (catSummary,extraCats)