语言: 日语
库名称: transformers
许可证: apache-2.0
标签:
- 音频
- 自动语音识别
- hf-asr-leaderboard
小部件:
- 示例标题: CommonVoice 8.0 (测试集)
音频源: >-
https://huggingface.co/datasets/japanese-asr/ja_asr.common_voice_8_0/resolve/main/sample.flac
- 示例标题: JSUT Basic 5000
音频源: >-
https://huggingface.co/datasets/japanese-asr/ja_asr.jsut_basic5000/resolve/main/sample.flac
- 示例标题: ReazonSpeech (测试集)
音频源: >-
https://huggingface.co/datasets/japanese-asr/ja_asr.reazonspeech_test/resolve/main/sample.flac
流水线标签: 自动语音识别
数据集:
- japanese-asr/whisper_transcriptions.reazonspeech.all
- japanese-asr/whisper_transcriptions.reazonspeech.all.wer_10.0
- japanese-asr/whisper_transcriptions.reazonspeech.all.wer_10.0.vectorized
Kotoba-Whisper-v2.1
Kotoba-Whisper-v2.1 是一款基于 kotoba-tech/kotoba-whisper-v2.0 的日语自动语音识别(ASR)模型,集成了额外的后处理栈作为 pipeline
。新特性包括通过 punctuators 添加标点符号。这些库通过流水线无缝整合到 Kotoba-Whisper-v2.1 中,并应用于 kotoba-tech/kotoba-whisper-v2.0 的预测转录结果。该流水线由 Asahi Ushio 和 Kotoba Technologies 合作开发。
下表展示了原始字符错误率(CER,与通常去除标点后计算的 CER 不同,评估脚本见此处)及对比数据:
关于标准化 CER,由于 v2.1 的更新会在标准化过程中被移除,kotoba-tech/kotoba-whisper-v2.1 的 CER 值与 kotoba-tech/kotoba-whisper-v2.0 相同。
延迟
请参考 kotoba-whisper-v1.1 中的延迟部分此处。
Transformers 使用
Kotoba-Whisper-v2.1 从 4.39 版本开始在 Hugging Face 🤗 Transformers 库中支持。运行模型前,请先安装最新版本的 Transformers。
pip install --upgrade pip
pip install --upgrade transformers accelerate torchaudio
pip install stable-ts==2.16.0
pip install punctuators==0.0.5
转录
可以使用 pipeline
类转录音频文件,如下所示:
import torch
from transformers import pipeline
from datasets import load_dataset
model_id = "kotoba-tech/kotoba-whisper-v2.1"
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
device = "cuda:0" if torch.cuda.is_available() else "cpu"
model_kwargs = {"attn_implementation": "sdpa"} if torch.cuda.is_available() else {}
generate_kwargs = {"language": "ja", "task": "transcribe"}
pipe = pipeline(
model=model_id,
torch_dtype=torch_dtype,
device=device,
model_kwargs=model_kwargs,
batch_size=16,
trust_remote_code=True,
punctuator=True
)
dataset = load_dataset("japanese-asr/ja_asr.reazonspeech_test", split="test")
sample = dataset[0]["audio"]
result = pipe(sample, chunk_length_s=15, return_timestamps=True, generate_kwargs=generate_kwargs)
print(result)
- 转录本地音频文件时,只需在调用流水线时传递音频文件路径:
- result = pipe(sample, return_timestamps=True, generate_kwargs=generate_kwargs)
+ result = pipe("audio.mp3", return_timestamps=True, generate_kwargs=generate_kwargs)
- punctuator=True,
+ punctuator=False,
Flash Attention 2
如果您的 GPU 支持,我们推荐使用 Flash-Attention 2。首先需要安装 Flash Attention:
pip install flash-attn --no-build-isolation
然后向 from_pretrained
传递 attn_implementation="flash_attention_2"
:
- model_kwargs = {"attn_implementation": "sdpa"} if torch.cuda.is_available() else {}
+ model_kwargs = {"attn_implementation": "flash_attention_2"} if torch.cuda.is_available() else {}
致谢