-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Fix live interfaces for audio/image streaming #9883
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-pypi-previews.s3.amazonaws.com/39a62ff596773c2aff535add0e24df3562d8f7a7/gradio-5.4.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@39a62ff596773c2aff535add0e24df3562d8f7a7#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-npm-previews.s3.amazonaws.com/39a62ff596773c2aff535add0e24df3562d8f7a7/gradio-client-1.7.1.tgz Use Lite from this PR <script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/39a62ff596773c2aff535add0e24df3562d8f7a7/dist/lite.js""></script> |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
@@ -201,7 +201,7 @@ | |||
dispatch("start_recording"); | |||
if (!inited) await prepare_audio(); | |||
header = undefined; | |||
if (streaming) { | |||
if (streaming && recorder.state != "recording") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes this would get triggered twice and there would be an exception in the console since the recorder was already recording. But it wouldn't break anything.
gradio/queueing.py
Outdated
@@ -679,7 +681,11 @@ async def process_events( | |||
if awake_events[0].streaming: | |||
awake_events, closed_events = await Queue.wait_for_batch( | |||
awake_events, | |||
[cast(float, fn.time_limit) - first_iteration] | |||
# We need to wait for all of the events to have the latest input data | |||
# the max time is the time limit of the function or 90 seconds (arbitrary) but should |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# the max time is the time limit of the function or 90 seconds (arbitrary) but should | |
# the max time is the time limit of the function or 30 seconds (arbitrary) but should |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
@@ -702,7 +708,9 @@ def attach_submit_events( | |||
preprocess=not (self.api_mode), | |||
postprocess=not (self.api_mode), | |||
show_progress="hidden" if streaming_event else self.show_progress, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor point unrelated to this PR, but I think we should just make show_progress="hidden" if live=True
[ | ||
d["name"] | ||
for d in _event_specific_args | ||
if d.get("component_prop", "true") != "false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this component_prop
attribute mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether or not to pass this arguments (stream_every
or time_limit
) it to svelte component in the front-end. Only stream_every
is used in the component code. time_limit
is used by statustracker.
Looks good to me @freddyaboulton! With regards to #9837, can we print a warning if someone uses a streaming input and does not set |
Description
When an interface is
live
, the events are configured viagr.on
and there are some modifications needed for the stream events to be set up correctly if the input components are set tostreaming=True
.Also added
time_limit
andstream_every
to the interface class for users to control the stream event behavior.Closes: #9837
Closes: #9869
🎯 PRs Should Target Issues
Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.
Not adhering to this guideline will result in the PR being closed.
Tests
PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests:
bash scripts/run_all_tests.sh
You may need to run the linters:
bash scripts/format_backend.sh
andbash scripts/format_frontend.sh