初始化项目,由ModelHub XC社区提供模型
Model: Harveenchadha/vakyansh-wav2vec2-tamil-tam-250 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
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
135
README.md
Normal file
135
README.md
Normal file
@@ -0,0 +1,135 @@
|
||||
---
|
||||
language: ta
|
||||
#datasets:
|
||||
#- Interspeech 2021
|
||||
metrics:
|
||||
- wer
|
||||
tags:
|
||||
- audio
|
||||
- automatic-speech-recognition
|
||||
- speech
|
||||
license: mit
|
||||
model-index:
|
||||
- name: Wav2Vec2 Vakyansh Tamil Model by Harveen Chadha
|
||||
results:
|
||||
- task:
|
||||
name: Speech Recognition
|
||||
type: automatic-speech-recognition
|
||||
dataset:
|
||||
name: Common Voice ta
|
||||
type: common_voice
|
||||
args: ta
|
||||
metrics:
|
||||
- name: Test WER
|
||||
type: wer
|
||||
value: 53.64
|
||||
---
|
||||
|
||||
## Pretrained Model
|
||||
|
||||
Fine-tuned on Multilingual Pretrained Model [CLSRIL-23](https://arxiv.org/abs/2107.07402). The original fairseq checkpoint is present [here](https://github.com/Open-Speech-EkStep/vakyansh-models). When using this model, make sure that your speech input is sampled at 16kHz.
|
||||
|
||||
**Note: The result from this model is without a language model so you may witness a higher WER in some cases.**
|
||||
|
||||
## Dataset
|
||||
|
||||
This model was trained on 4200 hours of Hindi Labelled Data. The labelled data is not present in public domain as of now.
|
||||
|
||||
## Training Script
|
||||
|
||||
Models were trained using experimental platform setup by Vakyansh team at Ekstep. Here is the [training repository](https://github.com/Open-Speech-EkStep/vakyansh-wav2vec2-experimentation).
|
||||
|
||||
In case you want to explore training logs on wandb they are [here](https://wandb.ai/harveenchadha/tamil-finetuning-multilingual).
|
||||
|
||||
|
||||
## [Colab Demo](https://github.com/harveenchadha/bol/blob/main/demos/hf/tamil/hf_tamil_tnm_4200_demo.ipynb)
|
||||
|
||||
## Usage
|
||||
|
||||
The model can be used directly (without a language model) as follows:
|
||||
|
||||
```python
|
||||
import soundfile as sf
|
||||
import torch
|
||||
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
|
||||
import argparse
|
||||
|
||||
def parse_transcription(wav_file):
|
||||
# load pretrained model
|
||||
processor = Wav2Vec2Processor.from_pretrained("Harveenchadha/vakyansh-wav2vec2-tamil-tam-250")
|
||||
model = Wav2Vec2ForCTC.from_pretrained("Harveenchadha/vakyansh-wav2vec2-tamil-tam-250")
|
||||
|
||||
# load audio
|
||||
audio_input, sample_rate = sf.read(wav_file)
|
||||
|
||||
# pad input values and return pt tensor
|
||||
input_values = processor(audio_input, sampling_rate=sample_rate, return_tensors="pt").input_values
|
||||
|
||||
# INFERENCE
|
||||
# retrieve logits & take argmax
|
||||
logits = model(input_values).logits
|
||||
predicted_ids = torch.argmax(logits, dim=-1)
|
||||
|
||||
# transcribe
|
||||
transcription = processor.decode(predicted_ids[0], skip_special_tokens=True)
|
||||
print(transcription)
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Evaluation
|
||||
The model can be evaluated as follows on the hindi test data of Common Voice.
|
||||
|
||||
```python
|
||||
|
||||
import torch
|
||||
import torchaudio
|
||||
from datasets import load_dataset, load_metric
|
||||
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
|
||||
import re
|
||||
|
||||
test_dataset = load_dataset("common_voice", "ta", split="test")
|
||||
wer = load_metric("wer")
|
||||
|
||||
processor = Wav2Vec2Processor.from_pretrained("Harveenchadha/vakyansh-wav2vec2-tamil-tam-250")
|
||||
model = Wav2Vec2ForCTC.from_pretrained("Harveenchadha/vakyansh-wav2vec2-tamil-tam-250")
|
||||
model.to("cuda")
|
||||
|
||||
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
||||
|
||||
chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"\“]'
|
||||
|
||||
# Preprocessing the datasets.
|
||||
# We need to read the aduio files as arrays
|
||||
def speech_file_to_array_fn(batch):
|
||||
batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
|
||||
speech_array, sampling_rate = torchaudio.load(batch["path"])
|
||||
batch["speech"] = resampler(speech_array).squeeze().numpy()
|
||||
return batch
|
||||
|
||||
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
||||
|
||||
# Preprocessing the datasets.
|
||||
# We need to read the aduio files as arrays
|
||||
def evaluate(batch):
|
||||
inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
|
||||
|
||||
with torch.no_grad():
|
||||
logits = model(inputs.input_values.to("cuda")).logits
|
||||
|
||||
pred_ids = torch.argmax(logits, dim=-1)
|
||||
batch["pred_strings"] = processor.batch_decode(pred_ids, skip_special_tokens=True)
|
||||
return batch
|
||||
|
||||
result = test_dataset.map(evaluate, batched=True, batch_size=8)
|
||||
|
||||
print("WER: {:2f}".format(100 * wer.compute(predictions=result["pred_strings"], references=result["sentence"])))
|
||||
|
||||
```
|
||||
|
||||
**Test Result**: 53.64 %
|
||||
|
||||
[**Colab Evaluation**](https://github.com/harveenchadha/bol/blob/main/demos/hf/tamil/hf_vakyansh_tamil_tnm_4200_evaluation_common_voice.ipynb)
|
||||
|
||||
## Credits
|
||||
Thanks to Ekstep Foundation for making this possible. The vakyansh team will be open sourcing speech models in all the Indic Languages.
|
||||
81
config.json
Normal file
81
config.json
Normal file
@@ -0,0 +1,81 @@
|
||||
{
|
||||
"activation_dropout": 0.1,
|
||||
"apply_spec_augment": true,
|
||||
"architectures": [
|
||||
"Wav2Vec2ForCTC"
|
||||
],
|
||||
"attention_dropout": 0.1,
|
||||
"bos_token": "<s>",
|
||||
"bos_token_id": 0,
|
||||
"codevector_dim": 256,
|
||||
"contrastive_logits_temperature": 0.1,
|
||||
"conv_bias": false,
|
||||
"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": "sum",
|
||||
"ctc_zero_infinity": false,
|
||||
"diversity_loss_weight": 0.1,
|
||||
"do_lower_case": false,
|
||||
"do_stable_layer_norm": false,
|
||||
"eos_token": "</s>",
|
||||
"eos_token_id": 2,
|
||||
"feat_extract_activation": "gelu",
|
||||
"feat_extract_norm": "group",
|
||||
"feat_proj_dropout": 0.1,
|
||||
"feat_quantizer_dropout": 0.0,
|
||||
"final_dropout": 0.1,
|
||||
"gradient_checkpointing": false,
|
||||
"hidden_act": "gelu",
|
||||
"hidden_dropout": 0.1,
|
||||
"hidden_size": 768,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 3072,
|
||||
"layer_norm_eps": 1e-05,
|
||||
"layerdrop": 0.1,
|
||||
"mask_feature_length": 10,
|
||||
"mask_feature_prob": 0.0,
|
||||
"mask_time_length": 10,
|
||||
"mask_time_prob": 0.05,
|
||||
"model_type": "wav2vec2",
|
||||
"num_attention_heads": 12,
|
||||
"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": 12,
|
||||
"num_negatives": 100,
|
||||
"pad_token": "[PAD]",
|
||||
"pad_token_id": 1,
|
||||
"proj_codevector_dim": 256,
|
||||
"torch_dtype": "float32",
|
||||
"transformers_version": "4.9.1",
|
||||
"unk_token": "[UNK]",
|
||||
"vocab_size": 53,
|
||||
"word_delimiter_token": "|"
|
||||
}
|
||||
9
preprocessor_config.json
Normal file
9
preprocessor_config.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"do_normalize": true,
|
||||
"feature_extractor_type": "Wav2Vec2FeatureExtractor",
|
||||
"feature_size": 1,
|
||||
"padding_side": "right",
|
||||
"padding_value": 0,
|
||||
"return_attention_mask": false,
|
||||
"sampling_rate": 16000
|
||||
}
|
||||
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:00adef7dc21c04f9014807f73c21c5fa12f9284aed6a5494a72bfc42ff3e55e7
|
||||
size 377731607
|
||||
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>"}
|
||||
1
tokenizer_config.json
Normal file
1
tokenizer_config.json
Normal file
@@ -0,0 +1 @@
|
||||
{"unk_token": "<unk>", "bos_token": "<s>", "eos_token": "</s>", "pad_token": "<pad>", "do_lower_case": false, "word_delimiter_token": "|", "tokenizer_class": "Wav2Vec2CTCTokenizer"}
|
||||
1
vocab.json
Normal file
1
vocab.json
Normal file
@@ -0,0 +1 @@
|
||||
{"<s>": 0, "<pad>": 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, "ஸ": 39, "ஹ": 40, "ா": 41, "ி": 42, "ீ": 43, "ு": 44, "ூ": 45, "ெ": 46, "ே": 47, "ை": 48, "ொ": 49, "ோ": 50, "ௌ": 51, "்": 52}
|
||||
Reference in New Issue
Block a user