File size: 2,472 Bytes
84e86b3
 
 
 
2d75b0b
 
8cc1cee
2d75b0b
 
245178b
 
8cc1cee
0400d47
8cc1cee
0400d47
 
 
2d75b0b
 
 
 
 
 
 
 
 
 
d9fd3db
2d75b0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
language:
- ja
---

# ドミニオン日本語LLM for Whisper(2023/12/19 1.0版)

## 概要
Whisperでドミニオン(ボードゲーム)のカード用語などを含んだ音声を文字起こし出来ることを目標にチューニングされたLLMです。<br>
open-ai/largeモデルをベースにファインチューニングすることで生成されています。<br>
2023/12/19時点、全てのカードを学習済み。通常のlargeモデルと比較して適切に出力される様子が確認できると思います。<br>

※認識しにくい語の例
* 寵臣(調子)、出納官(水筒感)など他の一般語に含まれやすい語
* 岐路(木)、馬丁(バテー)、鉄工所(鉄工場)など語尾の音が弱い語
* 執事(羊)など活舌によって揺れやすい語

## 実行例

```python
from faster_whisper import WhisperModel
from transformers import WhisperForConditionalGeneration, WhisperProcessor

from datasets import load_dataset, DatasetDict, Dataset
from datasets import Audio

MODEL_PATH = "trained_model" # ローカルにダウンロードしたketman/whisper_for_dominionの入ったフォルダ
fileList = ["out_4315_1.wav","out_4369_1.wav","out_4436_1.wav","out_4494_1.wav","out_4557_1.wav"]

processor = WhisperProcessor.from_pretrained("openai/whisper-large", language="Japanese", task="transcribe")

# チューニング済モデルを定義
model = WhisperForConditionalGeneration.from_pretrained(MODEL_PATH)
model.config.forced_decoder_ids = processor.get_decoder_prompt_ids(language = "ja", task = "transcribe")
model.config.suppress_tokens = []

# Dataset準備
common_voice = DatasetDict()
common_voice["train"] = Dataset.from_dict({"audio": fileList}).cast_column("audio", Audio(sampling_rate=16000))

# Whisper実行(transcription)
for i in range(len(common_voice["train"])):
    inputs = processor(common_voice["train"][i]["audio"]["array"], return_tensors="pt")
    input_features = inputs.input_features

    generated_ids = model.generate(inputs=input_features)

    transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]

    print(transcription)
```

# 参考文献
[自作データセットでWhisperをファインチューニングしたら、独自用語だらけのクラロワ実況でも使えるようになった:「ファインチューニング編」](https://zenn.dev/k_sone/articles/4d137d58dd06a6)