File size: 6,805 Bytes
a0a8333
39911bf
d0a7ba7
 
 
 
 
 
 
 
f46c130
 
 
 
 
a0a8333
 
d0a7ba7
 
 
 
 
f46c130
d0a7ba7
 
 
 
 
 
f46c130
d0a7ba7
 
 
f46c130
d0a7ba7
 
 
8c01e2c
d0a7ba7
 
 
 
 
 
 
 
 
 
 
 
 
 
ba540d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d0a7ba7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f46c130
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
---
license: mit
base_model: facebook/wav2vec2-conformer-rope-large
tags:
- generated_from_trainer
metrics:
- wer
model-index:
- name: wav2vec2-conformer-rope-jv-openslr
  results: []
datasets:
- openslr/openslr
language:
- jv
pipeline_tag: automatic-speech-recognition
---

<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->

# wav2vec2-conformer-rope-jv-openslr

This model is a fine-tuned version of [facebook/wav2vec2-conformer-rope-large](https://huggingface.co/facebook/wav2vec2-conformer-rope-large) on the [OpenSLR41](https://openslr.org/41/) datasets.
It achieves the following results on the evaluation set:
- Loss: 0.2555
- Wer: 0.1296

## Model description

The model is a fine-tuned version of wav2vec2-conformer-rope-large, specifically adapted using the OpenSLR 41 dataset, which is focused on the Javanese language domain. This adaptation enables the model to effectively recognize and process spoken Javanese, leveraging the robust capabilities of the wav2vec2-conformer-rope-large architecture combined with domain-specific training data.

## Intended uses & limitations

This model is intended for transcribing spoken Javanese language from audio recordings. It achieves a Word Error Rate (WER) of 12%, indicating that while the model performs reasonably well, it still produces significant transcription errors. Users should be aware that the accuracy may vary, particularly in cases with challenging audio conditions or less common dialects. Additionally, this model requires input audio at a sample rate of 16kHz, which may limit its applicability for recordings at different sample rates or lower quality audio files.

## Training and evaluation data

The model use OpenSLR41 datasets, and split into 2 section (training and testing), then the model is trained using 1xA100 GPU with a training duration of NaN hours.

### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 0.0001
- train_batch_size: 8
- eval_batch_size: 8
- seed: 42
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- lr_scheduler_warmup_steps: 1000
- num_epochs: 85
- mixed_precision_training: Native AMP

### How to run (Gradio Web)
```python
import torch
import torchaudio
import gradio as gr
import numpy as np
from transformers import pipeline, AutoProcessor, AutoModelForCTC

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

# Load the model and processor
MODEL_NAME = "<fill this to your model>"
processor = AutoProcessor.from_pretrained(MODEL_NAME)
model = AutoModelForCTC.from_pretrained(MODEL_NAME)

# Move model to GPU
model.to(device)

# Create the pipeline with the model and processor
transcriber = pipeline("automatic-speech-recognition", model=model, tokenizer=processor.tokenizer, feature_extractor=processor.feature_extractor, device=device)

def transcribe(audio):
    sr, y = audio
    y = y.astype(np.float32)
    y /= np.max(np.abs(y))

    return transcriber({"sampling_rate": sr, "raw": y})["text"]

demo = gr.Interface(
    transcribe,
    gr.Audio(sources=["upload"]),
    "text",
)

demo.launch(share=True)
```

### How to run
```python
import torch
import torchaudio
import gradio as gr
import numpy as np
from transformers import pipeline, AutoProcessor, AutoModelForCTC

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

# Load the model and processor
MODEL_NAME = "<fill this to actual model>"
processor = AutoProcessor.from_pretrained(MODEL_NAME)
model = AutoModelForCTC.from_pretrained(MODEL_NAME)

# Move model to GPU
model.to(device)

# Load audio file
AUDIO_PATH = "<replace 'path_to_audio_file.wav' with the actual path to your audio file>"
audio_input, sample_rate = torchaudio.load(AUDIO_PATH)

# Ensure the audio is mono (1 channel)
if audio_input.shape[0] > 1:
    audio_input = torch.mean(audio_input, dim=0, keepdim=True)

# Resample audio if necessary
if sample_rate != 16000:
    resampler = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=16000)
    audio_input = resampler(audio_input)

# Process the audio input
input_values = processor(audio_input.squeeze(), sampling_rate=16000, return_tensors="pt").input_values

# Move input values to GPU
input_values = input_values.to(device)

# Perform inference
with torch.no_grad():
    logits = model(input_values).logits

# Decode the logits to text
predicted_ids = torch.argmax(logits, dim=-1)
transcription = processor.batch_decode(predicted_ids)[0]

print("Transcription:", transcription)
```

### Training results

| Training Loss | Epoch   | Step  | Validation Loss | Wer    |
|:-------------:|:-------:|:-----:|:---------------:|:------:|
| 0.6796        | 2.8329  | 2000  | 0.5100          | 0.5010 |
| 0.4236        | 5.6657  | 4000  | 0.3792          | 0.3598 |
| 0.318         | 8.4986  | 6000  | 0.3244          | 0.2846 |
| 0.2444        | 11.3314 | 8000  | 0.3026          | 0.2674 |
| 0.1916        | 14.1643 | 10000 | 0.2682          | 0.2364 |
| 0.1588        | 16.9972 | 12000 | 0.2762          | 0.2398 |
| 0.1338        | 19.8300 | 14000 | 0.2623          | 0.2116 |
| 0.1201        | 22.6629 | 16000 | 0.2672          | 0.2081 |
| 0.1005        | 25.4958 | 18000 | 0.2596          | 0.1978 |
| 0.0921        | 28.3286 | 20000 | 0.2595          | 0.1881 |
| 0.0853        | 31.1615 | 22000 | 0.2671          | 0.1730 |
| 0.0761        | 33.9943 | 24000 | 0.2588          | 0.1744 |
| 0.0689        | 36.8272 | 26000 | 0.2490          | 0.1668 |
| 0.0646        | 39.6601 | 28000 | 0.2630          | 0.1633 |
| 0.0615        | 42.4929 | 30000 | 0.2677          | 0.1688 |
| 0.0563        | 45.3258 | 32000 | 0.2627          | 0.1585 |
| 0.0524        | 48.1586 | 34000 | 0.2497          | 0.1468 |
| 0.0511        | 50.9915 | 36000 | 0.2520          | 0.1516 |
| 0.0486        | 53.8244 | 38000 | 0.2418          | 0.1544 |
| 0.0415        | 56.6572 | 40000 | 0.2571          | 0.1489 |
| 0.0409        | 59.4901 | 42000 | 0.2687          | 0.1502 |
| 0.0361        | 62.3229 | 44000 | 0.2542          | 0.1371 |
| 0.0346        | 65.1558 | 46000 | 0.2504          | 0.1344 |
| 0.0312        | 67.9887 | 48000 | 0.2603          | 0.1337 |
| 0.0307        | 70.8215 | 50000 | 0.2641          | 0.1254 |
| 0.0305        | 73.6544 | 52000 | 0.2675          | 0.1289 |
| 0.0265        | 76.4873 | 54000 | 0.2625          | 0.1261 |
| 0.0271        | 79.3201 | 56000 | 0.2573          | 0.1268 |
| 0.0257        | 82.1530 | 58000 | 0.2571          | 0.1241 |
| 0.0247        | 84.9858 | 60000 | 0.2555          | 0.1296 |


### Framework versions

- Transformers 4.44.0
- Pytorch 2.2.1+cu118
- Datasets 2.20.0
- Tokenizers 0.19.1