pratikstar commited on
Commit
ea682b9
·
verified ·
1 Parent(s): f25bb8a

Upload 3 files

Browse files
Files changed (3) hide show
  1. modify.py +119 -0
  2. updated_timbre_dataset.csv +0 -0
  3. upload.py +34 -0
modify.py ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+
3
+ # Load the CSV file
4
+ file_path = "/Users/pratik.sutar/Desktop/supplementary material for NLP4MusA 2024/timbre annotations/timbre-dataset.csv"
5
+ df = pd.read_csv(file_path)
6
+
7
+ presetsById = {
8
+ '00001': '01A US Double Nrm',
9
+ '00002': '01B Essex A30',
10
+ '00003': '01C Brit Plexi Jump',
11
+ '00004': '01D Cali Rectifire',
12
+ '00005': '02A US Deluxe Nrm',
13
+ '00006': '02B A30 Fawn Nrm',
14
+ '00007': '02C Revv Gen Purple',
15
+ '00008': '02D Revv Gen Red',
16
+ '00009': '03A Archetype Clean',
17
+ '00010': '03B Matchstick Ch1',
18
+ '00011': '03C Brit 2204',
19
+ '00012': '03D Archetype Lead',
20
+ '00013': '04A Jazz Rivet 120',
21
+ '00014': '04B Fullerton Brt',
22
+ '00015': '04C Brit J45 Brt',
23
+ '00016': '04D Solo Lead OD',
24
+ '00017': '05A Placater Clean',
25
+ '00018': '05B Interstate Zed',
26
+ '00019': '05C Placater Dirty',
27
+ '00020': '05D PV Panama',
28
+ '00021': '06A Cali Texas Ch 1',
29
+ '00022': '06B Essex A15',
30
+ '00023': '06C Derailed Ingrid',
31
+ '00024': '06D German Mahadeva',
32
+ '00025': '07A WhoWatt 100',
33
+ '00026': '07B Line 6 Litigator',
34
+ '00027': '07C Cartographer',
35
+ '00028': '07D ANGL Meteor',
36
+ '00029': '08A US Small Tweed',
37
+ '00030': '08B Divided Duo',
38
+ '00031': '08C Brit P75 Brt',
39
+ '00032': '08D Line 6 Badonk',
40
+ '00033': '09A DI',
41
+ '00034': '09B BAS_SVT-4 Pro',
42
+ '00035': '09C BAS_Cali Bass',
43
+ '00036': '09D BAS_Aqua 51',
44
+ '00037': '10A BAS_Cougar 800',
45
+ '00038': '10B BAS_SVT Nrm',
46
+ '00039': '10C BAS_Cali 400 Ch1',
47
+ '00040': '10D BAS_Del Sol 300',
48
+ '00041': '11A BAS_Woody Blue',
49
+ '00042': '11B Trademark',
50
+ '00043': '11C AUS Flood',
51
+ '00044': '11D Justice Fo Y_all',
52
+ '00045': '12A Lonely Hearts',
53
+ '00046': '12B Pull Me Under',
54
+ '00047': '12C Stone Cold Loco',
55
+ '00048': '12D Plush Garden',
56
+ '00049': '13A Cowboys from DFW',
57
+ '00050': '13B G.O.A.T Rodeo',
58
+ '00051': '13C BIG DUBB',
59
+ '00052': '13D BIG VENUE DRIVE',
60
+ '00053': '14A BUBBLE NEST',
61
+ '00054': '14B DUSTED',
62
+ '00055': '14C SUNRISE DRIVE',
63
+ '00056': '14D GLISTEN',
64
+ '00057': '15A WATERS IN HELL',
65
+ '00058': '15B FAUX 7 STG CHUG',
66
+ '00059': '15C RICHEESE',
67
+ '00060': '15D RC REINCARNATION',
68
+ '00061': '16A RIFFS AND BEARDS',
69
+ '00062': '16B FELIX MARK IV',
70
+ '00063': '16C FELIX JAZZ 120',
71
+ '00064': '16D FELIX DELUXE MOD',
72
+ '00065': '17A FELIX ENGL',
73
+ '00066': '17B SPOTLIGHTS',
74
+ '00067': '17C BUMBLE ACOUSTIC',
75
+ '00068': '17D BMBLFOOT PRINCE',
76
+ '00069': '18A SHEEHAN PEARCE',
77
+ '00070': '18B SHEEHAN SVT4PRO',
78
+ '00071': '18C THE BLUE AGAVE',
79
+ '00072': '18D BULB RHYTHM',
80
+ '00073': '19A BULB LEAD',
81
+ '00074': '19B BULB CLEAN',
82
+ '00075': '19C BULB AMBIENT',
83
+ '00076': '19D EMPTY GARBAGE',
84
+ '00077': '20A ONLY GARBAGE',
85
+ '00078': '20B GARBAGE BASS',
86
+ '00079': '20C BILLY KASTODON',
87
+ '00080': '20D THIS IS THE END'
88
+ }
89
+
90
+ def change_path(clipid):
91
+ presetid, segmentid = clipid.split("-")
92
+ filename = "data/audio_files/" + clipid + " " + presetsById[presetid] + ".wav"
93
+ return filename
94
+
95
+ def str_to_list(x: str):
96
+ x = x.strip().strip('[').strip(']')
97
+ if len(x) == 0:
98
+ return []
99
+ x = x.replace("'", "").replace(" ", "")
100
+ x = x.split(",")
101
+ return x
102
+
103
+
104
+ # Replace the values in 'clip_a' and 'clip_b' with file paths
105
+ audio_dir = "audio_files/" # Directory containing the audio files
106
+ df['clip_a'] = df['clip_a'].apply(lambda x: change_path(x))
107
+ df['clip_b'] = df['clip_b'].apply(lambda x: change_path(x))
108
+ df['answer'] = df['answer'].apply(lambda x: "Clip A" if x == "clip_a" else "Clip B")
109
+ df['others'] = df['others'].apply(lambda x: str_to_list(x))
110
+
111
+
112
+ df = df.rename(columns={'clip_a': 'Clip-A', 'clip_b': 'Clip-B', 'attribute': 'Adjective', 'reg_ts_formattted': 'Timestamp', 'answer': 'Answer',
113
+ 'cust_attr': 'Free-style-Adjectives', 'others': 'Label-Annotations'})
114
+
115
+ print(df.columns)
116
+ print(df.iloc[0])
117
+
118
+ # Save the modified DataFrame (optional, for verification)
119
+ df.to_csv("./updated_timbre_dataset.csv", index=False)
updated_timbre_dataset.csv ADDED
The diff for this file is too large to render. See raw diff
 
