Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,23 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
demo = gr.Interface(
|
| 7 |
-
fn=
|
| 8 |
inputs=gr.Audio(
|
| 9 |
sources=["microphone"],
|
| 10 |
-
type="numpy",
|
| 11 |
-
label="
|
| 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)
|