Update app.py
Browse files
app.py
CHANGED
@@ -53,18 +53,18 @@ else:
|
|
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,7 +72,7 @@ if audio_file is not None:
|
|
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,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 |
-
|
94 |
speech_timestamps = get_speech_timestamps(wav, model, sampling_rate=sampling_rate)
|
95 |
-
# pprint(speech_timestamps)
|
96 |
|
97 |
plt.figure(figsize = (14,5))
|
98 |
-
|
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")
|