模型名称: AbelZimba/whisper-bemba-stt
模型链接: https://huggingface.co/AbelZimba/whisper-bemba-stt
模型描述: 基于 OpenAI Whisper 的语音转文本(STT)模型,在 Bemba(本巴语)语音数据上微调,输入 16kHz 单声道音频,输出转写文本;对英文等 Whisper 支持语言同样可用。
模型架构: WhisperForConditionalGeneration(encoder-decoder Transformer,12+12 层,d_model=768,80 mel 特征,30s 窗口)
参数规模: ~241.7M(fp32,单分片 model.safetensors 966,995,080 bytes,sha256 校验与 LFS oid 一致)
适配引擎: torch_npu(昇腾 NPU 推理引擎)
标签集合: automatic-speech-recognition / whisper / stt / audio / speech-to-text / NPU / Ascend / torch_npu / model-agent-tagged
| 依赖项 | 版本 | 说明 |
|---|---|---|
| torch | 2.9.0 | |
| torch_npu | 2.9.0.post1 | 昇腾 NPU 推理引擎 |
| transformers | 4.46.3 | 标准格式加载(WhisperForConditionalGeneration + WhisperProcessor),无需 custom code |
| librosa | >= 0.10 | 音频读取与重采样 |
| fastapi / uvicorn / python-multipart | - | 服务化推理(server.py) |
注:本模型为 transformers 标准格式(model.safetensors + config.json + tokenizer.json + preprocessor_config.json),权重与配置放
/tmp/whisper-bemba-stt/。
# 内置示例音频(默认 npu:0)
python inference.py --device npu:0
# 指定音频文件(wav/mp3/flac,自动重采样到 16kHz 单声道)
python inference.py --audio examples/sample.wav --device npu:0
# 纯 CPU 推理(对比验证)
python inference.py --device cpu推理流程:WhisperProcessor(audio, sampling_rate=16000) 提取 log-mel 特征 → WhisperForConditionalGeneration.generate(input_features) 自回归解码 → batch_decode(skip_special_tokens=True) 得到转写文本。
说明:Whisper 语言 token 表不含 Bemba,该微调模型未使用语言强制 token,直接
generate()即可(自动语言检测+转写);如需指定英文可传forced_decoder_ids=processor.get_decoder_prompt_ids(language='english', task='transcribe')。
以下输出为在昇腾 Ascend 910B4(CANN 8.5.1 + torch_npu 2.9.0.post1 + transformers 4.46.3)上实测获得。
命令:
python inference.py --device npu:0输出:
[加载] 完成: WhisperForConditionalGeneration (241.7M params),耗时 3.86s
[输入] examples/sample.wav(4.60s @16kHz)
[结果] 转写文本: The combination of trumpets, violins and a drumset is quite unusual.
[耗时] 7.28s结果说明:首次推理含算子编译预热(约 7s),进程内稳态耗时 0.34s/条(4.6s 音频)。转写结果为连贯、语义正确的英文句子,验证了 whisper-bemba-stt 在昇腾 NPU 上的语音识别链路通畅。
见第 6 节 /asr 实测。

python server.py --port 8000 --device npu:0接口:
GET /health → {"status":"ok","model":"AbelZimba/whisper-bemba-stt","device":"npu:0","loaded":true}POST /asr(multipart:file 音频文件,可选 max_new_tokens)→ 转写文本实测(服务化):
/health → {"status":"ok","model":"AbelZimba/whisper-bemba-stt","device":"npu:0","loaded":true}/asr(sample.wav)→ {"text":"The combination of trumpets, violins and a drumset is quite unusual.","audio_seconds":4.6,"elapsed_s":0.344}/tmp/whisper-bemba-stt/(966,995,080 bytes,sha256 校验通过),不占用仓库空间,不纳入本仓库chunk_length=30);librosa 加载时自动重采样