Skip to content

Fix preprocessing for audio input pipelines in external.py#2779

Merged
freddyaboulton merged 7 commits into
mainfrom
fix-to-binary-in-model-load
Dec 9, 2022
Merged

Fix preprocessing for audio input pipelines in external.py#2779
freddyaboulton merged 7 commits into
mainfrom
fix-to-binary-in-model-load

Conversation

@freddyaboulton
Copy link
Copy Markdown
Collaborator

Description

As noted by @gary149 on slack, you can't load an automatic speech recognition model on the latest gradio.

Repro here: https://huggingface.co/spaces/freddyaboulton/openai-whisper-large
image

This change fixes that. Local test:

image

Checklist:

  • I have performed a self-review of my own code
  • I have added a short summary of my change to the CHANGELOG.md
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

A note about the CHANGELOG

Hello 👋 and thank you for contributing to Gradio!

All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 8, 2022

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2779-all-demos

def to_binary(x: str | Dict) -> bytes:
"""Converts a base64 string or dictionary to a binary string that can be sent in a POST."""
if isinstance(x, dict):
if isinstance(x, dict) and not x.get("data"):
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be backwards compatible

@abidlabs
Copy link
Copy Markdown
Member

abidlabs commented Dec 8, 2022

Might be good to add a fast test to prevent regressions. Will test out with a few other models

@freddyaboulton
Copy link
Copy Markdown
Collaborator Author

Good point @abidlabs ! Pushed up a test now.

@freddyaboulton freddyaboulton marked this pull request as ready for review December 8, 2022 22:00
@abidlabs
Copy link
Copy Markdown
Member

abidlabs commented Dec 9, 2022

Thanks for the quick fix @freddyaboulton. I just updated a couple of comments that linked to example models, otherwise LGTM!

@freddyaboulton freddyaboulton merged commit 2a773d5 into main Dec 9, 2022
@freddyaboulton freddyaboulton deleted the fix-to-binary-in-model-load branch December 9, 2022 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants