lIlBrother
commited on
Commit
ยท
096e07c
1
Parent(s):
8cd3453
Init: README
Browse files
README.md
CHANGED
@@ -1,3 +1,65 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- ko # Example: fr
|
4 |
+
license: apache-2.0 # Example: apache-2.0 or any license from https://hf.co/docs/hub/repositories-licenses
|
5 |
+
library_name: kenlm # Optional. Example: keras or any library from https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Libraries.ts
|
6 |
+
tags:
|
7 |
+
- automatic-speech-recognition
|
8 |
+
- text2text-generation
|
9 |
+
datasets:
|
10 |
+
- korean-wiki
|
11 |
---
|
12 |
+
# ko-ctc-kenlm-42maru-only-wiki
|
13 |
+
## Table of Contents
|
14 |
+
- [ko-ctc-kenlm-42maru-only-wiki](#ko-ctc-kenlm-42maru-only-wiki)
|
15 |
+
- [Table of Contents](#table-of-contents)
|
16 |
+
- [Model Details](#model-details)
|
17 |
+
- [How to Get Started With the Model](#how-to-get-started-with-the-model)
|
18 |
+
## Model Details
|
19 |
+
- **Model Description** <br />
|
20 |
+
- ์ํฅ ๋ชจ๋ธ์ ์ํ N-gram Base์ LM์ผ๋ก ์์๋ณ ๋จ์ด๊ธฐ๋ฐ์ผ๋ก ๋ง๋ค์ด์ก์ผ๋ฉฐ, KenLM์ผ๋ก ํ์ต๋์์ต๋๋ค. ํด๋น ๋ชจ๋ธ์ [ko-42maru-wav2vec2-conformer-del-1s](https://huggingface.co/42MARU/ko-42maru-wav2vec2-conformer-del-1s)๊ณผ ์ฌ์ฉํ์ญ์์ค. <br />
|
21 |
+
- HuggingFace Transformers Style๋ก ๋ถ๋ฌ์ ์ฌ์ฉํ ์ ์๋๋ก ์ฒ๋ฆฌํ์ต๋๋ค. <br />
|
22 |
+
- pyctcdecode lib์ ์ด์ฉํด์๋ ๋ฐ๋ก ์ฌ์ฉ๊ฐ๋ฅํฉ๋๋ค. <br />
|
23 |
+
- data๋ wiki korean์ ์ฌ์ฉํ์ต๋๋ค. <br />
|
24 |
+
- 42maru vocab data์ ์๋ ๋ฌธ์ฅ์ ์ ๋ถ ์ ๊ฑฐํ์ฌ, ์คํ๋ ค LM์ผ๋ก Outlier๊ฐ ๋ฐ์ํ ์์๋ฅผ ์ต์ํ ์์ผฐ์ต๋๋ค. <br />
|
25 |
+
- ํด๋น ๋ชจ๋ธ์ **์์ฑ์ ์ฌ๋ฅผ ์์ฒด ์ปค์คํ
ํ 42maru** ๊ธฐ์ค์ ๋ฐ์ดํฐ๋ก ํ์ต๋ ๋ชจ๋ธ์
๋๋ค. (์ซ์์ ์์ด๋ ํ๊ธ ํ๊ธฐ๋ฒ์ ๋ฐ๋ฆ) <br />
|
26 |
+
- **Developed by:** TADev (@lIlBrother)
|
27 |
+
- **Language(s):** Korean
|
28 |
+
- **License:** apache-2.0
|
29 |
+
|
30 |
+
## How to Get Started With the Model
|
31 |
+
```python
|
32 |
+
import librosa
|
33 |
+
from pyctcdecode import build_ctcdecoder
|
34 |
+
from transformers import (
|
35 |
+
AutoConfig,
|
36 |
+
AutoFeatureExtractor,
|
37 |
+
AutoModelForCTC,
|
38 |
+
AutoTokenizer,
|
39 |
+
Wav2Vec2ProcessorWithLM,
|
40 |
+
)
|
41 |
+
from transformers.pipelines import AutomaticSpeechRecognitionPipeline
|
42 |
+
audio_path = ""
|
43 |
+
# ๋ชจ๋ธ๊ณผ ํ ํฌ๋์ด์ , ์์ธก์ ์ํ ๊ฐ ๋ชจ๋๋ค์ ๋ถ๋ฌ์ต๋๋ค.
|
44 |
+
model = AutoModelForCTC.from_pretrained("42MARU/ko-42maru-wav2vec2-conformer-del-1s")
|
45 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained("42MARU/ko-42maru-wav2vec2-conformer-del-1s")
|
46 |
+
tokenizer = AutoTokenizer.from_pretrained("42MARU/ko-42maru-wav2vec2-conformer-del-1s")
|
47 |
+
processor = Wav2Vec2ProcessorWithLM.from_pretrained("42MARU/ko-ctc-kenlm-42maru-only-wiki")
|
48 |
+
|
49 |
+
# ์ค์ ์์ธก์ ์ํ ํ์ดํ๋ผ์ธ์ ์ ์๋ ๋ชจ๋๋ค์ ์ฝ์
.
|
50 |
+
asr_pipeline = AutomaticSpeechRecognitionPipeline(
|
51 |
+
model=model,
|
52 |
+
tokenizer=processor.tokenizer,
|
53 |
+
feature_extractor=processor.feature_extractor,
|
54 |
+
decoder=processor.decoder,
|
55 |
+
device=-1,
|
56 |
+
)
|
57 |
+
# ์์ฑํ์ผ์ ๋ถ๋ฌ์ค๊ณ beamsearch ํ๋ผ๋ฏธํฐ๋ฅผ ํน์ ํ์ฌ ์์ธก์ ์ํํฉ๋๋ค.
|
58 |
+
raw_data, _ = librosa.load(audio_path, sr=16000)
|
59 |
+
kwargs = {"decoder_kwargs": {"beam_width": 100}}
|
60 |
+
pred = asr_pipeline(inputs=raw_data, **kwargs)["text"]
|
61 |
+
# ๋ชจ๋ธ์ด ์์ ๋ถ๋ฆฌ ์ ๋์ฝ๋ ํ
์คํธ๋ก ๋์ค๋ฏ๋ก, ์ผ๋ฐ String์ผ๋ก ๋ณํํด์ค ํ์๊ฐ ์์ต๋๋ค.
|
62 |
+
result = unicodedata.normalize("NFC", pred)
|
63 |
+
print(result)
|
64 |
+
# ์๋
ํ์ธ์ ํ๋๋์
ํ
์คํธ์
๋๋ค.
|
65 |
+
```
|