File size: 3,764 Bytes
31504a3
63356a6
 
 
 
 
 
 
 
 
 
 
31504a3
63356a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b6e8cfc
63356a6
 
 
 
 
 
 
 
 
 
 
 
ddbced5
 
63356a6
 
 
 
 
 
 
 
ddbced5
 
63356a6
 
ddbced5
 
 
63356a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0cce16c
 
 
 
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
---
language:
- ko  # Example: fr
license: apache-2.0  # Example: apache-2.0 or any license from https://hf.co/docs/hub/repositories-licenses
library_name: transformers  # Optional. Example: keras or any library from https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Libraries.ts
tags:
- audio
- automatic-speech-recognition
datasets:
- KsponSpeech
metrics:
- wer  # Example: wer. Use metric id from https://hf.co/metrics
---

# ko-spelling-wav2vec2-conformer-del-1s

## Table of Contents
- [ko-spelling-wav2vec2-conformer-del-1s](#ko-spelling-wav2vec2-conformer-del-1s)
  - [Table of Contents](#table-of-contents)
  - [Model Details](#model-details)
  - [Evaluation](#evaluation)
  - [How to Get Started With the Model](#how-to-get-started-with-the-model)

## Model Details
- **Model Description:**
ํ•ด๋‹น ๋ชจ๋ธ์€ wav2vec2-conformer base architecture์— scratch pre-training ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. <br />
Wav2Vec2ConformerForCTC๋ฅผ ์ด์šฉํ•˜์—ฌ KsponSpeech์— ๋Œ€ํ•œ Fine-Tuning ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค. <br />

- Dataset use [AIHub KsponSpeech](https://www.aihub.or.kr/aihubdata/data/view.do?currMenu=115&topMenu=100&aihubDataSe=realm&dataSetSn=123) <br />
Datasets๋Š” ํ•ด๋‹น Data๋ฅผ ์ „์ฒ˜๋ฆฌํ•˜์—ฌ ์ž„์˜๋กœ ๋งŒ๋“ค์–ด ์‚ฌ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค. <br />
del-1s์˜ ์˜๋ฏธ๋Š” 1์ดˆ ์ดํ•˜์˜ ๋ฐ์ดํ„ฐ ํ•„ํ„ฐ๋ง์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. <br />
ํ•ด๋‹น ๋ชจ๋ธ์€ **์ฒ ์ž์ „์‚ฌ** ๊ธฐ์ค€์˜ ๋ฐ์ดํ„ฐ๋กœ ํ•™์Šต๋œ ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค. (์ˆซ์ž์™€ ์˜์–ด๋Š” ๊ฐ ํ‘œ๊ธฐ๋ฒ•์„ ๋”ฐ๋ฆ„) <br />

- **Developed by:**  TADev (@lIlBrother, @ddobokki, @jp42maru)
- **Language(s):** Korean
- **License:** apache-2.0
- **Parent Model:** See the [wav2vec2-conformer](https://huggingface.co/docs/transformers/model_doc/wav2vec2-conformer) for more information about the pre-trained base model. (ํ•ด๋‹น ๋ชจ๋ธ์€ wav2vec2-conformer base architecture์— scratch pre-training ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.)

## Evaluation
Just using `load_metric("wer")` and `load_metric("wer")` in huggingface `datasets` library <br />

## How to Get Started With the Model
```python
import librosa
from pyctcdecode import build_ctcdecoder
from transformers import (
    AutoConfig,
    AutoFeatureExtractor,
    AutoModelForCTC,
    AutoTokenizer,
    Wav2Vec2ProcessorWithLM,
)
from transformers.pipelines import AutomaticSpeechRecognitionPipeline

audio_path = ""

# ๋ชจ๋ธ๊ณผ ํ† ํฌ๋‚˜์ด์ €, ์˜ˆ์ธก์„ ์œ„ํ•œ ๊ฐ ๋ชจ๋“ˆ๋“ค์„ ๋ถˆ๋Ÿฌ์˜ต๋‹ˆ๋‹ค.
model = AutoModelForCTC.from_pretrained("42MARU/ko-spelling-wav2vec2-conformer-del-1s")
feature_extractor = AutoFeatureExtractor.from_pretrained("42MARU/ko-spelling-wav2vec2-conformer-del-1s")
tokenizer = AutoTokenizer.from_pretrained("42MARU/ko-spelling-wav2vec2-conformer-del-1s")
beamsearch_decoder = build_ctcdecoder(
    labels=list(tokenizer.encoder.keys()),
    kenlm_model_path=None,
)
processor = Wav2Vec2ProcessorWithLM(
    feature_extractor=feature_extractor, tokenizer=tokenizer, decoder=beamsearch_decoder
)

# ์‹ค์ œ ์˜ˆ์ธก์„ ์œ„ํ•œ ํŒŒ์ดํ”„๋ผ์ธ์— ์ •์˜๋œ ๋ชจ๋“ˆ๋“ค์„ ์‚ฝ์ž….
asr_pipeline = AutomaticSpeechRecognitionPipeline(
    model=model,
    tokenizer=processor.tokenizer,
    feature_extractor=processor.feature_extractor,
    decoder=processor.decoder,
    device=-1,
)

# ์Œ์„ฑํŒŒ์ผ์„ ๋ถˆ๋Ÿฌ์˜ค๊ณ  beamsearch ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ํŠน์ •ํ•˜์—ฌ ์˜ˆ์ธก์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.
raw_data, _ = librosa.load(audio_path, sr=16000)
kwargs = {"decoder_kwargs": {"beam_width": 100}}
pred = asr_pipeline(inputs=raw_data, **kwargs)["text"]
# ๋ชจ๋ธ์ด ์ž์†Œ ๋ถ„๋ฆฌ ์œ ๋‹ˆ์ฝ”๋“œ ํ…์ŠคํŠธ๋กœ ๋‚˜์˜ค๋ฏ€๋กœ, ์ผ๋ฐ˜ String์œผ๋กœ ๋ณ€ํ™˜ํ•ด์ค„ ํ•„์š”๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.
result = unicodedata.normalize("NFC", pred)
print(result)
# ์•ˆ๋…•ํ•˜์„ธ์š” 123 ํ…Œ์ŠคํŠธ์ž…๋‹ˆ๋‹ค.
```
*Beam-100 Result (WER)*:
| "clean" | "other" |
| ------- | ------- |
| 22.01   | 27.34   |