Upload 1.local_files.py
Browse files- 1.local_files.py +32 -0
1.local_files.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import Dataset, Audio
|
2 |
+
|
3 |
+
audio_paths = ["Creating_audio_dataset/audios/audio1.wav",
|
4 |
+
"Creating_audio_dataset/audios/audio2.wav",
|
5 |
+
"Creating_audio_dataset/audios/audio3.wav"]
|
6 |
+
|
7 |
+
transcript_data = ["this law was given to the jews after the like distribution plato who grounds his laws on this division made the fame regulation which had been received as a law by the athenians",
|
8 |
+
"two praise the lord with harp men need all the help they can get to stir them up to praise this is the lesson to be gathered from the use of musical instruments under the old dispensation israel was at school and used childish things to help her to learn",
|
9 |
+
"i always expect to discover a secret yet never do still the post haunts me for once boy chickadee kept house there"]
|
10 |
+
|
11 |
+
|
12 |
+
audio_data = {"audio" : audio_paths, "transcript": transcript_data}
|
13 |
+
|
14 |
+
# #load the dataset from dict
|
15 |
+
audio_dataset = Dataset.from_dict(audio_data)
|
16 |
+
|
17 |
+
# Cast the "audio" column to Audio feature
|
18 |
+
audio_dataset = audio_dataset.cast_column("audio", Audio())
|
19 |
+
|
20 |
+
# upload the dataset
|
21 |
+
audio_dataset.push_to_hub("Mike1794/test_audiodataset")
|
22 |
+
|
23 |
+
# Access the first element (audio file) in the dataset
|
24 |
+
first_audio = audio_dataset[0]
|
25 |
+
|
26 |
+
|
27 |
+
# # Get details of the loaded audio
|
28 |
+
print(f"Audio path: {first_audio['audio']['path']}") # Path to the audio file
|
29 |
+
print(f"Sampling rate: {first_audio['audio']['sampling_rate']}") # Sampling rate in Hz
|
30 |
+
print(f"Audio data (first few elements): {first_audio['audio']['array'][:5]}") # Array containing audio samples (float32)
|
31 |
+
|
32 |
+
# You can now access and process the audio data for your machine learning tasks.
|