audio_input = gr.Audio(sources=["microphone","upload"], type="filepath", max_length=60, label="語音輸入")
Browse files
app.py
CHANGED
|
@@ -15,6 +15,9 @@ def score_audio_plus(password, audio, api_plan, return_json):
|
|
| 15 |
"""
|
| 16 |
Call the ELSA 'score_audio_plus' endpoint with the provided audio file.
|
| 17 |
"""
|
|
|
|
|
|
|
|
|
|
| 18 |
verify_password(password)
|
| 19 |
url = "https://api.elsanow.io/api/v1/score_audio_plus"
|
| 20 |
headers = {
|
|
@@ -40,29 +43,22 @@ def score_audio_plus(password, audio, api_plan, return_json):
|
|
| 40 |
# Error handling
|
| 41 |
return f"Error: {response.status_code} - {response.text}"
|
| 42 |
|
| 43 |
-
with gr.Blocks() as
|
| 44 |
with gr.Row():
|
| 45 |
-
|
| 46 |
with gr.Row():
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
waveform_color="#01C6FF",
|
| 51 |
-
waveform_progress_color="#0066B4",
|
| 52 |
-
skip_length=2,
|
| 53 |
-
show_controls=False,
|
| 54 |
-
),
|
| 55 |
-
)
|
| 56 |
-
api_plan = gr.Dropdown(choices=["basic", "premium"], label="API Plan")
|
| 57 |
-
return_json = gr.Checkbox(label="Return JSON", value=True)
|
| 58 |
submit_button = gr.Button("Score Audio")
|
| 59 |
output_text = gr.Textbox(label="API Response")
|
| 60 |
|
| 61 |
submit_button.click(
|
| 62 |
fn=score_audio_plus,
|
| 63 |
-
inputs=[
|
| 64 |
outputs=output_text
|
| 65 |
)
|
| 66 |
|
| 67 |
-
# Launch the interface
|
| 68 |
-
|
|
|
|
|
|
| 15 |
"""
|
| 16 |
Call the ELSA 'score_audio_plus' endpoint with the provided audio file.
|
| 17 |
"""
|
| 18 |
+
if not audio:
|
| 19 |
+
return "No audio file provided. Please upload an audio file."
|
| 20 |
+
|
| 21 |
verify_password(password)
|
| 22 |
url = "https://api.elsanow.io/api/v1/score_audio_plus"
|
| 23 |
headers = {
|
|
|
|
| 43 |
# Error handling
|
| 44 |
return f"Error: {response.status_code} - {response.text}"
|
| 45 |
|
| 46 |
+
with gr.Blocks() as demo:
|
| 47 |
with gr.Row():
|
| 48 |
+
password_input = gr.Textbox(label="Password", type="password")
|
| 49 |
with gr.Row():
|
| 50 |
+
audio_input = gr.Audio(sources=["microphone","upload"], type="filepath", max_length=60, label="語音輸入")
|
| 51 |
+
api_plan_input = gr.Dropdown(choices=["basic", "premium"], label="API Plan")
|
| 52 |
+
return_json_input = gr.Checkbox(label="Return JSON", value=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
submit_button = gr.Button("Score Audio")
|
| 54 |
output_text = gr.Textbox(label="API Response")
|
| 55 |
|
| 56 |
submit_button.click(
|
| 57 |
fn=score_audio_plus,
|
| 58 |
+
inputs=[password_input, audio_input, api_plan_input, return_json_input],
|
| 59 |
outputs=output_text
|
| 60 |
)
|
| 61 |
|
| 62 |
+
# Launch the interface
|
| 63 |
+
demo.launch()
|
| 64 |
+
|