Mridul21 commited on
Commit
62aef5e
1 Parent(s): 240a3b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -53,18 +53,18 @@ else:
53
  reset = True
54
 
55
  if audio_file is not None:
56
- # Save the uploaded audio file to a temporary file
57
  with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
58
  tmp_file.write(audio_file.getvalue())
59
- # tmp_file.write(audio_file.read())
60
  tmp_file_name = tmp_file.name
61
 
62
- # audio_file.seek(0) # Seek to the beginning of the file
63
  tmp_file.close()
64
- # print(audio_file)
65
  plt.figure(figsize = (14,5))
66
  data, sample_rate = librosa.load(tmp_file_name,sr=16000)
67
- # Plot the waveform
68
  plt.figure(figsize=(10, 4))
69
  librosa.display.waveshow(data, sr=16000)
70
  plt.title("Waveform")
@@ -72,7 +72,7 @@ if audio_file is not None:
72
  plt.ylabel("Amplitude")
73
  plt.tight_layout()
74
 
75
- # Display the plot in Streamlit
76
  st.audio(data, format="audio/wav", sample_rate=sample_rate)
77
  st.caption("Raw Audio Waveform")
78
  st.pyplot(plt)
@@ -90,12 +90,11 @@ if audio_file is not None:
90
 
91
  sampling_rate = 16000
92
  wav = read_audio(audio_file, sampling_rate=sampling_rate) #type(wav) = <class 'torch.Tensor'>
93
- # print(wav)
94
  speech_timestamps = get_speech_timestamps(wav, model, sampling_rate=sampling_rate)
95
- # pprint(speech_timestamps)
96
 
97
  plt.figure(figsize = (14,5))
98
- # data,sample_rate = librosa.load(local_audio_file_path, sr=sampling_rate)
99
  librosa.display.waveshow(np.array(wav), sr = sampling_rate)
100
  if len(speech_timestamps) != 0:
101
  plt.title("Detected Speech Segments")
 
53
  reset = True
54
 
55
  if audio_file is not None:
56
+
57
  with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
58
  tmp_file.write(audio_file.getvalue())
59
+
60
  tmp_file_name = tmp_file.name
61
 
62
+
63
  tmp_file.close()
64
+
65
  plt.figure(figsize = (14,5))
66
  data, sample_rate = librosa.load(tmp_file_name,sr=16000)
67
+
68
  plt.figure(figsize=(10, 4))
69
  librosa.display.waveshow(data, sr=16000)
70
  plt.title("Waveform")
 
72
  plt.ylabel("Amplitude")
73
  plt.tight_layout()
74
 
75
+
76
  st.audio(data, format="audio/wav", sample_rate=sample_rate)
77
  st.caption("Raw Audio Waveform")
78
  st.pyplot(plt)
 
90
 
91
  sampling_rate = 16000
92
  wav = read_audio(audio_file, sampling_rate=sampling_rate) #type(wav) = <class 'torch.Tensor'>
93
+
94
  speech_timestamps = get_speech_timestamps(wav, model, sampling_rate=sampling_rate)
 
95
 
96
  plt.figure(figsize = (14,5))
97
+
98
  librosa.display.waveshow(np.array(wav), sr = sampling_rate)
99
  if len(speech_timestamps) != 0:
100
  plt.title("Detected Speech Segments")