youngtsai commited on
Commit
dfa7ea3
·
1 Parent(s): e65bc22

input_audio = gr.Audio(

Browse files
Files changed (1) hide show
  1. app.py +23 -14
app.py CHANGED
@@ -32,18 +32,27 @@ def score_audio_plus(audio, api_plan, return_json):
32
  # Error handling
33
  return f"Error: {response.status_code} - {response.text}"
34
 
35
- # Gradio interface setup
36
- iface = gr.Interface(
37
- fn=score_audio_plus,
38
- inputs=[
39
- gr.Audio(label="Upload your audio file", type="file", tool="microphone"),
40
- gr.Dropdown(choices=["basic", "premium"], label="API Plan"),
41
- gr.Checkbox(label="Return JSON", value=True)
42
- ],
43
- outputs="text",
44
- title="Score Audio Plus API",
45
- description="Upload your audio file and choose settings to score the audio."
46
- )
 
 
 
 
 
 
 
 
 
47
 
48
- # Launch the interface
49
- iface.launch()
 
32
  # Error handling
33
  return f"Error: {response.status_code} - {response.text}"
34
 
35
+ with gr.Blocks() as blocks:
36
+ with gr.Row():
37
+ input_audio = gr.Audio(
38
+ sources=["microphone"],
39
+ waveform_options=gr.WaveformOptions(
40
+ waveform_color="#01C6FF",
41
+ waveform_progress_color="#0066B4",
42
+ skip_length=2,
43
+ show_controls=False,
44
+ ),
45
+ )
46
+ api_plan = gr.Dropdown(choices=["basic", "premium"], label="API Plan")
47
+ return_json = gr.Checkbox(label="Return JSON", value=True)
48
+ submit_button = gr.Button("Score Audio")
49
+ output_text = gr.Textbox(label="API Response")
50
+
51
+ submit_button.click(
52
+ fn=score_audio_plus,
53
+ inputs=[input_audio, api_plan, return_json],
54
+ outputs=output_text
55
+ )
56
 
57
+ # Launch the interface in blocking mode
58
+ blocks.launch()