lucasjca commited on
Commit
4337c4a
·
verified ·
1 Parent(s): 221b192

Upload 2 files

Browse files
Files changed (2) hide show
  1. audio-text-demo.py +60 -0
  2. audios.tar.gz +3 -0
audio-text-demo.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+
3
+ _CITATION = """\
4
+ @InProceedings{huggingface:dataset,
5
+ title = {Small audio-text set},
6
+ author={James Briggs},
7
+ year={2022}
8
+ }
9
+ """
10
+
11
+ _DESCRIPTION = """\
12
+ Demo dataset for testing or showing audio-text capabilities.
13
+ """
14
+ ##_HOMEPAGE = "https://huggingface.co/datasets/jamescalam/audio-text-demo"
15
+ _HOMEPAGE = "https://huggingface.co/datasets/lucasjca/audio-files"
16
+
17
+ _LICENSE = ""
18
+
19
+ #_REPO = "https://huggingface.co/datasets/jamescalam/audio-text-demo"
20
+ _REPO = "https://huggingface.co/datasets/lucasjca/audio-files"
21
+
22
+ class audioSet(datasets.GeneratorBasedBuilder):
23
+ """Small sample of audio-text pairs"""
24
+
25
+ def _info(self):
26
+ return datasets.DatasetInfo(
27
+ description=_DESCRIPTION,
28
+ features=datasets.Features(
29
+ {
30
+ 'text': datasets.Value("string"),
31
+ 'audio': datasets.audio(),
32
+ }
33
+ ),
34
+ supervised_keys=None,
35
+ homepage=_HOMEPAGE,
36
+ citation=_CITATION,
37
+ )
38
+
39
+ def _split_generators(self, dl_manager):
40
+ audios_archive = dl_manager.download(f"{_REPO}/resolve/main/audios.tgz")
41
+ audio_iters = dl_manager.iter_archive(audios_archive)
42
+ return [
43
+ datasets.SplitGenerator(
44
+ name=datasets.Split.TRAIN,
45
+ gen_kwargs={
46
+ "audios": audio_iters
47
+ }
48
+ ),
49
+ ]
50
+
51
+ def _generate_examples(self, audios):
52
+ """ This function returns the examples in the raw (text) form."""
53
+
54
+ for idx, (filepath, audio) in enumerate(audios):
55
+ description = filepath.split('/')[-1][:-4]
56
+ description = description.replace('_', ' ')
57
+ yield idx, {
58
+ "audio": {"path": filepath, "bytes": audio.read()},
59
+ "text": description,
60
+ }
audios.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d99e7d81b4665107277e2a60c6b3ef5ae4a56edf8aaf680d1b004a552a8034ee
3
+ size 191