Devubiodee commited on
Commit
06fda25
·
verified ·
1 Parent(s): 5585cc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -1,18 +1,23 @@
1
  import gradio as gr
2
 
3
- def greet(audio):
4
- return "Audio received! (length: {} seconds)".format(len(audio) if audio else 0)
 
 
 
5
 
6
  demo = gr.Interface(
7
- fn=greet,
8
  inputs=gr.Audio(
9
  sources=["microphone"],
10
- type="numpy", # or "filepath"
11
- label="Record something",
12
- format="wav"
 
13
  ),
14
  outputs="text",
15
- title="Mic Test"
 
16
  )
17
 
18
- demo.launch()
 
1
  import gradio as gr
2
 
3
+ def test_audio(audio):
4
+ if audio is None:
5
+ return "No audio captured."
6
+ # audio is filepath or numpy array
7
+ return f"Audio received! Length: {len(audio) if isinstance(audio, (list, tuple)) else 'file exists'}"
8
 
9
  demo = gr.Interface(
10
+ fn=test_audio,
11
  inputs=gr.Audio(
12
  sources=["microphone"],
13
+ type="numpy", # or "filepath" — both work
14
+ label="Click to record (mic icon should appear)",
15
+ format="wav",
16
+ interactive=True
17
  ),
18
  outputs="text",
19
+ title="Simple Mic Test – 2026",
20
+ description="Record 5 seconds and speak. If no mic icon/button appears or recording fails, check browser permissions."
21
  )
22
 
23
+ demo.launch(server_name="0.0.0.0", server_port=7860, share=False)