Views
No views yet
pipeline. The new features includes
adding punctuation with punctuators.
These libraries are merged into Kotoba-Whisper-v1.1 via pipeline and will be applied seamlessly to the predicted transcription from kotoba-tech/kotoba-whisper-v1.0.
The pipeline has been developed through the collaboration between Asahi Ushio and Kotoba Technologies| model | CommonVoice 8 (Japanese test set) | JSUT Basic 5000 | ReazonSpeech (held out test set) |
|---|---|---|---|
| kotoba-tech/kotoba-whisper-v2.0 | 17.6 | 15.4 | 17.4 |
| kotoba-tech/kotoba-whisper-v2.1 | 17.7 | 15.4 | 17 |
| kotoba-tech/kotoba-whisper-v1.0 | 17.8 | 15.2 | 17.8 |
| kotoba-tech/kotoba-whisper-v1.1 | 17.9 | 15 | 17.8 |
| openai/whisper-large-v3 | 15.3 | 13.4 | 20.5 |
| openai/whisper-large-v2 | 15.9 | 10.6 | 34.6 |
| openai/whisper-large | 16.6 | 11.3 | 40.7 |
| openai/whisper-medium | 17.9 | 13.1 | 39.3 |
| openai/whisper-base | 34.5 | 26.4 | 76 |
| openai/whisper-small | 21.5 | 18.9 | 48.1 |
| openai/whisper-tiny | 58.8 | 38.3 | 153.3 |
| model | return_timestamps | time (mean) |
|---|---|---|
| kotoba-tech/kotoba-whisper-v1.0 | False | 10.8 |
| kotoba-tech/kotoba-whisper-v1.0 | True | 15.7 |
| kotoba-tech/kotoba-whisper-v1.1 (punctuator + stable-ts) | True | 17.9 |
| kotoba-tech/kotoba-whisper-v1.1 (punctuator) | True | 17.7 |
| kotoba-tech/kotoba-whisper-v1.1 (stable-ts) | True | 16.1 |
| openai/whisper-large-v3 | False | 29.1 |
| openai/whisper-large-v3 | True | 37.9 |
1pip install --upgrade pip
2pip install --upgrade transformers accelerate torchaudio
3pip install stable-ts==2.16.0
4pip install punctuators==0.0.5pipeline
class to transcribe audio files as follows:1import torch
2from transformers import pipeline
3from datasets import load_dataset
4
5# config
6model_id = "kotoba-tech/kotoba-whisper-v1.1"
7torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
8device = "cuda:0" if torch.cuda.is_available() else "cpu"
9model_kwargs = {"attn_implementation": "sdpa"} if torch.cuda.is_available() else {}
10generate_kwargs = {"language": "ja", "task": "transcribe"}
11
12# load model
13pipe = pipeline(
14 model=model_id,
15 torch_dtype=torch_dtype,
16 device=device,
17 model_kwargs=model_kwargs,
18 batch_size=16,
19 trust_remote_code=True,
20 punctuator=True
21)
22
23# load sample audio
24dataset = load_dataset("japanese-asr/ja_asr.reazonspeech_test", split="test")
25sample = dataset[0]["audio"]
26
27# run inference
28result = pipe(sample, chunk_length_s=15, return_timestamps=True, generate_kwargs=generate_kwargs)
29print(result)1- result = pipe(sample, return_timestamps=True, generate_kwargs=generate_kwargs)
2+ result = pipe("audio.mp3", return_timestamps=True, generate_kwargs=generate_kwargs)1- punctuator=True,
2+ punctuator=False,1import re
2import torch
3from transformers import pipeline
4from datasets import load_dataset
5
6# config
7model_id = "kotoba-tech/kotoba-whisper-v1.1"
8torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
9device = "cuda:0" if torch.cuda.is_available() else "cpu"
10model_kwargs = {"attn_implementation": "sdpa"} if torch.cuda.is_available() else {}
11generate_kwargs = {"language": "japanese", "task": "transcribe"}
12
13# load model
14pipe = pipeline(
15 model=model_id,
16 torch_dtype=torch_dtype,
17 device=device,
18 model_kwargs=model_kwargs,
19 batch_size=16,
20 trust_remote_code=True
21)
22
23# load sample audio
24dataset = load_dataset("japanese-asr/ja_asr.reazonspeech_test", split="test")
25
26# --- Without prompt ---
27text = pipe(dataset[10]["audio"], chunk_length_s=15, generate_kwargs=generate_kwargs)['text']
28print(text)
29# 81歳、力強い走りに変わってきます。
30
31# --- With prompt ---: Let's change `81` to `91`.
32prompt = "91歳"
33generate_kwargs['prompt_ids'] = pipe.tokenizer.get_prompt_ids(prompt, return_tensors="pt").to(device)
34text = pipe(dataset[10]["audio"], generate_kwargs=generate_kwargs)['text']
35# currently the pipeline for ASR appends the prompt at the beginning of the transcription, so remove it
36text = re.sub(rf"\A\s*{prompt}\s*", "", text)
37print(text)
38# あっぶったでもスルガさん、91歳、力強い走りに変わってきます。pip install flash-attn --no-build-isolationattn_implementation="flash_attention_2" to from_pretrained:1- model_kwargs = {"attn_implementation": "sdpa"} if torch.cuda.is_available() else {}
2+ model_kwargs = {"attn_implementation": "flash_attention_2"} if torch.cuda.is_available() else {}