KEMBAR78
Fix some doc examples in task summary by ydshieh · Pull Request #16666 · huggingface/transformers · GitHub
Skip to content

Conversation

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Apr 8, 2022

What does this PR do?

Fix some doctest CI failure found here

A few failures:

  • Expected nothing
    Got:
        '_unknown_'
    
  • Expected nothing
    Got:
        'MISTER QUILTER IS THE APOSTLE OF THE MIDDLE CLASSES AND WE ARE GLAD TO WELCOME HIS GOSPEL'
    
  • Expected:
        <pad> prosecutors say the marriages were part of an immigration scam. if convicted, barrientos faces two criminal
        counts of "offering a false instrument for filing in the first degree" she has been married 10 times, nine of them
        between 1999 and 2002.
    Got:
        <pad> prosecutors say the marriages were part of an immigration scam. if convicted, barrientos faces two criminal counts of "offering a false instrument for filing in the first degree" she has been married 10 times, nine of them between 1999 and 2002.</s><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad>
    

There is one error I haven't fixed yet

No such file or directory: 'jfk_moon_speech.wav'

Do you know where to get this file for testing purpose ..?

@ydshieh ydshieh requested review from sgugger and stevhliu April 8, 2022 14:38
@ydshieh ydshieh changed the title Fix audio doc example in task summary Fix some doc examples in task summary Apr 8, 2022
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 8, 2022

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

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.

LGTM! For the audio file, @stevhliu might know where it is.

Copy link
Member

@stevhliu stevhliu 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 these!

The jfk_moon_speech.wav is a local file I used to test some code examples, so maybe we can replace it with an audio example from the Hub?

@ydshieh
Copy link
Collaborator Author

ydshieh commented Apr 8, 2022

Thanks for fixing these!

The jfk_moon_speech.wav is a local file I used to test some code examples, so maybe we can replace it with an audio example from the Hub?

Sure! Let me try. Haven't tried audio dataset from the Hub.

@ydshieh
Copy link
Collaborator Author

ydshieh commented Apr 8, 2022

@sgugger @stevhliu I was able to use a file from dataset.

One example of change is

>>> from transformers import pipeline
>>> from datasets import load_dataset
>>> import torch

>>> torch.manual_seed(42)  # doctest: +IGNORE_RESULT

>>> dataset = load_dataset("hf-internal-testing/librispeech_asr_demo", "clean", split="validation")
>>> dataset = dataset.sort("id")
>>> audio_file = dataset[0]["audio"]["path"]

>>> audio_classifier = pipeline(
...     task="audio-classification", model="ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition"
... )
>>> predictions = audio_classifier(audio_file)
>>> predictions = [{"score": round(pred["score"], 4), "label": pred["label"]} for pred in predictions]
>>> predictions
[{'score': 0.1315, 'label': 'calm'}, {'score': 0.1307, 'label': 'neutral'}, {'score': 0.1274, 'label': 'sad'}, {'score': 0.1261, 'label': 'fearful'}, {'score': 0.1242, 'label': 'happy'}]

I ran the tests, and task_summary.mdx is fine, except the one in #16644 (it is not merged yet).

Let me know if you have further comments :-)

@ydshieh ydshieh merged commit 8e93dc7 into huggingface:main Apr 11, 2022
@ydshieh ydshieh deleted the fix_audio_doc_example_in_task_summary branch April 11, 2022 09:20
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
* Fix some doc examples

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
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.

5 participants