<jupyter_start><jupyter_text>Load the dataset<jupyter_code>def load_dataset_javanese():
    urls = [
        "https://www.openslr.org/resources/41/jv_id_female.zip",
        "https://www.openslr.org/resources/41/jv_id_male.zip"
    ]
    dm = DownloadManager()
    download_dirs = dm.download_and_extract(urls)
    data_dirs = [ 
        Path(download_dirs[0])/"jv_id_female/wavs",
        Path(download_dirs[1])/"jv_id_male/wavs",
    ]
    filenames = [ 
        Path(download_dirs[0])/"jv_id_female/line_index.tsv",
        Path(download_dirs[1])/"jv_id_male/line_index.tsv",
    ]
    
    dfs = []
    dfs.append(pd.read_csv(filenames[0], sep='\t', names=["path", "sentence"]))
    dfs.append(pd.read_csv(filenames[1], sep='\t', names=["path", "client_id", "sentence"]))
    dfs[1] = dfs[1].drop(["client_id"], axis=1)
    
    for i, dir in enumerate(data_dirs):
        dfs[i]["path"] = dfs[i].apply(lambda row: str(data_dirs[i]) + "/" + row + ".wav", axis=1)
    df = pd.concat(dfs)
    # df = df.sample(frac=1, random_state=1).reset_index(drop=True)
    dataset = Dataset.from_pandas(df)
    dataset = dataset.remove_columns('__index_level_0__')
    
    return dataset.train_test_split(test_size=0.1, seed=1)
dataset = load_dataset_javanese()
# We can also just load it from the disk created during training
# dataset = datasets.load_from_disk("dataset_javanese")
dataset
test_dataset = dataset['test']
wer = load_metric("wer")
%%capture

model_name = "cahya/wav2vec2-large-xlsr-javanese"

processor = Wav2Vec2Processor.from_pretrained(model_name)
model = Wav2Vec2ForCTC.from_pretrained(model_name) 
model.to("cuda")
chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"\“\%\‘\'\”_\�]'
resampler = torchaudio.transforms.Resample(48_000, 16_000)
test_dataset = test_dataset.map(speech_file_to_array_fn)
result = test_dataset.map(evaluate, batched=True, batch_size=8)

print("WER: {:2f}".format(100 * wer.compute(predictions=result["pred_strings"], references=result["sentence"])))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1688247011952191, 'fraction_numerical': 0.02041832669322709, 'mean_word_length': 4.596100278551532, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '410784', 'license': 'MIT', 'n_tokens_mistral': 813, 'n_tokens_neox': 786, 'n_words': 98, 'path': 'XLSR_Wav2Vec2_for_Indonesian_Evaluation-Javanese.ipynb', 'repo_name': 'cahya-wirawan/indonesian-speech-recognition', 'size': '2008'}