Julien Simon commited on
Commit
515a989
1 Parent(s): e130e80
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -7,16 +7,13 @@ p = pipeline("audio-classification", model=model_name)
7
 
8
  def process(file):
9
  pred = p(file)
10
- labels = dict()
11
- for l in pred:
12
- labels[l['label']]=l['score']
13
- return labels
14
 
15
  # Gradio inputs
16
- mic = gr.inputs.Audio(source='microphone', type='filepath', label='Speech input', optional=True)
17
 
18
  # Gradio outputs
19
- keyword = gr.outputs.Label(num_top_classes=3)
20
 
21
  description = "This Space showcases a wav2vec2-conformer-rel-pos-large model fine-tuned for audio classification on the speech_commands dataset. \n \n It can spot one of the following keywords: 'Yes', 'No', 'Up', 'Down', 'Left', 'Right', 'On', 'Off', 'Stop', 'Go', 'Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Bed', 'Bird', 'Cat', 'Dog', 'Happy', 'House', 'Marvin', 'Sheila', 'Tree', 'Wow', 'Backward', 'Forward', 'Follow', 'Learn', 'Visual'."
22
 
@@ -24,9 +21,8 @@ iface = gr.Interface(
24
  theme='huggingface',
25
  description=description,
26
  fn=process,
27
- layout='horizontal',
28
  inputs=[mic],
29
- outputs=[keyword],
30
  examples=[
31
  ['backward16k.wav'],
32
  ['happy16k.wav'],
@@ -35,6 +31,7 @@ iface = gr.Interface(
35
  ['stop16k.wav'],
36
  ['up16k.wav'],
37
  ],
38
- allow_flagging=False
39
  )
 
40
  iface.launch()
 
7
 
8
  def process(file):
9
  pred = p(file)
10
+ return { x['label']:x['score'] for x in pred}
 
 
 
11
 
12
  # Gradio inputs
13
+ mic = gr.inputs.Audio(source='microphone', type='filepath', label='Speech input')
14
 
15
  # Gradio outputs
16
+ labels = gr.outputs.Label(num_top_classes=3)
17
 
18
  description = "This Space showcases a wav2vec2-conformer-rel-pos-large model fine-tuned for audio classification on the speech_commands dataset. \n \n It can spot one of the following keywords: 'Yes', 'No', 'Up', 'Down', 'Left', 'Right', 'On', 'Off', 'Stop', 'Go', 'Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Bed', 'Bird', 'Cat', 'Dog', 'Happy', 'House', 'Marvin', 'Sheila', 'Tree', 'Wow', 'Backward', 'Forward', 'Follow', 'Learn', 'Visual'."
19
 
 
21
  theme='huggingface',
22
  description=description,
23
  fn=process,
 
24
  inputs=[mic],
25
+ outputs=[labels],
26
  examples=[
27
  ['backward16k.wav'],
28
  ['happy16k.wav'],
 
31
  ['stop16k.wav'],
32
  ['up16k.wav'],
33
  ],
34
+ allow_flagging='never',
35
  )
36
+
37
  iface.launch()