File size: 4,518 Bytes
a25b334
b586e31
 
 
 
 
 
 
 
224ef26
b586e31
 
a25b334
b586e31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
pretty_name: CantoMap
annotations_creators:
- crowdsourced
language_creators:
- crowdsourced
language:
- yue
license:
- gpl-3.0
multilinguality:
- monolingual
---

# Dataset Card for CantoMap

## Dataset Description

- **Homepage:** https://github.com/gwinterstein/CantoMap/
- **Repository:** https://github.com/gwinterstein/CantoMap/
- **Paper:** http://www.lrec-conf.org/proceedings/lrec2020/pdf/2020.lrec-1.355.pdf

### Dataset Summary

The Common Voice dataset consists of a unique MP3 and corresponding text file. 
Many of the 30328 recorded hours in the dataset also include demographic metadata like age, sex, and accent 
that can help improve the accuracy of speech recognition engines.

The dataset currently consists of 19673 validated hours in 120 languages, but more voices and languages are always added. 
Take a look at the [Languages](https://commonvoice.mozilla.org/en/languages) page to request a language or start contributing.

### Languages

```
Cantonese
```

## How to use

The `datasets` library allows you to load and pre-process your dataset in pure Python, at scale. The dataset can be downloaded and prepared in one call to your local drive by using the `load_dataset` function. 

For example, to download the Cantonese config, simply specify the corresponding language config name (i.e., "yue" for Cantonese):
```python
from datasets import load_dataset

cv_16 = load_dataset("safecantonese/cantomap", "yue", split="train")
```

Using the datasets library, you can also stream the dataset on-the-fly by adding a `streaming=True` argument to the `load_dataset` function call. Loading a dataset in streaming mode loads individual samples of the dataset at a time, rather than downloading the entire dataset to disk.
```python
from datasets import load_dataset

cv_16 = load_dataset("safecantonese/cantomap", "yue", split="train", streaming=True)

print(next(iter(cv_16)))
```

*Bonus*: create a [PyTorch dataloader](https://huggingface.co/docs/datasets/use_with_pytorch) directly with your own datasets (local/streamed).

### Local

```python
from datasets import load_dataset
from torch.utils.data.sampler import BatchSampler, RandomSampler

cv_16 = load_dataset("safecantonese/cantomap", "yue", split="train")

batch_sampler = BatchSampler(RandomSampler(cv_16), batch_size=32, drop_last=False)
dataloader = DataLoader(cv_16, batch_sampler=batch_sampler)
```

### Streaming

```python
from datasets import load_dataset
from torch.utils.data import DataLoader

cv_16 = load_dataset("safecantonese/cantomap", "yue", split="train")
dataloader = DataLoader(cv_16, batch_size=32)
```

To find out more about loading and preparing audio datasets, head over to [hf.co/blog/audio-datasets](https://huggingface.co/blog/audio-datasets).

### Example scripts

Train your own CTC or Seq2Seq Automatic Speech Recognition models on CantoMap with `transformers` - [here](https://github.com/huggingface/transformers/tree/main/examples/pytorch/speech-recognition).

## Dataset Structure

### Data Instances

A typical data point comprises the `path` to the audio file and its `sentence`. 

```python
{
  'path': 'et/clips/common_voice_et_18318995.mp3', 
  'audio': {
    'path': 'et/clips/common_voice_et_18318995.mp3', 
    'array': array([-0.00048828, -0.00018311, -0.00137329, ...,  0.00079346, 0.00091553,  0.00085449], dtype=float32), 
    'sampling_rate': 48000
  },
  'sentence': 'Tasub kokku saada inimestega, keda tunned juba ammust ajast saati.', 
}
```

### Data Fields

`path` (`string`): The path to the audio file

`audio` (`dict`): A dictionary containing the path to the downloaded audio file, the decoded audio array, and the sampling rate. Note that when accessing the audio column: `dataset[0]["audio"]` the audio file is automatically decoded and resampled to `dataset.features["audio"].sampling_rate`. Decoding and resampling of a large number of audio files might take a significant amount of time. Thus it is important to first query the sample index before the `"audio"` column, *i.e.* `dataset[0]["audio"]` should **always** be preferred over `dataset["audio"][0]`.

`sentence` (`string`): The sentence the user was prompted to speak

### Data Splits

The speech material has been subdivided into portions for train and test.

## Additional Information

### Licensing Information

gpl-3.0

### Citation Information

```
@inproceedings{lrec:2020,
  author = {Winterstein, Grégoire, Tang, Carmen and Lai, Regine},
  title = {CantoMap: a Hong Kong Cantonese MapTask Corpus}
}
```