File size: 1,073 Bytes
ea682b9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | from huggingface_hub import login
import pandas as pd
from datasets import Dataset, Audio, Sequence, Value
import ast
# login() # This will ask for your token, which you can get from https://huggingface.co/settings/tokens
repo_id = "pratikstar/doesitchug" # Replace 'your-username' with your Hugging Face username
# Load the CSV file
file_path = "./updated_timbre_dataset.csv"
df = pd.read_csv(file_path)
df['Label-Annotations'] = df['Label-Annotations'].apply(lambda x: ast.literal_eval(x) if isinstance(x, str) else x)
print(len(df))
print(df["Clip-A"][0])
# print(df["Clip A"])
# Convert the pandas DataFrame to a Hugging Face Dataset
hf_dataset = Dataset.from_pandas(df)
# Specify that 'clip_a' and 'clip_b' columns are audio columns
hf_dataset = hf_dataset.cast_column("Clip-A", Audio(sampling_rate=44100))
hf_dataset = hf_dataset.cast_column("Clip-B", Audio(sampling_rate=44100))
hf_dataset = hf_dataset.cast_column("Label-Annotations", Sequence(Value(dtype='string')))
print(hf_dataset[0])
# Push the dataset to the Hub
hf_dataset.push_to_hub(repo_id)
|