初始化项目,由ModelHub XC社区提供模型
Model: jonatasgrosman/wav2vec2-large-xlsr-53-russian Source: Original Platform
This commit is contained in:
17
.gitattributes
vendored
Normal file
17
.gitattributes
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.model filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||||
165
README.md
Normal file
165
README.md
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
---
|
||||||
|
language: ru
|
||||||
|
license: apache-2.0
|
||||||
|
datasets:
|
||||||
|
- common_voice
|
||||||
|
- mozilla-foundation/common_voice_6_0
|
||||||
|
metrics:
|
||||||
|
- wer
|
||||||
|
- cer
|
||||||
|
tags:
|
||||||
|
- audio
|
||||||
|
- automatic-speech-recognition
|
||||||
|
- hf-asr-leaderboard
|
||||||
|
- mozilla-foundation/common_voice_6_0
|
||||||
|
- robust-speech-event
|
||||||
|
- ru
|
||||||
|
- speech
|
||||||
|
- xlsr-fine-tuning-week
|
||||||
|
model-index:
|
||||||
|
- name: XLSR Wav2Vec2 Russian by Jonatas Grosman
|
||||||
|
results:
|
||||||
|
- task:
|
||||||
|
name: Automatic Speech Recognition
|
||||||
|
type: automatic-speech-recognition
|
||||||
|
dataset:
|
||||||
|
name: Common Voice ru
|
||||||
|
type: common_voice
|
||||||
|
args: ru
|
||||||
|
metrics:
|
||||||
|
- name: Test WER
|
||||||
|
type: wer
|
||||||
|
value: 13.3
|
||||||
|
- name: Test CER
|
||||||
|
type: cer
|
||||||
|
value: 2.88
|
||||||
|
- name: Test WER (+LM)
|
||||||
|
type: wer
|
||||||
|
value: 9.57
|
||||||
|
- name: Test CER (+LM)
|
||||||
|
type: cer
|
||||||
|
value: 2.24
|
||||||
|
- task:
|
||||||
|
name: Automatic Speech Recognition
|
||||||
|
type: automatic-speech-recognition
|
||||||
|
dataset:
|
||||||
|
name: Robust Speech Event - Dev Data
|
||||||
|
type: speech-recognition-community-v2/dev_data
|
||||||
|
args: ru
|
||||||
|
metrics:
|
||||||
|
- name: Dev WER
|
||||||
|
type: wer
|
||||||
|
value: 40.22
|
||||||
|
- name: Dev CER
|
||||||
|
type: cer
|
||||||
|
value: 14.8
|
||||||
|
- name: Dev WER (+LM)
|
||||||
|
type: wer
|
||||||
|
value: 33.61
|
||||||
|
- name: Dev CER (+LM)
|
||||||
|
type: cer
|
||||||
|
value: 13.5
|
||||||
|
---
|
||||||
|
|
||||||
|
# Fine-tuned XLSR-53 large model for speech recognition in Russian
|
||||||
|
|
||||||
|
Fine-tuned [facebook/wav2vec2-large-xlsr-53](https://huggingface.co/facebook/wav2vec2-large-xlsr-53) on Russian using the train and validation splits of [Common Voice 6.1](https://huggingface.co/datasets/common_voice) and [CSS10](https://github.com/Kyubyong/css10).
|
||||||
|
When using this model, make sure that your speech input is sampled at 16kHz.
|
||||||
|
|
||||||
|
This model has been fine-tuned thanks to the GPU credits generously given by the [OVHcloud](https://www.ovhcloud.com/en/public-cloud/ai-training/) :)
|
||||||
|
|
||||||
|
The script used for training can be found here: https://github.com/jonatasgrosman/wav2vec2-sprint
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
The model can be used directly (without a language model) as follows...
|
||||||
|
|
||||||
|
Using the [HuggingSound](https://github.com/jonatasgrosman/huggingsound) library:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from huggingsound import SpeechRecognitionModel
|
||||||
|
|
||||||
|
model = SpeechRecognitionModel("jonatasgrosman/wav2vec2-large-xlsr-53-russian")
|
||||||
|
audio_paths = ["/path/to/file.mp3", "/path/to/another_file.wav"]
|
||||||
|
|
||||||
|
transcriptions = model.transcribe(audio_paths)
|
||||||
|
```
|
||||||
|
|
||||||
|
Writing your own inference script:
|
||||||
|
|
||||||
|
```python
|
||||||
|
import torch
|
||||||
|
import librosa
|
||||||
|
from datasets import load_dataset
|
||||||
|
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
|
||||||
|
|
||||||
|
LANG_ID = "ru"
|
||||||
|
MODEL_ID = "jonatasgrosman/wav2vec2-large-xlsr-53-russian"
|
||||||
|
SAMPLES = 5
|
||||||
|
|
||||||
|
test_dataset = load_dataset("common_voice", LANG_ID, split=f"test[:{SAMPLES}]")
|
||||||
|
|
||||||
|
processor = Wav2Vec2Processor.from_pretrained(MODEL_ID)
|
||||||
|
model = Wav2Vec2ForCTC.from_pretrained(MODEL_ID)
|
||||||
|
|
||||||
|
# Preprocessing the datasets.
|
||||||
|
# We need to read the audio files as arrays
|
||||||
|
def speech_file_to_array_fn(batch):
|
||||||
|
speech_array, sampling_rate = librosa.load(batch["path"], sr=16_000)
|
||||||
|
batch["speech"] = speech_array
|
||||||
|
batch["sentence"] = batch["sentence"].upper()
|
||||||
|
return batch
|
||||||
|
|
||||||
|
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
||||||
|
inputs = processor(test_dataset["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
|
||||||
|
|
||||||
|
with torch.no_grad():
|
||||||
|
logits = model(inputs.input_values, attention_mask=inputs.attention_mask).logits
|
||||||
|
|
||||||
|
predicted_ids = torch.argmax(logits, dim=-1)
|
||||||
|
predicted_sentences = processor.batch_decode(predicted_ids)
|
||||||
|
|
||||||
|
for i, predicted_sentence in enumerate(predicted_sentences):
|
||||||
|
print("-" * 100)
|
||||||
|
print("Reference:", test_dataset[i]["sentence"])
|
||||||
|
print("Prediction:", predicted_sentence)
|
||||||
|
```
|
||||||
|
|
||||||
|
| Reference | Prediction |
|
||||||
|
| ------------- | ------------- |
|
||||||
|
| ОН РАБОТАТЬ, А ЕЕ НЕ УДЕРЖАТЬ НИКАК — БЕГАЕТ ЗА КЛЁШЕМ КАЖДОГО БУЛЬВАРНИКА. | ОН РАБОТАТЬ А ЕЕ НЕ УДЕРЖАТ НИКАК БЕГАЕТ ЗА КЛЕШОМ КАЖДОГО БУЛЬБАРНИКА |
|
||||||
|
| ЕСЛИ НЕ БУДЕТ ВОЗРАЖЕНИЙ, Я БУДУ СЧИТАТЬ, ЧТО АССАМБЛЕЯ СОГЛАСНА С ЭТИМ ПРЕДЛОЖЕНИЕМ. | ЕСЛИ НЕ БУДЕТ ВОЗРАЖЕНИЙ Я БУДУ СЧИТАТЬ ЧТО АССАМБЛЕЯ СОГЛАСНА С ЭТИМ ПРЕДЛОЖЕНИЕМ |
|
||||||
|
| ПАЛЕСТИНЦАМ НЕОБХОДИМО СНАЧАЛА УСТАНОВИТЬ МИР С ИЗРАИЛЕМ, А ЗАТЕМ ДОБИВАТЬСЯ ПРИЗНАНИЯ ГОСУДАРСТВЕННОСТИ. | ПАЛЕСТИНЦАМ НЕОБХОДИМО СНАЧАЛА УСТАНОВИТЬ С НИ МИР ФЕЗРЕЛЕМ А ЗАТЕМ ДОБИВАТЬСЯ ПРИЗНАНИЯ ГОСУДАРСТВЕНСКИ |
|
||||||
|
| У МЕНЯ БЫЛО ТАКОЕ ЧУВСТВО, ЧТО ЧТО-ТО ТАКОЕ ОЧЕНЬ ВАЖНОЕ Я ПРИБАВЛЯЮ. | У МЕНЯ БЫЛО ТАКОЕ ЧУВСТВО ЧТО ЧТО-ТО ТАКОЕ ОЧЕНЬ ВАЖНОЕ Я ПРЕДБАВЛЯЕТ |
|
||||||
|
| ТОЛЬКО ВРЯД ЛИ ПОЙМЕТ. | ТОЛЬКО ВРЯД ЛИ ПОЙМЕТ |
|
||||||
|
| ВРОНСКИЙ, СЛУШАЯ ОДНИМ УХОМ, ПЕРЕВОДИЛ БИНОКЛЬ С БЕНУАРА НА БЕЛЬ-ЭТАЖ И ОГЛЯДЫВАЛ ЛОЖИ. | ЗЛАЗКИ СЛУШАЮ ОТ ОДНИМ УХАМ ТЫ ВОТИ В ВИНОКОТ СПИЛА НА ПЕРЕТАЧ И ОКЛЯДЫВАЛ БОСУ |
|
||||||
|
| К СОЖАЛЕНИЮ, СИТУАЦИЯ ПРОДОЛЖАЕТ УХУДШАТЬСЯ. | К СОЖАЛЕНИЮ СИТУАЦИИ ПРОДОЛЖАЕТ УХУЖАТЬСЯ |
|
||||||
|
| ВСЁ ЖАЛОВАНИЕ УХОДИЛО НА ДОМАШНИЕ РАСХОДЫ И НА УПЛАТУ МЕЛКИХ НЕПЕРЕВОДИВШИХСЯ ДОЛГОВ. | ВСЕ ЖАЛОВАНИЕ УХОДИЛО НА ДОМАШНИЕ РАСХОДЫ И НА УПЛАТУ МЕЛКИХ НЕ ПЕРЕВОДИВШИХСЯ ДОЛГОВ |
|
||||||
|
| ТЕПЕРЬ ДЕЛО, КОНЕЧНО, ЗА ТЕМ, ЧТОБЫ ПРЕВРАТИТЬ СЛОВА В ДЕЛА. | ТЕПЕРЬ ДЕЛАЮ КОНЕЧНО ЗАТЕМ ЧТОБЫ ПРЕВРАТИТЬ СЛОВА В ДЕЛА |
|
||||||
|
| ДЕВЯТЬ | ЛЕВЕТЬ |
|
||||||
|
|
||||||
|
## Evaluation
|
||||||
|
|
||||||
|
1. To evaluate on `mozilla-foundation/common_voice_6_0` with split `test`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python eval.py --model_id jonatasgrosman/wav2vec2-large-xlsr-53-russian --dataset mozilla-foundation/common_voice_6_0 --config ru --split test
|
||||||
|
```
|
||||||
|
|
||||||
|
2. To evaluate on `speech-recognition-community-v2/dev_data`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python eval.py --model_id jonatasgrosman/wav2vec2-large-xlsr-53-russian --dataset speech-recognition-community-v2/dev_data --config ru --split validation --chunk_length_s 5.0 --stride_length_s 1.0
|
||||||
|
```
|
||||||
|
|
||||||
|
## Citation
|
||||||
|
If you want to cite this model you can use this:
|
||||||
|
|
||||||
|
```bibtex
|
||||||
|
@misc{grosman2021xlsr53-large-russian,
|
||||||
|
title={Fine-tuned {XLSR}-53 large model for speech recognition in {R}ussian},
|
||||||
|
author={Grosman, Jonatas},
|
||||||
|
howpublished={\url{https://huggingface.co/jonatasgrosman/wav2vec2-large-xlsr-53-russian}},
|
||||||
|
year={2021}
|
||||||
|
}
|
||||||
|
```
|
||||||
1
alphabet.json
Normal file
1
alphabet.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"labels": ["", "<s>", "</s>", "⁇", " ", "-", "ё", "а", "б", "в", "г", "д", "е", "ж", "з", "и", "й", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", "ь", "э", "ю", "я"], "is_bpe": false}
|
||||||
83
config.json
Normal file
83
config.json
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
{
|
||||||
|
"_name_or_path": "facebook/wav2vec2-large-xlsr-53",
|
||||||
|
"activation_dropout": 0.05,
|
||||||
|
"apply_spec_augment": true,
|
||||||
|
"architectures": [
|
||||||
|
"Wav2Vec2ForCTC"
|
||||||
|
],
|
||||||
|
"attention_dropout": 0.1,
|
||||||
|
"bos_token_id": 1,
|
||||||
|
"codevector_dim": 768,
|
||||||
|
"contrastive_logits_temperature": 0.1,
|
||||||
|
"conv_bias": true,
|
||||||
|
"conv_dim": [
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
512
|
||||||
|
],
|
||||||
|
"conv_kernel": [
|
||||||
|
10,
|
||||||
|
3,
|
||||||
|
3,
|
||||||
|
3,
|
||||||
|
3,
|
||||||
|
2,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
"conv_stride": [
|
||||||
|
5,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
"ctc_loss_reduction": "mean",
|
||||||
|
"ctc_zero_infinity": true,
|
||||||
|
"diversity_loss_weight": 0.1,
|
||||||
|
"do_stable_layer_norm": true,
|
||||||
|
"eos_token_id": 2,
|
||||||
|
"feat_extract_activation": "gelu",
|
||||||
|
"feat_extract_dropout": 0.0,
|
||||||
|
"feat_extract_norm": "layer",
|
||||||
|
"feat_proj_dropout": 0.05,
|
||||||
|
"feat_quantizer_dropout": 0.0,
|
||||||
|
"final_dropout": 0.0,
|
||||||
|
"hidden_act": "gelu",
|
||||||
|
"hidden_dropout": 0.05,
|
||||||
|
"hidden_size": 1024,
|
||||||
|
"initializer_range": 0.02,
|
||||||
|
"intermediate_size": 4096,
|
||||||
|
"layer_norm_eps": 1e-05,
|
||||||
|
"layerdrop": 0.05,
|
||||||
|
"mask_channel_length": 10,
|
||||||
|
"mask_channel_min_space": 1,
|
||||||
|
"mask_channel_other": 0.0,
|
||||||
|
"mask_channel_prob": 0.0,
|
||||||
|
"mask_channel_selection": "static",
|
||||||
|
"mask_feature_length": 10,
|
||||||
|
"mask_feature_prob": 0.0,
|
||||||
|
"mask_time_length": 10,
|
||||||
|
"mask_time_min_space": 1,
|
||||||
|
"mask_time_other": 0.0,
|
||||||
|
"mask_time_prob": 0.05,
|
||||||
|
"mask_time_selection": "static",
|
||||||
|
"model_type": "wav2vec2",
|
||||||
|
"num_attention_heads": 16,
|
||||||
|
"num_codevector_groups": 2,
|
||||||
|
"num_codevectors_per_group": 320,
|
||||||
|
"num_conv_pos_embedding_groups": 16,
|
||||||
|
"num_conv_pos_embeddings": 128,
|
||||||
|
"num_feat_extract_layers": 7,
|
||||||
|
"num_hidden_layers": 24,
|
||||||
|
"num_negatives": 100,
|
||||||
|
"pad_token_id": 0,
|
||||||
|
"proj_codevector_dim": 768,
|
||||||
|
"transformers_version": "4.7.0.dev0",
|
||||||
|
"vocab_size": 39
|
||||||
|
}
|
||||||
164
eval.py
Normal file
164
eval.py
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from datasets import load_dataset, load_metric, Audio, Dataset
|
||||||
|
from transformers import pipeline, AutoFeatureExtractor, AutoTokenizer, AutoConfig, AutoModelForCTC, Wav2Vec2Processor, Wav2Vec2ProcessorWithLM
|
||||||
|
import re
|
||||||
|
import torch
|
||||||
|
import argparse
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
|
def log_results(result: Dataset, args: Dict[str, str]):
|
||||||
|
""" DO NOT CHANGE. This function computes and logs the result metrics. """
|
||||||
|
|
||||||
|
log_outputs = args.log_outputs
|
||||||
|
dataset_id = "_".join(args.dataset.split("/") + [args.config, args.split])
|
||||||
|
|
||||||
|
# load metric
|
||||||
|
wer = load_metric("wer")
|
||||||
|
cer = load_metric("cer")
|
||||||
|
|
||||||
|
# compute metrics
|
||||||
|
wer_result = wer.compute(references=result["target"], predictions=result["prediction"])
|
||||||
|
cer_result = cer.compute(references=result["target"], predictions=result["prediction"])
|
||||||
|
|
||||||
|
# print & log results
|
||||||
|
result_str = (
|
||||||
|
f"WER: {wer_result}\n"
|
||||||
|
f"CER: {cer_result}"
|
||||||
|
)
|
||||||
|
print(result_str)
|
||||||
|
|
||||||
|
with open(f"{dataset_id}_eval_results.txt", "w") as f:
|
||||||
|
f.write(result_str)
|
||||||
|
|
||||||
|
# log all results in text file. Possibly interesting for analysis
|
||||||
|
if log_outputs is not None:
|
||||||
|
pred_file = f"log_{dataset_id}_predictions.txt"
|
||||||
|
target_file = f"log_{dataset_id}_targets.txt"
|
||||||
|
|
||||||
|
with open(pred_file, "w") as p, open(target_file, "w") as t:
|
||||||
|
|
||||||
|
# mapping function to write output
|
||||||
|
def write_to_file(batch, i):
|
||||||
|
p.write(f"{i}" + "\n")
|
||||||
|
p.write(batch["prediction"] + "\n")
|
||||||
|
t.write(f"{i}" + "\n")
|
||||||
|
t.write(batch["target"] + "\n")
|
||||||
|
|
||||||
|
result.map(write_to_file, with_indices=True)
|
||||||
|
|
||||||
|
|
||||||
|
def normalize_text(text: str, invalid_chars_regex: str, to_lower: bool) -> str:
|
||||||
|
""" DO ADAPT FOR YOUR USE CASE. this function normalizes the target text. """
|
||||||
|
|
||||||
|
text = text.lower() if to_lower else text.upper()
|
||||||
|
|
||||||
|
text = re.sub(invalid_chars_regex, " ", text)
|
||||||
|
|
||||||
|
text = re.sub("\s+", " ", text).strip()
|
||||||
|
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
def main(args):
|
||||||
|
# load dataset
|
||||||
|
dataset = load_dataset(args.dataset, args.config, split=args.split, use_auth_token=True)
|
||||||
|
|
||||||
|
# for testing: only process the first two examples as a test
|
||||||
|
# dataset = dataset.select(range(10))
|
||||||
|
|
||||||
|
# load processor
|
||||||
|
if args.greedy:
|
||||||
|
processor = Wav2Vec2Processor.from_pretrained(args.model_id)
|
||||||
|
decoder = None
|
||||||
|
else:
|
||||||
|
processor = Wav2Vec2ProcessorWithLM.from_pretrained(args.model_id)
|
||||||
|
decoder = processor.decoder
|
||||||
|
|
||||||
|
feature_extractor = processor.feature_extractor
|
||||||
|
tokenizer = processor.tokenizer
|
||||||
|
|
||||||
|
# resample audio
|
||||||
|
dataset = dataset.cast_column("audio", Audio(sampling_rate=feature_extractor.sampling_rate))
|
||||||
|
|
||||||
|
# load eval pipeline
|
||||||
|
if args.device is None:
|
||||||
|
args.device = 0 if torch.cuda.is_available() else -1
|
||||||
|
|
||||||
|
config = AutoConfig.from_pretrained(args.model_id)
|
||||||
|
model = AutoModelForCTC.from_pretrained(args.model_id)
|
||||||
|
|
||||||
|
#asr = pipeline("automatic-speech-recognition", model=args.model_id, device=args.device)
|
||||||
|
asr = pipeline("automatic-speech-recognition", config=config, model=model, tokenizer=tokenizer,
|
||||||
|
feature_extractor=feature_extractor, decoder=decoder, device=args.device)
|
||||||
|
|
||||||
|
# build normalizer config
|
||||||
|
tokenizer = AutoTokenizer.from_pretrained(args.model_id)
|
||||||
|
tokens = [x for x in tokenizer.convert_ids_to_tokens(range(0, tokenizer.vocab_size))]
|
||||||
|
special_tokens = [
|
||||||
|
tokenizer.pad_token, tokenizer.word_delimiter_token,
|
||||||
|
tokenizer.unk_token, tokenizer.bos_token,
|
||||||
|
tokenizer.eos_token,
|
||||||
|
]
|
||||||
|
non_special_tokens = [x for x in tokens if x not in special_tokens]
|
||||||
|
invalid_chars_regex = f"[^\s{re.escape(''.join(set(non_special_tokens)))}]"
|
||||||
|
normalize_to_lower = False
|
||||||
|
for token in non_special_tokens:
|
||||||
|
if token.isalpha() and token.islower():
|
||||||
|
normalize_to_lower = True
|
||||||
|
break
|
||||||
|
|
||||||
|
# map function to decode audio
|
||||||
|
def map_to_pred(batch, args=args, asr=asr, invalid_chars_regex=invalid_chars_regex, normalize_to_lower=normalize_to_lower):
|
||||||
|
prediction = asr(batch["audio"]["array"], chunk_length_s=args.chunk_length_s, stride_length_s=args.stride_length_s)
|
||||||
|
|
||||||
|
batch["prediction"] = prediction["text"]
|
||||||
|
batch["target"] = normalize_text(batch["sentence"], invalid_chars_regex, normalize_to_lower)
|
||||||
|
return batch
|
||||||
|
|
||||||
|
# run inference on all examples
|
||||||
|
result = dataset.map(map_to_pred, remove_columns=dataset.column_names)
|
||||||
|
|
||||||
|
# filtering out empty targets
|
||||||
|
result = result.filter(lambda example: example["target"] != "")
|
||||||
|
|
||||||
|
# compute and log_results
|
||||||
|
# do not change function below
|
||||||
|
log_results(result, args)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--model_id", type=str, required=True, help="Model identifier. Should be loadable with 🤗 Transformers"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--dataset", type=str, required=True, help="Dataset name to evaluate the `model_id`. Should be loadable with 🤗 Datasets"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--config", type=str, required=True, help="Config of the dataset. *E.g.* `'en'` for Common Voice"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--split", type=str, required=True, help="Split of the dataset. *E.g.* `'test'`"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--chunk_length_s", type=float, default=None, help="Chunk length in seconds. Defaults to None. For long audio files a good value would be 5.0 seconds."
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--stride_length_s", type=float, default=None, help="Stride of the audio chunks. Defaults to None. For long audio files a good value would be 1.0 seconds."
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--log_outputs", action='store_true', help="If defined, write outputs to log file for analysis."
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--greedy", action='store_true', help="If defined, the LM will be ignored during inference."
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--device",
|
||||||
|
type=int,
|
||||||
|
default=None,
|
||||||
|
help="The device to run the pipeline on. -1 for CPU (default), 0 for the first GPU and so on.",
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
main(args)
|
||||||
3
flax_model.msgpack
Normal file
3
flax_model.msgpack
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:967b19d6400670d9437a0489a13bedbc3da0c710a7671349ac679cad9853639f
|
||||||
|
size 1261930172
|
||||||
15
full_eval.sh
Normal file
15
full_eval.sh
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# CV - TEST
|
||||||
|
|
||||||
|
python eval.py --model_id jonatasgrosman/wav2vec2-large-xlsr-53-russian --dataset mozilla-foundation/common_voice_6_0 --config ru --split test --log_outputs --greedy
|
||||||
|
mv log_mozilla-foundation_common_voice_6_0_ru_test_predictions.txt log_mozilla-foundation_common_voice_6_0_ru_test_predictions_greedy.txt
|
||||||
|
mv mozilla-foundation_common_voice_6_0_ru_test_eval_results.txt mozilla-foundation_common_voice_6_0_ru_test_eval_results_greedy.txt
|
||||||
|
|
||||||
|
python eval.py --model_id jonatasgrosman/wav2vec2-large-xlsr-53-russian --dataset mozilla-foundation/common_voice_6_0 --config ru --split test --log_outputs
|
||||||
|
|
||||||
|
# HF EVENT - DEV
|
||||||
|
|
||||||
|
python eval.py --model_id jonatasgrosman/wav2vec2-large-xlsr-53-russian --dataset speech-recognition-community-v2/dev_data --config ru --split validation --chunk_length_s 5.0 --stride_length_s 1.0 --log_outputs --greedy
|
||||||
|
mv log_speech-recognition-community-v2_dev_data_ru_validation_predictions.txt log_speech-recognition-community-v2_dev_data_ru_validation_predictions_greedy.txt
|
||||||
|
mv speech-recognition-community-v2_dev_data_ru_validation_eval_results.txt speech-recognition-community-v2_dev_data_ru_validation_eval_results_greedy.txt
|
||||||
|
|
||||||
|
python eval.py --model_id jonatasgrosman/wav2vec2-large-xlsr-53-russian --dataset speech-recognition-community-v2/dev_data --config ru --split validation --chunk_length_s 5.0 --stride_length_s 1.0 --log_outputs
|
||||||
1
language_model/attrs.json
Normal file
1
language_model/attrs.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"alpha": 0.5, "beta": 1.5, "unk_score_offset": -10.0, "score_boundary": true}
|
||||||
3
language_model/lm.binary
Normal file
3
language_model/lm.binary
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:01a8fba99ad0d5157e060ea7bee83adb7bc7025606e6f98a783da1413b6edbaf
|
||||||
|
size 1486935543
|
||||||
3
language_model/unigrams.txt
Normal file
3
language_model/unigrams.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:e7c72ae916afa54951fe3bd6094c95e2895c1c7881a20e02ef640aa27cdb4874
|
||||||
|
size 32849086
|
||||||
16012
log_mozilla-foundation_common_voice_6_0_ru_test_predictions.txt
Normal file
16012
log_mozilla-foundation_common_voice_6_0_ru_test_predictions.txt
Normal file
File diff suppressed because it is too large
Load Diff
16012
log_mozilla-foundation_common_voice_6_0_ru_test_predictions_greedy.txt
Normal file
16012
log_mozilla-foundation_common_voice_6_0_ru_test_predictions_greedy.txt
Normal file
File diff suppressed because it is too large
Load Diff
16012
log_mozilla-foundation_common_voice_6_0_ru_test_targets.txt
Normal file
16012
log_mozilla-foundation_common_voice_6_0_ru_test_targets.txt
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
|
|||||||
|
WER: 0.09577627565075995
|
||||||
|
CER: 0.022471409641103304
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
WER: 0.1330815852068859
|
||||||
|
CER: 0.028824204091177356
|
||||||
10
preprocessor_config.json
Normal file
10
preprocessor_config.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"do_normalize": true,
|
||||||
|
"feature_extractor_type": "Wav2Vec2FeatureExtractor",
|
||||||
|
"feature_size": 1,
|
||||||
|
"padding_side": "right",
|
||||||
|
"padding_value": 0.0,
|
||||||
|
"return_attention_mask": true,
|
||||||
|
"sampling_rate": 16000,
|
||||||
|
"processor_class": "Wav2Vec2ProcessorWithLM"
|
||||||
|
}
|
||||||
3
pytorch_model.bin
Normal file
3
pytorch_model.bin
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:d1cdb1a7921de7d363f967a9b0101a713602e109dba62b6f3f9ae2e0b2df0c1c
|
||||||
|
size 1262093719
|
||||||
1
special_tokens_map.json
Normal file
1
special_tokens_map.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"bos_token": "<s>", "eos_token": "</s>", "unk_token": "<unk>", "pad_token": "<pad>"}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
WER: 0.3361409730688241
|
||||||
|
CER: 0.13507897295031526
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
WER: 0.4022498060512025
|
||||||
|
CER: 0.14809992240941075
|
||||||
1
vocab.json
Normal file
1
vocab.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"<pad>": 0, "<s>": 1, "</s>": 2, "<unk>": 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}
|
||||||
Reference in New Issue
Block a user