Spaces:
Sleeping
Sleeping
Commit
·
210a1a2
1
Parent(s):
5e740f6
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,26 +39,26 @@ def plot_sound_event_detection_result(framewise_output):
|
|
| 39 |
def pred(audio):
|
| 40 |
rate, y = audio
|
| 41 |
device = 'cpu' # 'cuda' | 'cpu'
|
| 42 |
-
print('sample rate ', rate)
|
| 43 |
-
print('shape ', y.shape)
|
| 44 |
-
print('raw data', y)
|
| 45 |
y = y.astype(np.float32)
|
| 46 |
-
print('float', y)
|
| 47 |
y = librosa.core.to_mono(y.T)
|
| 48 |
-
print('shape ', y.shape)
|
| 49 |
-
print('mono', y)
|
| 50 |
y = librosa.core.resample(y, orig_sr=rate, target_sr=32000)
|
| 51 |
-
print('shape ', y.shape)
|
| 52 |
-
print('resampled', y)
|
| 53 |
-
print(y.mean())
|
| 54 |
-
print(y.std())
|
| 55 |
#y = (y - y.mean())/y.std()
|
| 56 |
y = y/y.max()
|
| 57 |
-
print('normalized', y)
|
| 58 |
#print(rate)
|
| 59 |
-
plt.plot(y)
|
| 60 |
-
plt.savefig('wave.png')
|
| 61 |
-
plt.close()
|
| 62 |
y = y[None, :] # (batch_size, segment_samples)
|
| 63 |
#print(y)
|
| 64 |
|
|
@@ -86,7 +86,6 @@ demo = gr.Interface(
|
|
| 86 |
"telephone_speech.wav",
|
| 87 |
"ringtone.wav", "animals.wav",
|
| 88 |
],
|
| 89 |
-
interpretation="default",
|
| 90 |
)
|
| 91 |
|
| 92 |
demo.launch()
|
|
|
|
| 39 |
def pred(audio):
|
| 40 |
rate, y = audio
|
| 41 |
device = 'cpu' # 'cuda' | 'cpu'
|
| 42 |
+
#print('sample rate ', rate)
|
| 43 |
+
#print('shape ', y.shape)
|
| 44 |
+
#print('raw data', y)
|
| 45 |
y = y.astype(np.float32)
|
| 46 |
+
#print('float', y)
|
| 47 |
y = librosa.core.to_mono(y.T)
|
| 48 |
+
#print('shape ', y.shape)
|
| 49 |
+
#print('mono', y)
|
| 50 |
y = librosa.core.resample(y, orig_sr=rate, target_sr=32000)
|
| 51 |
+
#print('shape ', y.shape)
|
| 52 |
+
#print('resampled', y)
|
| 53 |
+
#print(y.mean())
|
| 54 |
+
#print(y.std())
|
| 55 |
#y = (y - y.mean())/y.std()
|
| 56 |
y = y/y.max()
|
| 57 |
+
#print('normalized', y)
|
| 58 |
#print(rate)
|
| 59 |
+
#plt.plot(y)
|
| 60 |
+
#plt.savefig('wave.png')
|
| 61 |
+
#plt.close()
|
| 62 |
y = y[None, :] # (batch_size, segment_samples)
|
| 63 |
#print(y)
|
| 64 |
|
|
|
|
| 86 |
"telephone_speech.wav",
|
| 87 |
"ringtone.wav", "animals.wav",
|
| 88 |
],
|
|
|
|
| 89 |
)
|
| 90 |
|
| 91 |
demo.launch()
|