🚀 用于德语自动语音识别的微调whisper-small模型
本模型是 openai/whisper-small 的微调版本,在 mozilla-foundation/common_voice_11_0 德语数据集上进行训练。使用该模型时,请确保语音输入的采样率为 16Khz。该模型还能预测大小写和标点符号。
属性 |
详情 |
模型类型 |
seq2seq |
模型参数 |
2.44 亿 |
支持语言 |
德语 |

🚀 快速开始
本模型是为德语自动语音识别任务对 whisper-small
进行微调得到的,可用于将德语语音转换为文本。
✨ 主要特性
- 基于
whisper-small
模型微调,适用于德语自动语音识别。
- 能够预测大小写和标点符号。
📦 安装指南
文档未提供安装步骤,可根据 transformers
库的常规安装方法进行安装:
pip install transformers datasets torch torchaudio
💻 使用示例
基础用法
使用 🤗 Pipeline 进行推理:
import torch
from datasets import load_dataset
from transformers import pipeline
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
pipe = pipeline("automatic-speech-recognition", model="bofenghuang/whisper-small-cv11-german", device=device)
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language="de", task="transcribe")
ds_mcv_test = load_dataset("mozilla-foundation/common_voice_11_0", "de", split="test", streaming=True)
test_segment = next(iter(ds_mcv_test))
waveform = test_segment["audio"]
pipe.model.config.max_length = 225 + 1
generated_sentences = pipe(waveform)["text"]
高级用法
使用 🤗 底层 API 进行推理:
import torch
import torchaudio
from datasets import load_dataset
from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
model = AutoModelForSpeechSeq2Seq.from_pretrained("bofenghuang/whisper-small-cv11-german").to(device)
processor = AutoProcessor.from_pretrained("bofenghuang/whisper-small-cv11-german", language="german", task="transcribe")
model.config.forced_decoder_ids = processor.get_decoder_prompt_ids(language="de", task="transcribe")
model_sample_rate = processor.feature_extractor.sampling_rate
ds_mcv_test = load_dataset("mozilla-foundation/common_voice_11_0", "de", split="test", streaming=True)
test_segment = next(iter(ds_mcv_test))
waveform = torch.from_numpy(test_segment["audio"]["array"])
sample_rate = test_segment["audio"]["sampling_rate"]
if sample_rate != model_sample_rate:
resampler = torchaudio.transforms.Resample(sample_rate, model_sample_rate)
waveform = resampler(waveform)
inputs = processor(waveform, sampling_rate=model_sample_rate, return_tensors="pt")
input_features = inputs.input_features
input_features = input_features.to(device)
generated_ids = model.generate(inputs=input_features, max_new_tokens=225)
generated_sentences = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
📚 详细文档
性能
以下是预训练模型在 Common Voice 9.0 上的字错率(WER)。这些结果来自原始 论文。
以下是微调模型在 Common Voice 11.0 上的字错率(WER)。
📄 许可证
本项目采用 Apache-2.0 许可证。