Dataset Viewer issue: How to create preview-able Audio dataset directly from parquet?

#1
by Lauler - opened

Hi!

I am having issues creating an audio dataset with a functioning audio column preview when uploading a dataset directly as parquet.

Some background on how my dataset was created:

  • My source audio files aren't stored as individual files that have a one-to-one mapping to the observations/rows of this dataset. Most of the audio dataset guides on your website assume everyone always creates observations from individual files using the datasets library and the Audio() feature class.
  • In my case I have metadata of the "start" and "end" location of where ground truth was uttered within audio files, and have manually created parquet files (without using datasets) where the audio array data (16khz, mono wav) was sliced from the larger source file and inserted into an audio column.
  • This process works well to create a dataset that I can load with the datasets library, but it doesn't produce a functioning audio preview when I upload it to Huggingface.

My question is:

  • What is the correct way of formatting my audio column in the expected Audio() features format (preferably without using the datasets library) in order to get a functioning preview when saving audio array data directly as parquet? I have looked at the Audio dataclass source code to figure out what is expected, but I'm not understanding it.

I have tried both uploading the array data directly in an audiocolumn, and also uploading it in the type of dictionary format that comes out of using Audio() (also in a column named audio):

{'array': array([ 0.00201416, -0.00076294,  0.00039673, ...,  0.00714111,
        0.00628662,  0.0039978 ], dtype=float32), 'path': None, 'sampling_rate': 16000}

The array is a numpy array.

  • Do I need a pa.StructArray?
  • Do I always need a path?

As a point of feedback to you guys working on HF datasets: I wish at least one of your guides for creating audio datasets would be more framework agnostic and just explain the expected final format (for storing audio in a column that conforms to the dataset viewer's expectations).

cc @albertvillanova @lhoestq @severo .

Sign up or log in to comment