Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adding support for array key in raw dictionnaries in ASR pipeline. #16827

Merged
merged 5 commits into from
Apr 21, 2022

Conversation

Narsil
Copy link
Contributor

@Narsil Narsil commented Apr 19, 2022

What does this PR do?

Adding support for array key in raw dictionnaries in ASR pipeline.
This means we can simplify the Quicktour example to look again a bit
more what the old ffmpeg example looked like.

Even simpler code might be enabled by
huggingface/datasets#4180
in the future. We could then remove the [:4] which is currently necessary to prevent
loading a huge audio in RAM upfront.

Performance-wise the iterator also enables using stuff like batch_size and num_workers in the
pipeline object to get optimal performance (this will only show real differences on GPU which is not
included in this quicktour)

Fixes # (issue)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@patrickvonplaten
@sgugger

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 19, 2022

The documentation is not available anymore as the PR was closed or merged.

@@ -134,8 +134,7 @@ Audio files are automatically loaded and resampled when calling the `"audio"` co
Let's extract the raw waveform arrays of the first 4 samples and pass it as a list to the pipeline:

```py
>>> raw_audio_waveforms = [d["array"] for d in dataset[:4]["audio"]]
>>> speech_recognizer(raw_audio_waveforms)
>>> speech_recognizer(dataset[:4]["audio"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! Could you update the es version as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done !

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

src/transformers/pipelines/automatic_speech_recognition.py Outdated Show resolved Hide resolved
Narsil and others added 3 commits April 19, 2022 14:10
@Narsil Narsil merged commit e789418 into huggingface:main Apr 21, 2022
@Narsil Narsil deleted the improve_asr_quicktour branch April 21, 2022 12:39
Narsil added a commit to Narsil/transformers that referenced this pull request Apr 21, 2022
…uggingface#16827)

* Adding support for `array` key in raw dictionnaries in ASR pipeline.

* ES .

* Update src/transformers/pipelines/automatic_speech_recognition.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Making it work by not popping `array` first.

* Black 22.3

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
…uggingface#16827)

* Adding support for `array` key in raw dictionnaries in ASR pipeline.

* ES .

* Update src/transformers/pipelines/automatic_speech_recognition.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Making it work by not popping `array` first.

* Black 22.3

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants