Kotoba-Whisper-Bilingual is a collection of distilled
Whisper models trained for
developed through the collaboration bewteen
Asahi Ushio and
Kotoba Technologies.
Following the original work of distil-whisper (
Robust Knowledge Distillation via Large-Scale Pseudo Labelling),
we employ OpenAI's
Whisper large-v3 as the teacher model for Japanese and English ASR, while we translate the
transcription into English and Japanese by external LLM to obtain training dataset for speech-to-text translation.
We employ
ReazonSpeech for Japanese ASR and Japanese speech to English text translation,
and
Multilingual LibriSpeech for English ASR and English speech to Japanese text translation.
Kotoba-whisper-bilingual's loss objective consists of cross-entropy on both of ASR and translation tasks, while KL divergence loss only for ASR task.
The student model consists the full encoder of the teacher large-v3 model and the decoder with two layers initialized from the first and last layer of the large-v3 model.
As kotoba-whisper uses the same architecture as
distil-whisper/distil-large-v3,
it inherits the benefit of the improved latency compared to
openai/whisper-large-v3
(
6.3x faster than large-v3, see the table below taken from
distil-whisper/distil-large-v3).
We compare our kotoba-whisper-bilingual with OpenAI whisper models, kotoba-whisper models, and cascaded models for translation.
Worth noting that kotoba-whisper-bilingual is the only model that can do Japanese and English ASR and speech-to-text translation between Japanese and English, as
OpenAI whisper is not trained for English to Japanese speech-to-text translation, and other models are specific to the Task (eg. kotoba-whisper is Japanese ASR and
distil whisper is English ASR only).
Although the cascaded approach is better in translation task, due to the nature of cascaded approach, the pipeline
has additional complexity and memory consumption compared to the single end2end models for the sake of high accuracy.
Following table shows the mean inference time on a single RTX 4090 (VRAM 24 GB) in second averaged over 10 trials on audio sample with different durations, along with the parameter size.
Kotoba-Whisper is supported in the Hugging Face 🤗 Transformers library from version 4.39 onwards. To run the model, first
install the latest version of Transformers.
1pip install --upgrade pip
2pip install --upgrade transformers accelerate
The model can be used with the
pipeline
class to transcribe short-form audio files (< 30-seconds) as follows:
Download sample audio.
1wget https://huggingface.co/datasets/japanese-asr/en_asr.esb_eval/resolve/main/sample.wav -O sample_en.wav
2wget https://huggingface.co/datasets/japanese-asr/ja_asr.jsut_basic5000/resolve/main/sample.flac -O sample_ja.flac
1import torch
2from transformers import pipeline
3from datasets import load_dataset
4
5# config
6torch_dtype = torch.bfloat16 if torch.cuda.is_available() else torch.float32
7device = "cuda:0" if torch.cuda.is_available() else "cpu"
8model_kwargs = {"attn_implementation": "sdpa"} if torch.cuda.is_available() else {}
9pipe = pipeline(
10 "automatic-speech-recognition",
11 model="kotoba-tech/kotoba-whisper-bilingual-v1.0",
12 torch_dtype=torch_dtype,
13 device=device,
14 model_kwargs=model_kwargs,
15 chunk_length_s=15,
16 batch_size=16
17)
18
19# Japanese ASR
20generate_kwargs = {"language": "ja", "task": "transcribe"}
21result = pipe("sample_ja.flac", generate_kwargs=generate_kwargs)
22print(result["text"])
23
24# English ASR
25generate_kwargs = {"language": "en", "task": "transcribe"}
26result = pipe("sample_en.wav", generate_kwargs=generate_kwargs)
27print(result["text"])
28
29# Translate Japanese speech to English text
30generate_kwargs = {"language": "en", "task": "translate"}
31result = pipe("sample_ja.flac", generate_kwargs=generate_kwargs)
32print(result["text"])
33
34# Translate English speech to Japanese text
35generate_kwargs = {"language": "ja", "task": "translate"}
36result = pipe("sample_en.wav", generate_kwargs=generate_kwargs)
37print(result["text"])
1result = pipe(sample, return_timestamps=True, generate_kwargs=generate_kwargs)
2print(result["chunks"])
Please refer to
https://github.com/kotoba-tech/kotoba-whisper for the model training detail.
Datasets used in distillation and the whole model variations can be found at
https://huggingface.co/japanese-asr.