# Prepare func failed when mapped on audio dataset

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fprepare-func-failed-when-mapped-on-audio-dataset%2F20447%3E%5C
**Category:** Beginners\
**Created:** [July 16, 2022, 12:19am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fprepare-func-failed-when-mapped-on-audio-dataset%2F20447 "2022-07-16T00:19:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MidSummersEve](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@MidSummersEve](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FMidSummersEve)%5C
**Post date:** [July 16, 2022, 12:19am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fprepare-func-failed-when-mapped-on-audio-dataset%2F20447%2F1 "2022-07-16T00:19:47Z")

</div>

Greetings,

I am following [this notebook on fine-tuning a Wav2Vec model](https://colab.research.google.com/github/patrickvonplaten/notebooks/blob/master/Fine_tuning_Wav2Vec2_for_English_ASR.ipynb#scrollTo=mk9QHuSsN7lf)

The only difference is that, the notebook made use of a prepared dataset, while I am utilizing my own data.

I’ve made sure my dataset has the same layout as in the notebook:

**Mine:**

 ![mine_data](https://us1.discourse-cdn.com/hellohellohello/original/2X/5/5cccf3ce11de21b4fc97159fa6186686dfda7e09.png)

The error occurred when I try to map the rather standard prepare function on the dataset.

> def prepare\_dataset(batch):  
> 
> > print(audio)
> > 
> > batch[“input\_values”] = processor(audio[“array”],sampling\_rate=audio[“sampling\_rate”]).input\_values[0]  
> > batch[“input\_length”] = len(batch[“input\_values”])
> > 
> > with processor.as\_target\_processor():
> > 
> > > batch["labels"] = processor(batch["UTT"]).input\_ids
> > 
> > return batch

**mapping** :

> audio\_dataset = audio\_dataset.map(prepare\_dataset, num\_proc=4)

**Issue occurred** :

{‘bytes’: None, ‘path’: ‘/content/drive/MyDrive/Dissertation/Speech/Ses02M\_script01\_1\_M032.wav’}  
{‘bytes’: None, ‘path’: ‘/content/drive/MyDrive/Dissertation/Speech/Ses02M\_script01\_1\_M015.wav’}  
{‘bytes’: None, ‘path’: ‘/content/drive/MyDrive/Dissertation/Speech/Ses02F\_script01\_3\_M023.wav’}  
RemoteTraceback Traceback (most recent call last)  
RemoteTraceback:  
“”"  
Traceback (most recent call last):  
File “/usr/local/lib/python3.7/dist-packages/multiprocess/pool.py”, line 121, in worker  
result = (True, func(\*args, \*\*kwds))  
File “/usr/local/lib/python3.7/dist-packages/datasets/arrow\_dataset.py”, line 518, in wrapper  
out: Union[“Dataset”, “DatasetDict”] = func(self, \*args, \*\*kwargs)  
File “/usr/local/lib/python3.7/dist-packages/datasets/arrow\_dataset.py”, line 485, in wrapper  
out: Union[“Dataset”, “DatasetDict”] = func(self, \*args, \*\*kwargs)  
File “/usr/local/lib/python3.7/dist-packages/datasets/fingerprint.py”, line 413, in wrapper  
out = func(self, \*args, \*\*kwargs)  
File “/usr/local/lib/python3.7/dist-packages/datasets/arrow\_dataset.py”, line 2460, in \_map\_single  
example = apply\_function\_on\_filtered\_inputs(example, i, offset=offset)  
File “/usr/local/lib/python3.7/dist-packages/datasets/arrow\_dataset.py”, line 2367, in apply\_function\_on\_filtered\_inputs  
processed\_inputs = function(\*fn\_args, \*additional\_args, \*\*fn\_kwargs)  
File “”, line 6, in prepare\_dataset  
batch[“input\_values”] = processor(audio[“array”], sampling\_rate=audio[“sampling\_rate”]).input\_values[0]  
KeyError: ‘array’  
“”"

So it was saying that there is no ‘array’ key under the ‘audio’ entry of my dataset. But I do have it as has been previously shown. The result of my self-add-on print function suggested that the program saw only “bytes”(value None, not loaded) & “path”(value correct) entries under the ‘audio’ entry. Why am I experiencing this contradiction? I thought all waveforms would be accordingly resampled during mapping.

My Envs:  
Google Colab  
datasets==1.18.3  
transformers==4.17.0  
torch==1.12.0+cu113

Totally new to this. Can’t figure out the reason.  
Thanks in advance!
