Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 51 additions & 21 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,68 @@
# This workflow will upload a Python Package to PyPI when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Deploy

on:
release:
types:
- published
types: [published]

permissions:
contents: read

jobs:
build:
if: github.repository == 'lovemefan/SenseVoice-python'
runs-on: ubuntu-20.04
release-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- run: |
git fetch --prune --unshallow
- uses: actions/checkout@v6

- name: Set up Python 3.8
uses: actions/setup-python@v1
- uses: actions/setup-python@v6
with:
python-version: 3.8
python-version: "3.13"

- name: Install dependencies
- name: Build release distributions
run: |
python -m pip install -U pip
python -m pip install -U twine wheel
python -m pip install -U twine wheel build
python -m build
twine check dist/*

- name: Build package
run: |
python setup.py sdist bdist_wheel
twine check dist/*
- name: Upload distributions
uses: actions/upload-artifact@v7
with:
name: release-dists
path: dist/

pypi-publish:
if: github.repository == 'lovemefan/SenseVoice-python'
runs-on: ubuntu-latest
needs:
- release-build
permissions:
id-token: write

environment:
name: pypi
# OPTIONAL: uncomment to include your PyPI project URL in the deployment status:
# url: https://pypi.org/project/sensevoice-onnx/

steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v8
with:
name: release-dists
path: dist/

- name: Publish package to PyPI
if: github.event.action == 'published'
uses: pypa/gh-action-pypi-publish@master
- name: Publish release distributions to PyPI
if: github.event.action == 'published' # doubt this is needed?
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_token }}
password: ${{ secrets.pypi_token }}
packages-dir: dist/
19 changes: 12 additions & 7 deletions .github/workflows/python-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,25 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.11", "3.13"]
exclude:
- os: windows-latest # no wheel for kaldi_native_fbank at time of writing, build fails
python-version: '3.14'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip install -U setuptools wheel
pip3 install -e .
python -m pip install --upgrade pip
python -m pip install -U setuptools wheel onnxruntime
pip install -e .

- name: Test audio
run: |
sensevoice --audio sensevoice/resource/asr_example_zh.wav
sensevoice --audio sensevoice/resource/asr_example_zh.wav
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/dist
/sensevoice_onnx.egg-info
21 changes: 10 additions & 11 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@

[「简体中文」](./README.md)|「English」

[SenseVoice](https://github.com/FunAudioLLM/SenseVoice) is an audio foundation model
with audio understanding capabilities,
including Automatic Speech Recognition (ASR), Language Identification (LID),
Speech Emotion Recognition (SER), and Acoustic Event Classification (AEC)
or Acoustic Event Detection (AED).
---

Currently, SenseVoice-small supports multilingual speech recognition, emotion recognition,
and event detection for Chinese, Cantonese, English, Japanese, and Korean, with extremely low inference latency.
This project provides the necessary ONNX environment installation
and inference methods for the Python version of the SenseVoice model.
[SenseVoice](https://github.com/FunAudioLLM/SenseVoice) is an audio foundation model with audio understanding capabilities, including Automatic Speech Recognition (ASR), Language Identification (LID), Speech Emotion Recognition (SER), and Acoustic Event Classification (AEC) or Acoustic Event Detection (AED).

Currently, SenseVoice-small supports multilingual speech recognition, emotion recognition, and event detection for Chinese, Cantonese, English, Japanese, and Korean, with extremely low inference latency.

This project provides the necessary ONNX environment installation and inference methods for the Python version of the SenseVoice model.

## Usage

### Installation
### Installation

```bash
pip install sensevoice-onnx

# optionally install as sensevoice-onnx[gpu] or sensevoice-onnx[cpu] if you don't already have an onnxruntime installed

# or pip from GitHub
pip install git+https://github.com/lovemefan/SenseVoice-python.git
```
Expand Down Expand Up @@ -54,4 +53,4 @@ optional arguments:
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.
```
```
48 changes: 48 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[build-system]
requires = ["setuptools", "wheel", "build", "twine"]
build-backend = "setuptools.build_meta"

[project]
requires-python = ">= 3.9"
name = "sensevoice-onnx"
version = "1.1.1"
authors = [ {name = "Lovemefan", email = "lovemefan@outlook.com"} ]
description = "SenseVoice-python: open source multi-language asr system from funasr with onnxruntime"
readme = "README-EN.md"
license = "MIT"
dependencies = [
"numpy>=1.24.4",
"kaldi_native_fbank",
"sentencepiece>=0.2.0",
"soundfile>=0.12.1",
"huggingface_hub",
"protobuf>=3.19.6"
]
keywords = ["asr", "speech", "ai", "audio-to-text"]
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Topic :: Multimedia :: Sound/Audio :: Speech",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Software Development :: Libraries :: Python Modules"
]

[project.scripts]
sensevoice = "sensevoice.sense_voice:main"

[project.optional-dependencies]
cpu = ["onnxruntime>=1.17.0"]
gpu = ["onnxruntime-gpu>=1.17.0"]

[project.urls]
Homepage = "https://github.com/lovemefan/SenseVoice-python"
Repository = "https://github.com/lovemefan/SenseVoice-python.git"
12 changes: 12 additions & 0 deletions sensevoice/sense_voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
# @Time :2024/7/18 15:40
# @Author :lovemefan
# @Email :lovemefan@outlook.com

try:
import onnxruntime
except ImportError:
raise ImportError(
"\n\n[SenseVoice Error]: An ONNX Runtime environment was not found.\n"
"Please install your preferred backend:\n"
" - onnxruntime\n"
" - onnxruntime-gpu\n"
" - onnxruntime-directml\n"
)

import argparse
import logging
import os
Expand Down
58 changes: 2 additions & 56 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,6 @@
# @Time :2024/7/19 09:23
# @Author :lovemefan
# @Email :lovemefan@outlook.com
from setuptools import setup


import os
from pathlib import Path

from setuptools import find_namespace_packages, setup

dirname = Path(os.path.dirname(__file__))
version = "1.1.0"

requirements = {
"install": [
"setuptools",
"numpy>=1.24.4",
"kaldi_native_fbank",
"onnxruntime>=1.17.0",
"sentencepiece>=0.2.0",
"soundfile>=0.12.1",
"huggingface_hub",
"protobuf>=3.19.6"
]
}

install_requires = requirements["install"]


setup(
name="sensevoice-onnx",
version=version,
url="https://github.com/lovemefan/SenseVoice-python",
author="Lovemefan",
author_email="lovemefan@outlook.com",
description="SenseVoice-python: A enterprise-grade open source multi-language asr system from funasr opensource "
"with onnxruntime",
long_description=open(os.path.join(dirname, "README.md"), encoding="utf-8").read(),
long_description_content_type="text/markdown",
license="MIT", # SPDX identifier
packages=find_namespace_packages(),
include_package_data=True,
install_requires=install_requires,
python_requires=">=3.8.0",
entry_points={"console_scripts": ["sensevoice=sensevoice.sense_voice:main"]},
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Operating System :: POSIX :: Linux",
"Topic :: Multimedia :: Sound/Audio :: Speech",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Software Development :: Libraries :: Python Modules",
],
)
setup()
Loading