Update README.md
Browse files
README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
| 1 |
---
|
| 2 |
library_name: peft
|
| 3 |
base_model: openai/whisper-large-v2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
# Model Card for Model ID
|
|
@@ -25,10 +31,38 @@ openai-whisper-large-v2-LORA-ja
|
|
| 25 |
|
| 26 |
## How to Get Started with the Model
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
|
|
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
### Training Data
|
| 34 |
|
|
|
|
| 1 |
---
|
| 2 |
library_name: peft
|
| 3 |
base_model: openai/whisper-large-v2
|
| 4 |
+
datasets:
|
| 5 |
+
- mozilla-foundation/common_voice_16_0
|
| 6 |
+
language:
|
| 7 |
+
- ja
|
| 8 |
+
metrics:
|
| 9 |
+
- wer
|
| 10 |
---
|
| 11 |
|
| 12 |
# Model Card for Model ID
|
|
|
|
| 31 |
|
| 32 |
## How to Get Started with the Model
|
| 33 |
|
| 34 |
+
import torch
|
| 35 |
+
from transformers import (
|
| 36 |
+
AutomaticSpeechRecognitionPipeline,
|
| 37 |
+
WhisperForConditionalGeneration,
|
| 38 |
+
WhisperTokenizer,
|
| 39 |
+
WhisperProcessor,
|
| 40 |
+
)
|
| 41 |
+
from peft import PeftModel, PeftConfig
|
| 42 |
|
| 43 |
+
peft_model_id = "fznx92/openai-whisper-large-v2-ja-transcribe-colab"
|
| 44 |
+
sample = "insert mp3 file location here"
|
| 45 |
|
| 46 |
+
language = "japanese"
|
| 47 |
+
task = "transcribe"
|
| 48 |
+
|
| 49 |
+
peft_config = PeftConfig.from_pretrained(peft_model_id)
|
| 50 |
+
model = WhisperForConditionalGeneration.from_pretrained(
|
| 51 |
+
peft_config.base_model_name_or_path,
|
| 52 |
+
)
|
| 53 |
+
model = PeftModel.from_pretrained(model, peft_model_id)
|
| 54 |
+
model.to("cuda").half()
|
| 55 |
+
|
| 56 |
+
processor = WhisperProcessor.from_pretrained(peft_config.base_model_name_or_path, language=language, task=task)
|
| 57 |
+
|
| 58 |
+
pipe = AutomaticSpeechRecognitionPipeline(model=model, tokenizer=processor.tokenizer, feature_extractor=processor.feature_extractor, batch_size=8, torch_dtype=torch.float16, device="cuda:0")
|
| 59 |
+
|
| 60 |
+
def transcribe(audio, return_timestamps=False):
|
| 61 |
+
text = pipe(audio, chunk_length_s=30, return_timestamps=return_timestamps, generate_kwargs={"language": language, "task": task})["text"]
|
| 62 |
+
return text
|
| 63 |
+
|
| 64 |
+
transcript = transcribe(sample)
|
| 65 |
+
print(transcript)
|
| 66 |
|
| 67 |
### Training Data
|
| 68 |
|