Support for streaming

#2
by bjelkenhed - opened

Hi, this is a great dataset and it will really improve Swedish ASR models!

Do you have any plans for supporting a streaming dataset to avoid having to download the entire dataset before using it like described here:
https://huggingface.co/docs/datasets/stream

I would be willing to contribute to that in that case.

Also as the audiofiles are in uncompressed wav format it takes a long time to download, have you considered using any other audio format such as mp4?

Thank you very much for this dataset!

National Library of Sweden / KBLab org
β€’
edited Mar 8, 2023

I think streaming should already work. It worked in the latest commit from a couple of hours ago, so if you haven't tried it in a while, try again and report back if you still have trouble. Here's an example that works for me:

dataset = load_dataset("KBLab/rixvox", cache_dir="data_rixvox", streaming=True)
dataset_valid = dataset["validation"].take(5)

for example in dataset_valid:
    print(example)

Regarding the format. Originally the files were 48 kbps mp3. But the mp3 format caused a lot of headaches, as a lot of libraries are using the soundfile library as a dependency to read audio. And it doesn't have support for mp3. Furthermore, pydub, that was the alternative when preprocessing the debate files, didn't play nicely with very long and big mp3-files, making it impossible to read in debates lasting ~6 hours or more.

https://github.com/bastibe/python-soundfile/issues/162
https://github.com/libsndfile/libsndfile/issues/258

For this reason I converted everything to wav 16 kHz mono. It's well supported by everything. I didn't consider mp4 as an option because I wasn't really aware whether it was a well supported option. If it is a format that can be read by e.g. torchaudio, soundfile, etc, then I'll consider uploading everything in mp4 format as well.

National Library of Sweden / KBLab org
β€’
edited Mar 8, 2023

Actually, looking at those Github issues it seems they fixed have added mp3 support for libsndfile. Maybe my installation of torchaudio was just old, or its depency remained on an old version of soundfile.

@bjelkenhed is mp4 the best format in your opinion?

Great, streaming is working fine now. I have primarily used mp4 it found it to work fine even with longer files up to several hours, but I recall some problems with really large audiofiles. I have used it with pydub as well, but mp3 might be just as good.

Thank you again for this dataset, it is a huge leap forward for Swedish ASR models.

Sign up or log in to comment