Skip to content

Commit

Permalink
Fix streaming Audio/Video Output (#9656)
Browse files Browse the repository at this point in the history
* Fix

* add changeset

* lint

* add changeset

* type ignore

---------

Co-authored-by: gradio-pr-bot <[email protected]>
Co-authored-by: Abubakar Abid <[email protected]>
  • Loading branch information
3 people authored Oct 11, 2024
1 parent b1c5a68 commit 8f6626c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-hairs-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": patch
---

feat:Fix streaming Audio/Video Output
4 changes: 1 addition & 3 deletions gradio/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,7 @@ def serve_static_file(
return client_utils.synchronize_async(
processing_utils.async_move_files_to_cache, data, self
)
except (
AttributeError
): # Can be raised if this function is called before the Block is fully initialized.
except AttributeError: # Can be raised if this function is called before the Block is fully initialized.
return data


Expand Down
2 changes: 1 addition & 1 deletion gradio/chat_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def _setup_stop_events(
None,
None,
None,
cancels=events_to_cancel,
cancels=events_to_cancel, # type: ignore
show_api=False,
)

Expand Down
1 change: 1 addition & 0 deletions gradio/components/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ async def stream_output(
"path": output_id,
"is_stream": True,
"orig_name": "audio-stream.mp3",
"meta": {"_type": "gradio.FileData"},
}
if value is None:
return None, output_file
Expand Down
1 change: 1 addition & 0 deletions gradio/components/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ async def stream_output(
# Need to set orig_name so that downloaded file has correct
# extension
"orig_name": "video-stream.mp4",
"meta": {"_type": "gradio.FileData"},
}
}
if value is None:
Expand Down
4 changes: 1 addition & 3 deletions gradio/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,7 @@ def login(form_data: OAuth2PasswordRequestForm = Depends()):
not callable(app.auth)
and username in app.auth
and compare_passwords_securely(password, app.auth[username]) # type: ignore
) or (
callable(app.auth) and app.auth.__call__(username, password)
): # type: ignore
) or (callable(app.auth) and app.auth.__call__(username, password)): # type: ignore
token = secrets.token_urlsafe(16)
app.tokens[token] = username
response = JSONResponse(content={"success": True})
Expand Down

0 comments on commit 8f6626c

Please sign in to comment.