czyoung commited on
Commit
cf16727
·
verified ·
1 Parent(s): 0d22830

Added demo sample

Browse files
Files changed (1) hide show
  1. app.py +36 -1
app.py CHANGED
@@ -501,9 +501,44 @@ with t1:
501
  key='download-txt2',
502
  on_click="ignore",
503
  )'''
504
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
505
  currFile = st.sidebar.selectbox('Current File', file_names,on_change=updateMultiSelect,key="select_currFile")
506
 
 
 
 
 
 
507
  if currFile is None and len(st.session_state.results) > 0 and len(st.session_state.results[0]) > 0:
508
  st.write("Select a file to view from the sidebar")
509
  try:
 
501
  key='download-txt2',
502
  on_click="ignore",
503
  )'''
504
+ class FakeUpload:
505
+ def __init__(self,filepath):
506
+ self.path = filepath
507
+ self.name = filepath.split('/')[-1
508
+ ]
509
+ demoPath = ""
510
+ isDemo = False
511
+ if st.sidebar.button("Load Demo Example"):
512
+ sampleUpload = FakeUpload(demoPath)
513
+ valid_files=[sampleUpload]
514
+ file_paths=[sampleUpload.path]
515
+ file_names=[sampleUpload.name]
516
+ start_time = time.time()
517
+ st.session_state.file_names = file_names
518
+ with st.spinner(text=f'Loading Demo Sample'):
519
+ # RTTM load as filler
520
+ speakerList, annotations = su.loadAudioRTTM(file_paths[0])
521
+ # Approximate total seconds
522
+ totalSeconds = 0
523
+ for segment in annotations.itersegments():
524
+ if segment.end > totalSeconds:
525
+ totalSeconds = segment.end
526
+ st.session_state.results = [(annotations, totalSeconds)]
527
+ st.session_state.summaries = [{}]
528
+ speakerNames = annotations.labels()
529
+ st.session_state.unusedSpeakers = [speakerNames]
530
+ with st.spinner(text=f'Analyzing Demo Data'):
531
+ analyze(file_names[0])
532
+ st.success(f"Took {time.time() - start_time} seconds to analyze {totalFiles} files!")
533
+ isDemo = True
534
+
535
  currFile = st.sidebar.selectbox('Current File', file_names,on_change=updateMultiSelect,key="select_currFile")
536
 
537
+ if isDemo:
538
+ st.session_state.select_currFile=file_names[0]
539
+ currFile=file_names[0]
540
+ isDemo = False
541
+
542
  if currFile is None and len(st.session_state.results) > 0 and len(st.session_state.results[0]) > 0:
543
  st.write("Select a file to view from the sidebar")
544
  try: