Audio Models
Collection
9 items
•
Updated
speech translation demo on Axera
For those who are interested in model conversion, you can try to export axmodel through the original repo : How to Convert from ONNX to axmodel
语音翻译
在python3.10(验证)
支持板端运行及算力卡模式运行
支持两种处理模式:文件处理模式和实时处理模式
git clone https://huggingface.co/AXERA-TECH/Speech-Translation.axera 或者
hf download AXERA-TECH/Speech-Translation.axera --local-dir Speech-Translation.axera
cd Speech-Translation.axera
工程目录文件结构如下:
.
|-- README.md
|-- ax_model
|-- ax_speech_translate_demo_qwen_api.py
|-- ax_speech_translate_demo_qwen_api_realtime.py
|-- config.json
|-- libaxllm
|-- libmelotts
|-- model.py
|-- requirements.txt
|-- utils
`-- wav
板端 demo
1、安装依赖库
1):
如果环境中没有axengine,下载安装
hf download AXERA-TECH/PyAXEngine --local-dir PyAXEngine
cd PyAXEngine
pip3 install axengine-0.1.3-py3-none-any.whl
2):
cd 到工程目录下
pip3 install -r requirements.txt
3):
apt install espeak 或者
sudo apt install espeak
2、模型下载
以Qwen2.5-1.5B为例,下载地址
将下载后的模型拷贝到 libaxllm/qwen2.5-1.5b-ctx-ax650/
3、在开发板运行以下命令
1)、运行qwen api
cd libaxllm
启动支持上下文的 tokenizer 服务器
python3 qwen2.5_tokenizer_uid.py
运行
sh run_qwen2.5_1.5b_ctx_ax650_api.sh
2)、运行pipeline板端demo
cd ..
python3 ax_speech_translate_demo_qwen_api.py --audio_file wav/en.mp3 --api_url http://10.126.29.158:8000 --output_dir output --output_tts output.wav
运行参数说明:
| 参数名称 | 说明|
|-------|------|
| `--audio_file` | 音频路径 |
| `--api_url` | qwen API服务地址,对应其运行服务器 |
| `--output_dir` | 结果保存路径 |
| `--output_tts` | 音频文件名 |
输出保存为wav文件,具体结果如下:
原始音频: wav/en.mp3
原始文本: The tribal chieftain called for the boy and presented him with 50 pieces of gold.
翻译文本: 部落酋长召见了那个男孩,并给了他50枚金币。
生成音频: output/output.wav
4、Latency
AX650N
RTF: 约为0.5
eg:
Inference time for en.mp3: 3.84 seconds
- VAD + ASR processing time: 0.90 seconds
- Translate time: 2.18 seconds
- TTS time: 0.77 seconds
Audio duration: 7.18 seconds
RTF: 0.54
算力卡demo
运行步骤与板端demo大致相同,以x86环境为例:
1、运行qwen api
cd libaxllm
启动支持上下文的 tokenizer 服务器
python3 qwen2.5_tokenizer_uid.py
运行对应环境的api
sh run_qwen2.5_1.5b_ctx_axcl_x86_api.sh
2、运行pipeline算力卡demo
cd ..
python3 ax_speech_translate_demo_qwen_api.py --audio_file wav/en.mp3 --api_url http://10.168.236.41:8000 --output_dir output --output_tts output.wav
aarch64环境运行步骤同上
前置步骤(安装库、模型下载、启动qwen api)与模式一相同,仅运行脚本不同:
python3 ax_speech_translate_demo_qwen_api_realtime.py --audio_file wav/en_6mins.wav --api_url http://10.126.29.158:8000 --output_dir output
运行参数说明:
| 参数名称 | 说明|
|-------|------|
| `--audio_file` | 输入音频文件路径 |
| `--output_dir` | 输出目录 |
| `--api_url` | Qwen API服务器URL |
| `--target_sr` | ASR目标采样率 (默认: 16000) |
| `--chunk_duration` | 音频块时长(秒) (默认: 7.0) |
| `--overlap_duration` | 重叠时长(秒) (默认: 0.01) |
音频依次生成,保存路径如下:
翻译结果已保存到: output/stream_results.txt
生成 52 个TTS音频文件:
- output/stream_segment_0001.wav
- output/stream_segment_0002.wav
- output/stream_segment_0003.wav
...
翻译结果:
----------------------------------------------------------------------
【段落 1】(ID: 1)
原文: Depressed in the eyes of the Lord. I know that all I ever did was believing in me.
译文: 在上帝的眼中,我感到非常沮丧。我知道我所做的所有事,都是相信自己。
音频: output/stream_segment_0001.wav
时间: 15:33:22
【段落 2】(ID: 2)
原文: wholeheartedly, I in jest your spirit through me. I used you as a teaching tool to help others.
译文: 我真心诚意地,通过你来戏弄你的精神。我用你作为教诲的工具,帮助他人。
音频: output/stream_segment_0002.wav
时间: 15:33:26
【段落 3】(ID: 3)
原文: To make sense of their trauma and turmoil. I preached you. I thanked you. I let you in every day of my life.
译文: 为了理解他们的创伤和混乱,我用你作为教诲的工具。我感谢你。我每天让你在我生活中都感到自在。
音频: output/stream_segment_0003.wav
时间: 15:33:32
...
算力卡demo 参考模式一
Base model
FunAudioLLM/SenseVoiceSmall