Spaces:
Running
Running
Luis
commited on
Commit
·
0bce4f4
1
Parent(s):
f8c5754
add audio_uri2
Browse files
app.py
CHANGED
@@ -75,7 +75,7 @@ description = "An audio event classifier trained on the AudioSet dataset to pred
|
|
75 |
|
76 |
demo = gr.Interface(
|
77 |
predict_uri,
|
78 |
-
inputs=gr.inputs.Audio(type="filepath"),
|
79 |
outputs=['image', 'image', 'image', 'text', 'text', 'text', 'text'],
|
80 |
# examples=examples,
|
81 |
title=title,
|
|
|
75 |
|
76 |
demo = gr.Interface(
|
77 |
predict_uri,
|
78 |
+
inputs=[gr.inputs.Audio(type="filepath"), gr.inputs.Audio(source="microphone", type="filepath")],
|
79 |
outputs=['image', 'image', 'image', 'text', 'text', 'text', 'text'],
|
80 |
# examples=examples,
|
81 |
title=title,
|
test.py
CHANGED
@@ -104,12 +104,11 @@ def split_given_size(arr, size):
|
|
104 |
return np.split(arr, np.arange(size, len(arr), size))
|
105 |
|
106 |
|
107 |
-
def predict_uri(
|
108 |
result = ''
|
109 |
-
|
110 |
-
# result += mp3_uri + '\n'
|
111 |
|
112 |
-
mp3_input =
|
113 |
wav_input = audio_to_wav(mp3_input) if not mp3_input.endswith('.mp3') == True else mp3_input
|
114 |
predict_seconds = int(str(sys.argv[2])) if len(sys.argv) > 2 else 1
|
115 |
|
|
|
104 |
return np.split(arr, np.arange(size, len(arr), size))
|
105 |
|
106 |
|
107 |
+
def predict_uri(audio_uri1, audio_uri2):
|
108 |
result = ''
|
109 |
+
if DEBUG: print('audio_uri1:', audio_uri1, 'audio_uri2:', audio_uri2)
|
|
|
110 |
|
111 |
+
mp3_input = audio_uri1 if audio_uri2 in (None, '') else audio_uri2
|
112 |
wav_input = audio_to_wav(mp3_input) if not mp3_input.endswith('.mp3') == True else mp3_input
|
113 |
predict_seconds = int(str(sys.argv[2])) if len(sys.argv) > 2 else 1
|
114 |
|