-
Notifications
You must be signed in to change notification settings - Fork 3k
Update: add using pcm bytes (#4323) #4409
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
Update: add using pcm bytes (#4323) #4409
Conversation
lhoestq
left a comment
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.
Awesome thanks ! Could you also add tests in tests/features/test_audio.py ?
Maybe add a small pcm file in tests/features/data and check that everything works as expected in tests cases like test_audio_encode_example_pcm and test_audio_decode_example_pcm for example.
|
@lhoestq Maybe I'm missing something, but what's the reason to read and encode PCM files to WAV in |
|
Because the PCM file is not enough, we also need the
|
|
But |
|
How does it get the sampling rate of a PCM file then ? According to SO it's not possible to infer it from the file alone |
Co-authored-by: Quentin Lhoest <[email protected]>
Co-authored-by: Quentin Lhoest <[email protected]>
Co-authored-by: Quentin Lhoest <[email protected]>
@lhoestq how can i test test_audio.py? where is "main" func? |
@mariosasko @lhoestq First of all, "PCM file" can not read alone to any audio library. if you want to read "PCM file" to audio file likely, it have to needs additional parameter. (channel, sampling_rate, else....) and, if we want to use In my source code, I don't compare sampling rate( |
|
There is no "main" function in test scripts :) To run a test script you must use the to run only one function you can also do for example |
|
@lhoestq |
|
You can add your tests in this PR with the other changes you did |
|
@lhoestq AND, some change in my code. audio.py test_audio.py |
|
@lhoestq |
lhoestq
left a comment
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.
Thanks for the tests ! This is awesome :)
I left two comments. Also to fix the CI feel free need to merge the master branch into yours
we can open up soundfile lib Co-authored-by: Quentin Lhoest <[email protected]>
|
@lhoestq |
…ngHyun/datasets into YooSungHyun/features/audio
lhoestq
left a comment
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.
You can ignore the multiprocess error in the CI, this is unrelated to your PR and we're working on it ;)
Thanks a lot for the changes, I spotted one thing that requires a small change: when writing the WAV data, we should use the sampling rate from the input example dictionary (the same that contains "path") - and not the sampling rate from the Audio attribute.
Indeed the sampling rate of the Audio attribute is the expected sampling rate when decoding the example. When we encode it we must specify the sampling rate of the PCM file
self.sampling_rate is for decode. so, we have to get value`s sampling_rate Co-authored-by: Quentin Lhoest <[email protected]>
we have to know sampling_rate in input values variable Co-authored-by: Quentin Lhoest <[email protected]>
Co-authored-by: Quentin Lhoest <[email protected]>
Co-authored-by: Quentin Lhoest <[email protected]>
Co-authored-by: Quentin Lhoest <[email protected]>
Co-authored-by: Quentin Lhoest <[email protected]>
…ngHyun/datasets into YooSungHyun/features/audio
|
@lhoestq thx for comment! and, some comment is not agreed to me, plz check my sub comment! |
lhoestq
left a comment
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.
Thank you ! It looks all good now.
I just removed the scipy import, since we already import soundfile:
|
The documentation is not available anymore as the PR was closed or merged. |
lhoestq
left a comment
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.
Thanks for adding support for PCM :)
Let's merge this one. The CI fails are unrelated to this PR and fixed on main

first of all, please look #4323
why i can not use {"path","array","sampling_rate"}
because sf.write(format="wav") and sf.read(BytesIO) is changed my pcm data value
maybe, i think wav got header but, pcm is not.
and variable naming, pcm data is "byte" type. so, "array" name is not fair i think
so, i use scipy lib and numpy (that is huggingface dependency)
and refer to @lhoestq answered,
that way is not screw up my pcm byte to float data, and another audio type(wav) safety
please check!