audio_input = gr.Audio(sources=["microphone","upload"], type="filepath", max_length=60, label="語音輸入")
Browse files14 unmodified lines15161718192019 unmodified lines404142434445464748495051525354555657585960616263646566676814 unmodified lines"""Call the ELSA 'score_audio_plus' endpoint with the provided audio file."""verify_password(password)url = "https://api.elsanow.io/api/v1/score_audio_plus"headers = {19 unmodified lines# Error handlingreturn f"Error: {response.status_code} - {response.text}"with gr.Blocks() as blocks:with gr.Row():password = gr.Textbox(label="Password", type="password")with gr.Row():input_audio = gr.Audio(sources=["microphone"],waveform_options=gr.WaveformOptions(waveform_color="#01C6FF",waveform_progress_color="#0066B4",skip_length=2,show_controls=False,),)api_plan = gr.Dropdown(choices=["basic", "premium"], label="API Plan")return_json = gr.Checkbox(label="Return JSON", value=True)submit_button = gr.Button("Score Audio")output_text = gr.Textbox(label="API Response")submit_button.click(fn=score_audio_plus,inputs=[password, input_audio, api_plan, return_json],outputs=output_text)# Launch the interface in blocking modeblocks.launch()14 unmodified lines15161718192021222319 unmodified lines4344454647484950515253545556575859606162636414 unmodified lines"""Call the ELSA 'score_audio_plus' endpoint with the provided audio file."""if not audio:return "No audio file provided. Please upload an audio file."verify_password(password)url = "https://api.elsanow.io/api/v1/score_audio_plus"headers = {19 unmodified lines# Error handlingreturn f"Error: {response.status_code} - {response.text}"with gr.Blocks() as demo:with gr.Row():password_input = gr.Textbox(label="Password", type="password")with gr.Row():audio_input = gr.Audio(sources=["microphone","upload"], type="filepath", max_length=60, label="語音輸入")api_plan_input = gr.Dropdown(choices=["basic", "premium"], label="API Plan")return_json_input = gr.Checkbox(label="Return JSON", value=True)submit_button = gr.Button("Score Audio")output_text = gr.Textbox(label="API Response")submit_button.click(fn=score_audio_plus,inputs=[password_input, audio_input, api_plan_input, return_json_input],outputs=output_text)# Launch the interfacedemo.launch()
app.py+12-16