TroglodyteDerivations commited on
Commit
24cbc7d
·
verified ·
1 Parent(s): 338ef81

Updated with: [removal] of display_segment

Browse files
Files changed (1) hide show
  1. app.py +1 -27
app.py CHANGED
@@ -336,33 +336,7 @@ def plot_alignments(trellis, segments, word_segments, waveform=np.random.randn(1
336
  #plot_alignments(trellis, segments, word_segments, waveform, sample_rate)
337
  st.pyplot(plot_alignments(trellis, segments, word_segments, waveform=np.random.randn(1024), sample_rate=16000))
338
 
339
- # Part N: Display Segment
340
- sample_rate = 16000
341
-
342
- def display_segment(i):
343
- word = word_segments[i]
344
- x0 = int(word.start * sample_rate)
345
- x1 = int(word.end * sample_rate)
346
- print(f"{word.label} ({word.score:.2f}): {x0 / sample_rate:.3f} - {x1 / sample_rate:.3f} sec")
347
- segment = waveform[x0:x1]
348
- # Ensure the segment is a 1D array
349
- segment = segment.squeeze()
350
- return segment.numpy() # Return the audio data as a numpy array
351
-
352
- # Display the full audio file
353
- st.audio(waveform.numpy(), format="audio/wav", sample_rate=sample_rate)
354
-
355
- # Display the audio for each segment
356
- for i in range(len(word_segments)):
357
- segment_audio = display_segment(i)
358
- # Ensure the segment_audio is a 1D array before passing to st.audio
359
- if segment_audio.ndim == 2:
360
- segment_audio = segment_audio.squeeze()
361
- st.audio(segment_audio.astype('float32'), format="audio/wav", sample_rate=sample_rate)
362
-
363
- st.write(display_segment(3))
364
-
365
- # Part O: Audio generation for each segment
366
  st.write('Abby Cadabby Transcript:')
367
  # Display the audio in the Streamlit app
368
  st.audio(SPEECH_FILE, format="audio/wav")
 
336
  #plot_alignments(trellis, segments, word_segments, waveform, sample_rate)
337
  st.pyplot(plot_alignments(trellis, segments, word_segments, waveform=np.random.randn(1024), sample_rate=16000))
338
 
339
+ # Part N: Audio generation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
  st.write('Abby Cadabby Transcript:')
341
  # Display the audio in the Streamlit app
342
  st.audio(SPEECH_FILE, format="audio/wav")