This project processes MediBeng audio data and creates Parquet files for uploading to Hugging Face. It uses the following two main scripts:
create_parquet.py: This script is used to create Parquet files from the synthetic Bengali-English code-switched audio data in healthcare settings. π΅upload_to_huggingface.py: This script uploads the Parquet files to Hugging Face, making the MediBeng dataset publicly available for sharing and usage. βοΈ
Explore the MediBeng Dataset : MediBeng Dataset on Hugging Face π€
I followed the steps above to create the MediBeng dataset, which contains audio data along with their transcriptions, and uploaded it to Hugging Face. You can explore the dataset here.
- 1. Cloning the Repository π
- 2. Setting Up the Conda Environment π§
- 3. Installing Dependencies πΎ
- 4. Setting Up Hugging Face Token π
- 5. Configuring the
config.yamlβοΈ - 6. Data Setup π
- 7. Running the Scripts π
- 8. How the Code Works π
- 9. Loading the MediBeng Dataset β¬οΈ
- 10. Summary of Updates π
First, clone the repository to your local machine using the following command:
git clone https://github.com/pr0mila/ParquetToHuggingFace.git
cd ParquetToHuggingFaceCreate a new Conda environment to run the project:
conda create --name audio-parquet python=3.9
conda activate audio-parquetInstall the necessary dependencies by using the requirements.txt file:
pip install -r requirements.txtOr, install the dependencies
pip install pandas soundfile numpy librosa datasetsThis will install all the required libraries and packages to run the project.
You need to set your Hugging Face token as an environment variable to upload data to Hugging Face. Run the following command in your terminal (replace your_token_here with your actual token):
export HUGGINGFACE_TOKEN='your_token_here'You can find your Hugging Face token by visiting Hugging Face - Account Settings.
To ensure the token persists across sessions, you can add the export command to your shell's configuration file (e.g., ~/.bashrc or ~/.zshrc).
The config.yaml file stores the configuration for the paths and Hugging Face repository settings.
Make sure to update the config.yaml according to your local setup. Example:
paths:
base_data_directory: "/path/to/your/raw/data"
output_directory: "/path/to/store/parquet"
huggingface:
repo_id: "your_username/your_dataset_name"
token_env_var: "HUGGINGFACE_TOKEN"base_data_directory: Path to your directory where the raw audio files and CSV files are located (it will be in theraw datadirectory).output_directory: Path to where the Parquet files will be saved (this will be in theprocessed_datadirectory).repo_id: Your Hugging Face repository ID where you want to upload the dataset.
Place your raw audio data and its corresponding CSV file into the raw data directory. The audio files should be in a format that the create_parquet.py script can read (e.g., .wav files).
Your directory structure should look like this:
ParquetToHuggingFace/
βββ data/
β βββ raw_data/
β β βββ test/
β β βββ train/
β βββ processed_data/
βββ config.yaml
βββ src/
βββ create_parquet.py
βββ upload_to_huggingface.py
Before running the scripts, make sure to update the path of your config.yaml file in src/main.py to reflect your local configuration. This will ensure the scripts use the correct settings.
Once the config path is updated, run the main.py file to generate the final output:
python3 src/main.py- The
create_parquet.pyclass processes raw audio data and its corresponding CSV file (which contains transcription and translation). - It calculates pitch statistics (mean and standard deviation) for each audio file.
- The processed data, including audio, transcription, translation, and pitch statistics, is then saved as Parquet files in the
processed_datadirectory.
- The
upload_to_huggingface.pyclass logs you into Hugging Face using the token set in your environment. - It checks whether the repository exists or needs to be created on Hugging Face.
- Finally, it uploads the Parquet files from the
processed_datadirectory to your Hugging Face repository.
Once the scripts are successfully run, your data will be stored on Hugging Face as Parquet files, and you will have the ability to share and use them for various machine learning or research purposes.
This guide demonstrates how to load the "MediBeng" dataset for use in your machine learning or research projects.
First, install the necessary dependencies by running the following command:
pip install datasets[audio]To begin working with the MediBeng dataset, follow these steps to load both the training and test splits.
The code below will load the dataset and allow you to take a quick look at the first three examples from the training split.
from datasets import load_dataset
# Load the dataset with both train and test splits
ds = load_dataset("pr0mila-gh0sh/MediBeng", split=["train", "test"])
# Take the first three examples from the training part
ds_head = ds[0].take(3)-
Processing Parquet files: Added steps to convert and process Parquet files containing audio data.
-
Storing on Hugging Face: Instructions on how to store datasets on Hugging Face after processing them.
-
Loading from Hugging Face: After uploading the dataset to Hugging Face, we can load it into the Python environment using the
load_dataset()method with the appropriate path. -
Example of Dataset MediBeng Storing and Loading: The code snippet demonstrates how to load the MediBeng dataset from Hugging Face.

