| 硬件名称 | 配置信息 |
|---|---|
| NPU型号 | 910B |
| 测试集群 | 单机 |
| 操作系统 | X86 |
| 软件 | 版本 |
|---|---|
| Python | 3.11.13 |
| CANN | 8.3.RC1 |
| Torch | 2.8.0 |
| Torch_npu | 2.8.0 |
| transformers | 5.0.0.dev0 |
下载Fun-ASR官方代码用于推理Fun-ASR-Nano-2512模型(https://github.com/FunAudioLLM/Fun-ASR/tree/main)
git clone https://github.com/FunAudioLLM/Fun-ASR.gitcd Fun-ASR
pip install -r requirements.txt
pip install funasr>=1.3.0pip install modelscope
modelscope download --model FunAudioLLM/Fun-ASR-Nano-2512数据格式需要包括如下几个字段:
head -n1 data/train_example.jsonl | jq
{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "语音转写:<|startofspeech|>!https://modelscope.cn/datasets/FunAudioLLM/funasr-demo/resolve/master/audios/IT0011W0002.wav<|endofspeech|>"
},
{
"role": "assistant",
"content": "几点了?"
}
],
"speech_length": 145,
"text_length": 3
}详细可以参考:data/train_example.jsonl
数据准备细节介绍:
You are a helpful assistant.<|startofspeech|>! 和 <|endofspeech|>之间)
语音转写:和Speech transcription: 语音转写成英文:和Transcribe speech into Chinese: 语音转写,不进行文本规整:和 Speech transcription without text normalization: Qwen/Qwen3-0.6B 编码)利用官方代码中的数据格式转换工具 scp2jsonl.py,可以将常见的语音识别训练数据格式 wav scp 和 transcription 转成 ChatML 格式。
train_wav.scp
左边为数据唯一 ID,需与 train_text.txt 中的 ID 一一对应 右边为音频文件的路径,格式如下
BAC009S0764W0121 https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/BAC009S0764W0121.wav
BAC009S0916W0489 https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/BAC009S0916W0489.wavtrain_text.txt
左边为数据唯一 ID,需与 train_wav.scp 中的 ID 一一对应 右边为音频文件标注文本,格式如下:
BAC009S0764W0121 甚至出现交易几乎停滞的情况
BAC009S0916W0489 湖北一公司以员工名义贷款数十员工负债千万python tools/scp2jsonl.py \
++scp_file=data/train_wav.scp \
++transcript_file=data/train_text.txt \
++jsonl_file=data/train_example.jsonl获取trainer路径
which funasr-train-ds例如trainer路径在 /usr/local/python3.11.13/bin/funasr-train-ds,对其进行修改:vim /usr/local/python3.11.13/bin/funasr-train-ds
第一行添加
from torch_npu.contrib import transfer_to_npu移动本项目下的finetune.sh到Fun-ASR代码目录中
mv ../Fun-ASR-Nano-2512-SFT/finetune.sh . 修改 finetune.sh 中的 audio_encoder_conf.freeze, audio_adaptor_conf.freeze 和 llm_conf.freeze。
将需要微调的模块 freeze 设置成 false(默认只微调 llm)。
bash finetune.sh