SenseVoice 音频转文字&情绪识别 - python 实现

具体代码实现如下:

python 复制代码
from funasr import AutoModel
from funasr.utils.postprocess_utils import rich_transcription_postprocess

path_audio = "emo/happy.mp3"# 音频文件
# 加载模型
model_dir = "iic/SenseVoiceSmall"
model = AutoModel(
    model=model_dir,
    trust_remote_code=True,
    remote_code="./model.py",
    vad_model="fsmn-vad",
    vad_kwargs={"max_single_segment_time": 30000},
    device="cuda:0",
    cache_dir = "./ckpt"
)
# 模型预测识别
res = model.generate(
    input=path_audio,
    cache={},
    language="auto",  # "zn", "en", "yue", "ja", "ko", "nospeech"
    use_itn=True,
    batch_size_s=60,
    merge_vad=True,  #
    merge_length_s=15,
)
# text = rich_transcription_postprocess(res[0]["text"])
print("音频文件:{}".format(path_audio))
print("识别预测结果:{}".format(res[0]["text"]))

脚本运行log如下:

python 复制代码
音频文件:emo/happy.mp3
识别预测结果:<|zh|><|HAPPY|><|Speech|><|withitn|>你好,见到你很高兴。

​​​

助力快速掌握数据集的信息和使用方式。

数据可以如此美好!

相关推荐
weixin_462446234 分钟前
基于 Flask + lunar-python 的农历转换 API 实战(公历 ↔ 农历 / 干支 / 生肖 / 节日)
python·flask·节日
安卓程序员_谢伟光5 分钟前
如何监听System.exit(0)的调用栈
java·服务器·前端
城市直通车12 分钟前
聚焦产业落地与生态共建小拼AI携手火山引擎共推AIGC电商智能化升级
人工智能·aigc·火山引擎
Xの哲學16 分钟前
从硬中断到 softirq:Linux 软中断机制的全景解剖
linux·服务器·网络·算法·边缘计算
weixin_5795996617 分钟前
编写一个程序,输入两个数字的加减乘除余数(Python版)
开发语言·python
傻啦嘿哟18 分钟前
深度学习破解复杂验证码:CNN实战指南
人工智能·深度学习·cnn
liu****20 分钟前
02_Pandas_数据结构
数据结构·python·pandas·python基础
人工智能培训32 分钟前
深度学习—卷积神经网络(4)
人工智能·深度学习·神经网络·机器学习·cnn·dnn
RFCEO40 分钟前
用手机写 Python程序解决方案
开发语言·python·智能手机·qpython环境安装
0思必得040 分钟前
[Web自动化] Requests模块基本使用
运维·前端·python·自动化·html·web自动化