Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gr.Audio Unable to record properly #3601

Closed
1 task done
monkeycc opened this issue Mar 24, 2023 · 1 comment
Closed
1 task done

gr.Audio Unable to record properly #3601

monkeycc opened this issue Mar 24, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@monkeycc
Copy link

monkeycc commented Mar 24, 2023

Describe the bug

gr.Audio
Unable to record properly

Ubuntu
nohup python3 1.py > /root/1.log 2>&1

The Ubuntu 22 server:
IP:port
domain name:port
Unable to record properly

xxxxxxxxxxx.gradio.live
Normal access

Local development
Normal access

2023-03-24.09-18-59-897.mp4

Is there an existing issue for this?

  • I have searched the existing issues

Reproduction

import gradio as gr



def greet1(audio):
     print("audio",audio)
     return audio

def greet2(audio):
     print("audio",audio)
     return audio

with gr.Blocks() as demo:

    with gr.Tabs():


        with gr.TabItem("音频对话"):
            with gr.Row():
                inp = gr.Audio(source="microphone", type="filepath", label="点击录音")
            with gr.Column():

                out = [gr.Textbox(label="输入音频"),gr.Textbox(label="AI输出")]

            btn = gr.Button("运行")
            btn.click(fn=greet1, inputs=inp, outputs=out, api_name="greet1")

        with gr.TabItem("文字对话"):
            with gr.Column():
                inp2 = gr.Textbox(label="文字输入")
                out2 = gr.Textbox(label="AI输出")

            btn2 = gr.Button("运行")
     
            btn2.click(fn=greet2, inputs=inp2, outputs=out2, api_name="greet2")


if __name__ == "__main__":
    demo.launch(share=True,server_name="0.0.0.0",server_port=8888,debug=True)   

import os

import numpy as np

import gradio as gr


def reverse_audio(audio):
    sr, data = audio
    return (sr, np.flipud(data))


demo = gr.Interface(fn=reverse_audio, 
                    inputs="microphone", 
                    outputs="audio", 
                    examples=[
                    "https://samplelib.com/lib/preview/mp3/sample-3s.mp3",
                    os.path.join(os.path.dirname(__file__), "audio/recording1.wav")
        ], cache_examples=True)

if __name__ == "__main__":
    demo.launch(share=True,server_name="0.0.0.0",server_port=8888,debug=True)   

Screenshot

No response

Logs

微信截图_20230325105339

System Info

gradio.__version__
3.22.1

win11
Edge 110.0.1587.46

Severity

annoying

@monkeycc monkeycc added the bug Something isn't working label Mar 24, 2023
@abidlabs
Copy link
Member

Hi @monkeycc this is happening because you are in an HTTP environment. Modern browsers do not allow recording audio unless you are on localhost or HTTPS. We should display a better error here though, same issue as #2551

cc @aliabid94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants