项目简介
本项目是基于Python的Whisper语音大模型多任务微调框架,能对Whisper语音大模型进行多任务微调。支持多语种的转录(ASR)以及多语种到英文的翻译(AST)任务,可利用预训练的Whisper模型,通过微调优化模型以适应特定语言或任务需求。
项目的主要特性和功能
- 多任务微调:可同时针对转录和翻译任务进行微调,提升模型通用性与性能。
- 多语种支持:支持多语种的输入与输出,适用于多种语言环境下的语音识别和翻译工作。
- 灵活配置:借助配置文件,用户能灵活设定微调任务、数据路径以及模型参数等。
- 高性能训练:可利用GPU加速训练流程,提高训练效率。
- 模型转换:支持将微调后的模型转换为CTranslate2格式,便于模型的应用与部署。
安装使用步骤
1. 复制项目
bash
2. 创建Conda环境
bash
conda create -n whisper python=3.8
conda activate whisper
3. 配置环境
bash
bash set_env.sh
4. 下载Whisper模型
可选择下载whisper-large-v2
模型:
bash
git clone https://huggingface.co/openai/whisper-large-v2
cd whisper-large-v2
git lfs fetch
git lfs checkout
也可以尝试使用whisper-base
模型:
bash
git clone https://huggingface.co/openai/whisper-base
cd whisper-base
git lfs fetch
git lfs checkout
5. 数据准备
准备转录数据(参考data/transcribe/{wav.scp,text}
)和翻译数据(参考data/translate/{wav.scp,text}
),并将两者数据合并:
bash
cat data/transcribe/wav.scp data/translate/wav.scp > data/wav.scp
cat data/transcribe/text data/translate/text > data/text
6. 修改配置文件
编辑config/whisper_multitask.yaml
,设置训练、验证和测试数据路径,指定模型保存路径等。
7. 训练模型
bash
python3 train.py
8. 测试模型
bash
python3 predict.py
9. 使用CTranslate2加速模型
```python from whisper.utils.common_utils import convert_finetuning_peft_model_into_whisper
convert_finetuning_peft_model_into_whisper( peft_model_path=config['predict']['model_path'], ori_model_path=config['dev_env']['ori_model_path'], ctranslate_model_path=config['dev_env']['ctranslate_model_path'] ) ```
注意:该项目运行需要特定依赖库和环境,如PyTorch、Hugging Face Transformers、CTranslate2等。运行前请确保已正确安装这些依赖库,并按项目要求设置环境。
下载地址
点击下载 【提取码: 4003】【解压密码: www.makuang.net】