|
--- |
|
language: |
|
- ko |
|
license: apache-2.0 |
|
library_name: kenlm |
|
tags: |
|
- automatic-speech-recognition |
|
- text2text-generation |
|
datasets: |
|
- korean-wiki |
|
--- |
|
# ko-ctc-kenlm-42maru-only-wiki |
|
## Table of Contents |
|
- [ko-ctc-kenlm-42maru-only-wiki](#ko-ctc-kenlm-42maru-only-wiki) |
|
- [Table of Contents](#table-of-contents) |
|
- [Model Details](#model-details) |
|
- [How to Get Started With the Model](#how-to-get-started-with-the-model) |
|
## Model Details |
|
- **Model Description** <br /> |
|
- ์ํฅ ๋ชจ๋ธ์ ์ํ N-gram Base์ LM์ผ๋ก ์์๋ณ ๋จ์ด๊ธฐ๋ฐ์ผ๋ก ๋ง๋ค์ด์ก์ผ๋ฉฐ, KenLM์ผ๋ก ํ์ต๋์์ต๋๋ค. ํด๋น ๋ชจ๋ธ์ [ko-42maru-wav2vec2-conformer-del-1s](https://huggingface.co/42MARU/ko-42maru-wav2vec2-conformer-del-1s)๊ณผ ์ฌ์ฉํ์ญ์์ค. <br /> |
|
- HuggingFace Transformers Style๋ก ๋ถ๋ฌ์ ์ฌ์ฉํ ์ ์๋๋ก ์ฒ๋ฆฌํ์ต๋๋ค. <br /> |
|
- pyctcdecode lib์ ์ด์ฉํด์๋ ๋ฐ๋ก ์ฌ์ฉ๊ฐ๋ฅํฉ๋๋ค. <br /> |
|
- data๋ wiki korean์ ์ฌ์ฉํ์ต๋๋ค. <br /> |
|
- 42maru vocab data์ ์๋ ๋ฌธ์ฅ์ ์ ๋ถ ์ ๊ฑฐํ์ฌ, ์คํ๋ ค LM์ผ๋ก Outlier๊ฐ ๋ฐ์ํ ์์๋ฅผ ์ต์ํ ์์ผฐ์ต๋๋ค. <br /> |
|
- ํด๋น ๋ชจ๋ธ์ **์์ฑ์ ์ฌ๋ฅผ ์์ฒด ์ปค์คํ
ํ 42maru** ๊ธฐ์ค์ ๋ฐ์ดํฐ๋ก ํ์ต๋ ๋ชจ๋ธ์
๋๋ค. (์ซ์์ ์์ด๋ ํ๊ธ ํ๊ธฐ๋ฒ์ ๋ฐ๋ฆ) <br /> |
|
- **Developed by:** TADev (@lIlBrother) |
|
- **Language(s):** Korean |
|
- **License:** apache-2.0 |
|
|
|
## 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-42maru-wav2vec2-conformer-del-1s") |
|
feature_extractor = AutoFeatureExtractor.from_pretrained("42MARU/ko-42maru-wav2vec2-conformer-del-1s") |
|
tokenizer = AutoTokenizer.from_pretrained("42MARU/ko-42maru-wav2vec2-conformer-del-1s") |
|
processor = Wav2Vec2ProcessorWithLM.from_pretrained("42MARU/ko-ctc-kenlm-42maru-only-wiki") |
|
|
|
# ์ค์ ์์ธก์ ์ํ ํ์ดํ๋ผ์ธ์ ์ ์๋ ๋ชจ๋๋ค์ ์ฝ์
. |
|
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) |
|
# ์๋
ํ์ธ์ ํ๋๋์
ํ
์คํธ์
๋๋ค. |
|
``` |
|
|