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

Audio streaming is not working properly #5110

Closed
1 task done
snarb opened this issue Aug 6, 2023 · 1 comment · Fixed by #5077
Closed
1 task done

Audio streaming is not working properly #5110

snarb opened this issue Aug 6, 2023 · 1 comment · Fixed by #5077
Labels
bug Something isn't working

Comments

@snarb
Copy link

snarb commented Aug 6, 2023

Describe the bug

I am having the same goal as i #3299 to make stream audio works. This could be from remote server or from several local wav files (when first is processed second is generated).

I have checked this solution: yield-ing the output audio file to an Audio output component. it is not working properly,

def transcribe(audio)
    flist = ['33056526426.wav', '65074181139.wav']
    for i in range(2):
        if i > 0:
            time.sleep(2)
         yield flist[i]

Not working and hangs UI thread during sleep. With single file works properly.

Example from this one #1775 is also looks like not working properly gradio/demo/stream_audio/run.py. or doesn't looks like supports real time playback, it is not clear how to stream audio when microphone is not triggering add_to_stream, and how to trigger output audio stream update from some background thread that is making processing. It would be so nice to have some working example .

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

def transcribe(audio)
flist = ['33056526426.wav', '65074181139.wav']
for i in range(2):
if i > 0:
time.sleep(2)
yield flist[i]

2)```
import gradio as gr
import numpy as np
import time

def add_to_stream(audio, instream):
    time.sleep(1)
    if audio is None:
        return gr.update(), instream
    if instream is None:
        ret = audio
    else:
        ret = (audio[0], np.concatenate((instream[1], audio[1])))
    return ret, ret


with gr.Blocks() as demo:
    inp = gr.Audio(source="microphone")
    out = gr.Audio()
    stream = gr.State()
    clear = gr.Button("Clear")

    inp.stream(add_to_stream, [inp, stream], [out, stream])
    clear.click(lambda: [None, None, None], None, [inp, out, stream])


if __name__ == "__main__":
    demo.launch()

Screenshot

No response

Logs

No response

System Info

any

Severity

Blocking usage of gradio

@snarb snarb added the bug Something isn't working label Aug 6, 2023
@aliabid94
Copy link
Collaborator

Working on this, will update soon

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

Successfully merging a pull request may close this issue.

2 participants