SenseVoice多语言语音理解模型之最新部署落地经验

杰说新技术 2024-08-22 09:31:05 阅读 64

SenseVoice是阿里云通义实验室开发的一款多语言音频基础模型,专注于高精度多语言语音识别、情感辨识和音频事件检测。

SenseVoice支持超过50种语言的识别,并且在中文和粤语上的识别效果优于Whisper模型,提升了50%以上。

SenseVoice具备强大的情感识别能力,能够检测音乐、掌声、笑声、哭声、咳嗽、喷嚏等多种常见人机交互事件。

SenseVoice模型在推理速度上表现出色,其小型模型SenseVoice-Small采用非自回归端到端框架,10秒音频的推理时间仅为70毫秒,比Whisper-large快15倍。

github项目地址:https://github.com/FunAudioLLM/SenseVoice。

一、环境安装

1、python环境

建议安装python版本在3.10以上。

2、库安装

<code>pip install torch==2.0.0+cu118 torchvision==0.15.1+cu118 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu118

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install funasr-onnx gradio -i https://pypi.tuna.tsinghua.edu.cn/simple

为了方便音频处理,还需要安装ffmpeg,命令如下:

apt install ffmpeg

3、SenseVoiceSmall模型下载

git lfs install

git clone https://www.modelscope.cn/iic/SenseVoiceSmall.git

、功能测试

1、运行测试

(1)通过官方model代码进行调用测试

from model import SenseVoiceSmall

import time

import argparse

class VoiceRecognitionModel:

def __init__(self, model_dir="SenseVoiceSmall", device="cpu"):code>

self.model_dir = model_dir

self.device = device

self.model, self.kwargs = SenseVoiceSmall.from_pretrained(model=self.model_dir, device=self.device)

def infer(self, input_file, language="auto", use_itn=False):code>

start_time = time.time()

result = self.model.inference(

data_in=input_file,

language=language,

use_itn=use_itn,

**self.kwargs,

)

elapsed_time_ms = (time.time() - start_time) * 1000

print(f"tts time: {elapsed_time_ms:.2f} ms")

return result

if name == "__main__":

parser = argparse.ArgumentParser()

parser.add_argument('--voice', type=str, default='voice/test1.wav', help='Path to the voice')code>

args = parser.parse_args()

model_dir="SenseVoiceSmall"code>

device="cpu"code>

recognizer = VoiceRecognitionModel(model_dir, device)

result = recognizer.infer(args.voice)

print(result)

(2)通过funasr进行调用测试

未完......

更多详细的内容欢迎关注:杰哥新技术



声明

本文内容仅代表作者观点,或转载于其他网站,本站不以此文作为商业用途
如有涉及侵权,请联系本站进行删除
转载本站原创文章,请注明来源及作者。