Spaces:
Runtime error
Runtime error
try a fix
Browse files
app.py
CHANGED
@@ -17,16 +17,19 @@ learn_plain = load_learner('xresnet50_pitch3.pkl')
|
|
17 |
|
18 |
labels = learn_removeSilence.dls.vocab
|
19 |
|
20 |
-
def process(Record, Upload, version):
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
|
26 |
-
def predict(Record, Upload,
|
27 |
if Upload: path = Upload
|
28 |
else: path = Record
|
29 |
-
|
|
|
|
|
|
|
30 |
fig,ax = plt.subplots(figsize=(16,10))
|
31 |
show_image(spec, ax=ax)
|
32 |
ax.invert_yaxis()
|
@@ -43,7 +46,7 @@ examples = [['代わる.mp3'],['大丈夫な.mp3'],['熱くない.mp3'], ['あ
|
|
43 |
|
44 |
enable_queue=True
|
45 |
|
46 |
-
gr.Interface(fn=
|
47 |
inputs=[gr.inputs.Audio(source='microphone', type='filepath', optional=True),
|
48 |
gr.inputs.Audio(source='upload', type='filepath', optional=True),
|
49 |
gr.inputs.Radio(choices=['plain','remove silence'], type="value", default='remove silence', label='version')
|
|
|
17 |
|
18 |
labels = learn_removeSilence.dls.vocab
|
19 |
|
20 |
+
#def process(Record, Upload, version):
|
21 |
+
# if version == 'remove silence':
|
22 |
+
# return predict(Record, Upload, learn_removeSilence)
|
23 |
+
# elif version == 'plain':
|
24 |
+
# return predict(Record, Upload, learn_plain)
|
25 |
|
26 |
+
def predict(Record, Upload, version):
|
27 |
if Upload: path = Upload
|
28 |
else: path = Record
|
29 |
+
if version == 'remove silence':
|
30 |
+
spec,pred,pred_idx,probs = learn_removeSilence.predict(str(path), with_input=True)
|
31 |
+
elif version == 'plain':
|
32 |
+
spec,pred,pred_idx,probs = learn_plain.predict(str(path), with_input=True)
|
33 |
fig,ax = plt.subplots(figsize=(16,10))
|
34 |
show_image(spec, ax=ax)
|
35 |
ax.invert_yaxis()
|
|
|
46 |
|
47 |
enable_queue=True
|
48 |
|
49 |
+
gr.Interface(fn=predict,
|
50 |
inputs=[gr.inputs.Audio(source='microphone', type='filepath', optional=True),
|
51 |
gr.inputs.Audio(source='upload', type='filepath', optional=True),
|
52 |
gr.inputs.Radio(choices=['plain','remove silence'], type="value", default='remove silence', label='version')
|