Skip to main content

SenseVoice-python with onnx

「简体中文」|「English」

SenseVoice是具有音频理解能力的音频基础模型, 包括语音识别(ASR)、语种识别(LID)、语音情感识别(SER)和声学事件分类(AEC)或声学事件检测(AED)。

当前SenseVoice-small支持中、粤、英、日、韩语的多语言语音识别,情感识别和事件检测能力,具有极低的推理延迟。 本项目提供python版的SenseVoice模型所需的onnx环境安装的与推理方式。

使用方式

安装

pip install sensevoice-onnx

# or pip from github
pip install git+https://github.com/lovemefan/SenseVoice-python.git

使用

sensevoice --audio sensevoice/resource/asr_example_zh.wav

第一次使用会自动从huggingface下载,如果下载不下来,可以使用hugginface代理

  • Linux:
export HF_ENDPOINT=https://hf-mirror.com
  • Windows Powershell
$env:HF_ENDPOINT = "https://hf-mirror.com"

或者非入侵方式使用环境变量

HF_ENDPOINT=https://hf-mirror.com sensevoice --audio sensevoice/resource/asr_example_zh.wav
Sense Voice 脚本参数设置

optional arguments:
  -h, --help            show this help message and exit
  -a , --audio_file 设置音频路径
  -dp , --download_path 自定义模型下载路径,默认`sensevoice/resource`
  -d , --device, 使用cpu时为-1,使用gpu(需要安装onnxruntime-gpu)时指定卡号 默认`-1`
                        Device
  -n , --num_threads , 线程数, 默认 `4`
                        Num threads
  -l , --language {auto,zh,en,yue,ja,ko,nospeech} 语音代码,默认`auto`
  --use_itn             是否使用itn
  --use_int8            是否使用int8 量化的onnx模型

结果

2024-07-19 07:22:40,643 INFO [sense_voice_ort_session.py:130] Loading model from /home/runner/work/SenseVoice-python/SenseVoice-python/sensevoice/resource/embedding.npy
2024-07-19 07:22:40,647 INFO [sense_voice_ort_session.py:133] Loading model /home/runner/work/SenseVoice-python/SenseVoice-python/sensevoice/resource/sense-voice-encoder.onnx
2024-07-19 07:22:42,755 INFO [sense_voice_ort_session.py:140] Loading /home/runner/work/SenseVoice-python/SenseVoice-python/sensevoice/resource/sense-voice-encoder.onnx takes 2.11 seconds
2024-07-19 07:22:42,786 INFO [sense_voice.py:76] Audio sensevoice/resource/asr_example_zh.wav is 5.58 seconds
2024-07-19 07:22:43,102 INFO [sense_voice.py:81] [0.61s - 5.53s] <|zh|><|NEUTRAL|><|Speech|><|woitn|>欢迎大家来体验达摩院推出的语音识别模型
2024-07-19 07:22:43,102 INFO [sense_voice.py:83] Decoder audio takes 0.31638407707214355 seconds
2024-07-19 07:22:43,103 INFO [sense_voice.py:84] The RTF is 0.05669965538927304.

Release files for sensevoice-onnx 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sensevoice-onnx 1.1.0
File Size Uploaded
sensevoice-onnx-1.1.0.tar.gz 16.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sensevoice-onnx 1.1.0
File Interpreter ABI Platform
sensevoice_onnx-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.2 kB

Release files / sensevoice-onnx-1.1.0.tar.gz

Download URL sensevoice-onnx-1.1.0.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1d121db81dac484edf509f3fbd00f111fb059ad3e84cb2c67b1d969729a42080
BLAKE2b-256 checksum
How to use checksums
9eab99e0326bb19cde81ba050fa1b95e8d0fcc266db747245a83ef96fe30eb80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / sensevoice_onnx-1.1.0-py3-none-any.whl

Download URL sensevoice_onnx-1.1.0-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
490ea1c94ef1d7eaf42b93bee508a31fc6235ea1a95660e9dbde9b378cac7921
BLAKE2b-256 checksum
How to use checksums
1ae6b548989d5a1c8394d45dae9f5eaec0cf0d32f4d85f33c379a6f4f3581cf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page