You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I met the audio play out high delay problem.However, even I use the #8906 source code to install gradio, the problem not was solved.There is still 3~4s delay and audio playing is not smooth(has some gap, look like lack of audio data).This is my demo code:
import gradio as gr
from pydub import AudioSegment
from time import sleep
import numpy as np
import datetime
audio_list = []
def add_to_stream(audio):
sleep(0.05)
global audio_list
audio_list.append(audio)
with gr.Blocks() as demo:
inp = gr.Audio(sources=["microphone"], streaming=True)
inp.stream(add_to_stream, [inp], [])
stream_as_file_btn = gr.Button("Stream as File")
stream_as_file_output = gr.Audio(streaming=True)
stream_as_file_output.autoplay = True
def stream_file():
global audio_list
while True:
while len(audio_list) == 0:
print('stream out pull data, but no data available now...')
sleep(0.05)
chunk = audio_list[0]
audio_list = audio_list[1:]
print('yield audio chunk, samples: {}, cached audio chunks: {}, at: {}'.format(len(chunk[1]), len(audio_list), datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")))
yield chunk
stream_as_file_btn.click(
stream_file, [], stream_as_file_output
)
if __name__ == "__main__":
demo.launch(server_name='0.0.0.0', server_port=8000)
I figured audio data output speed via log, it's coincident with it's sample rate.
Demo usage:
1.click 'stream_as_file_btn' to start audio data fetching.
2.click 'inp' audio component's recording button to start generating audio data.
After about half an second, you will see 'yield audio chunk...', which means audio data beging outputing.
I met the audio play out high delay problem.However, even I use the #8906 source code to install gradio, the problem not was solved.There is still 3~4s delay and audio playing is not smooth(has some gap, look like lack of audio data).This is my demo code:
I figured audio data output speed via log, it's coincident with it's sample rate.
Demo usage:
1.click 'stream_as_file_btn' to start audio data fetching.
2.click 'inp' audio component's recording button to start generating audio data.
After about half an second, you will see 'yield audio chunk...', which means audio data beging outputing.
Did I miss something?Thanks in advance.
Originally posted by @steven8274 in #8185 (comment)
The text was updated successfully, but these errors were encountered: