audioread icon indicating copy to clipboard operation
audioread copied to clipboard

added format check for method read_data in rawread

Open Charliechen1 opened this issue 7 years ago • 5 comments

The python audioop.lin2lin will complain if the length of data can not be divided by old_width, and it's not that convenient to check the length of the audio before using the model, especially when a large batches of audio files are used in some machine learning tasks. Therefore, I have made some patch for the input audio data if the length is not to the satisfaction. Thank you for taking my suggestion into consideration, and the project is truly intensive for me. :+1:

Charliechen1 avatar Jul 11 '18 07:07 Charliechen1

Here for your reference: I print the data and get: b'\xff\xff\xff\xff\xfe\xff\xfc\xff\xfc\xff\xfc' And I figured out that it's due to a broken download. Therefore, would it be better to raise a warning under this circumstance?

Charliechen1 avatar Jul 12 '18 03:07 Charliechen1

Hmm; perhaps! But on the other hand, another reasonable (silent) fix might be to round down instead of up—that is, to drop the last (partial) sample if it exists. Would that make sense to you?

sampsyo avatar Jul 12 '18 13:07 sampsyo

It should works.

Charliechen1 avatar Jul 13 '18 04:07 Charliechen1

OK, great! Want to give it a try and see if it works on the file you have?

sampsyo avatar Jul 13 '18 12:07 sampsyo

Sure~

Charliechen1 avatar Jul 16 '18 09:07 Charliechen1