upload.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import login
2
+
3
+ import pandas as pd
4
+ from datasets import Dataset, Audio, Sequence, Value
5
+ import ast
6
+
7
+ # login() # This will ask for your token, which you can get from https://huggingface.co/settings/tokens
8
+
9
+ repo_id = "pratikstar/doesitchug" # Replace 'your-username' with your Hugging Face username
10
+
11
+
12
+ # Load the CSV file
13
+ file_path = "./updated_timbre_dataset.csv"
14
+
15
+ df = pd.read_csv(file_path)
16
+
17
+ df['Label-Annotations'] = df['Label-Annotations'].apply(lambda x: ast.literal_eval(x) if isinstance(x, str) else x)
18
+
19
+ print(len(df))
20
+ print(df["Clip-A"][0])
21
+
22
+ # print(df["Clip A"])
23
+ # Convert the pandas DataFrame to a Hugging Face Dataset
24
+ hf_dataset = Dataset.from_pandas(df)
25
+
26
+ # Specify that 'clip_a' and 'clip_b' columns are audio columns
27
+ hf_dataset = hf_dataset.cast_column("Clip-A", Audio(sampling_rate=44100))
28
+ hf_dataset = hf_dataset.cast_column("Clip-B", Audio(sampling_rate=44100))
29
+ hf_dataset = hf_dataset.cast_column("Label-Annotations", Sequence(Value(dtype='string')))
30
+
31
+ print(hf_dataset[0])
32
+
33
+ # Push the dataset to the Hub
34
+ hf_dataset.push_to_hub(repo_id)