3 Star 20 Fork 9

zhyqieqie/SenseVoice

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
demo2.py 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
可渊 提交于 2024-11-29 15:13 . add support for timestamp
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
# Copyright FunASR (https://github.com/FunAudioLLM/SenseVoice). All Rights Reserved.
# MIT License (https://opensource.org/licenses/MIT)
from model import SenseVoiceSmall
from funasr.utils.postprocess_utils import rich_transcription_postprocess
model_dir = "iic/SenseVoiceSmall"
m, kwargs = SenseVoiceSmall.from_pretrained(model=model_dir, device="cuda:0")
m.eval()
res = m.inference(
data_in=f"{kwargs['model_path']}/example/en.mp3",
language="auto", # "zh", "en", "yue", "ja", "ko", "nospeech"
use_itn=False,
ban_emo_unk=False,
**kwargs,
)
text = rich_transcription_postprocess(res[0][0]["text"])
print(text)
res = m.inference(
data_in=f"{kwargs['model_path']}/example/en.mp3",
language="auto", # "zh", "en", "yue", "ja", "ko", "nospeech"
use_itn=False,
ban_emo_unk=False,
output_timestamp=True,
**kwargs,
)
timestamp = res[0][0]["timestamp"]
text = rich_transcription_postprocess(res[0][0]["text"])
print(text)
print(timestamp)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/zhyqieqie/SenseVoice.git
git@gitee.com:zhyqieqie/SenseVoice.git
zhyqieqie
SenseVoice
SenseVoice
main

搜索帮助

0d507c66 1850385 C8b1a773 1850385