mizoru commited on
Commit
45ece48
·
1 Parent(s): b7807f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -13,7 +13,9 @@ learn = load_learner('xresnet50_pitch3.pkl')
13
 
14
  labels = learn.dls.vocab
15
 
16
- def predict(path):
 
 
17
  pred,pred_idx,probs = learn.predict(str(path))
18
 
19
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
@@ -27,8 +29,8 @@ article="<p style='text-align: center'><a href='mizoru.github.io/blog' target='_
27
 
28
  interpretation='default'
29
 
30
- examples = ['代わる.mp3','大丈夫な.mp3','熱くない.mp3']
31
 
32
  enable_queue=True
33
 
34
- gr.Interface(fn=predict,inputs=gr.inputs.Audio(source='microphone', type='filepath'),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples).launch(debug=True,share=True,enable_queue=enable_queue)
 
13
 
14
  labels = learn.dls.vocab
15
 
16
+ def predict(path_mic, path_upload):
17
+ if path_upload: path = path_upload
18
+ else: path = path_mic
19
  pred,pred_idx,probs = learn.predict(str(path))
20
 
21
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
 
29
 
30
  interpretation='default'
31
 
32
+ examples = [['代わる.mp3'],['大丈夫な.mp3'],['熱くない.mp3']]
33
 
34
  enable_queue=True
35
 
36
+ gr.Interface(fn=predict,inputs=[gr.inputs.Audio(source='microphone', type='filepath', optional=True), gr.inputs.Audio(source='upload', type='filepath', optional=True] ,outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples).launch(debug=True,share=True,enable_queue=enable_queue)