rmarcosg commited on
Commit
fa4c855
·
verified ·
1 Parent(s): 7d62bf3

Update bark_detection.py

Browse files
Files changed (1) hide show
  1. bark_detection.py +40 -2
bark_detection.py CHANGED
@@ -1,6 +1,22 @@
1
- """A bark detection dataset"""
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- import csv
 
 
 
4
 
5
  import datasets
6
 
@@ -31,6 +47,14 @@ class BarkDetection(datasets.GeneratorBasedBuilder):
31
  def _info(self):
32
  return datasets.DatasetInfo(
33
  description=_DESCRIPTION,
 
 
 
 
 
 
 
 
34
  homepage=_HOMEPAGE,
35
  license=_LICENSE,
36
  citation=_CITATION,
@@ -61,3 +85,17 @@ class BarkDetection(datasets.GeneratorBasedBuilder):
61
  },
62
  ),
63
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2024 The HuggingFace Datasets Authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
 
16
+ # Lint as: python3
17
+
18
+ from pathlib import Path
19
+ from random import shuffle
20
 
21
  import datasets
22
 
 
47
  def _info(self):
48
  return datasets.DatasetInfo(
49
  description=_DESCRIPTION,
50
+ features=datasets.Features(
51
+ {
52
+ "file": datasets.Value("string"),
53
+ "audio": datasets.Audio(sampling_rate=44_100),
54
+ "label": datasets.Value("string"),
55
+ }
56
+ ),
57
+ supervised_keys=("file", "label"),
58
  homepage=_HOMEPAGE,
59
  license=_LICENSE,
60
  citation=_CITATION,
 
85
  },
86
  ),
87
  ]
88
+
89
+ def _generate_examples(self, archive_path, split):
90
+ """Yields examples."""
91
+ key = 0
92
+ audio_files_dir = Path(archive_path) / split
93
+ for audio_file_path in shuffle(audio_files_dir.glob("*/*.wav")):
94
+ filename = audio_file_path.stem
95
+ label = audio_file_path.parent.stem
96
+ yield key, {
97
+ "file": filename,
98
+ "audio": str(audio_file_path),
99
+ "label": label,
100
+ }
101
+ key += 1