Skip to content

Commit a688976

Browse files
committed
Add CI workflow for testing and update model registration
1 parent c788686 commit a688976

File tree

5 files changed

+98
-20
lines changed

5 files changed

+98
-20
lines changed

.github/workflows/test.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches: [ main, dev, develop ]
6+
pull_request:
7+
branches: [ main, dev, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
name: Test on ${{ matrix.os }} with Python ${{ matrix.python-version }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
python-version: ['3.10', '3.11', '3.12']
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
submodules: recursive
24+
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Cache pip dependencies
31+
uses: actions/cache@v4
32+
with:
33+
path: ~/.cache/pip
34+
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
35+
restore-keys: |
36+
${{ runner.os }}-pip-
37+
38+
- name: Install & Model Test
39+
run: |
40+
python -m pip install --upgrade pip setuptools wheel
41+
pip install -e .
42+
python tests/model_test.py
43+
44+
45+
- name: Install & Model/funasr Test
46+
run: |
47+
pip install -e .[test]
48+
python tests/funasr_model_test.py

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ omnisense benchmark -s --num-workers 4 --device-id 0 --batch-size 16 --textnorm
6161
Set up pre-commit hooks:
6262

6363
```
64-
pip install pre-commit==3.6.0
64+
pip install pre-commit==4.2.0
6565
pre-commit install
6666
```
6767

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@
2020
readme="README.md",
2121
python_requires=">=3.8",
2222
install_requires=[
23+
"kaldi-native-fbank",
2324
"modelscope>=1.18.0",
2425
"funasr>=1.1.6",
2526
"lhotse>=1.24.2",
2627
"kaldialign",
2728
"torch",
29+
"torchaudio",
2830
],
2931
extras_require={
3032
"test": [
33+
"onnxscript",
3134
"funasr_onnx==0.4.1",
3235
],
3336
},
@@ -42,6 +45,7 @@
4245
"Programming Language :: Python :: 3.11",
4346
"Programming Language :: Python :: 3.12",
4447
"Programming Language :: Python :: 3.13",
48+
"Programming Language :: Python :: 3.14",
4549
"Intended Audience :: Science/Research",
4650
"Operating System :: POSIX :: Linux",
4751
"Operating System :: MacOS :: MacOS X",

tests/funasr_model_test.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import time
2+
3+
import torch
4+
from funasr_onnx import SenseVoiceSmall
5+
from funasr_onnx.utils.postprocess_utils import rich_transcription_postprocess
6+
7+
from omnisense import OmniSenseVoiceSmall
8+
9+
model_dir = "iic/SenseVoiceSmall"
10+
model = SenseVoiceSmall(model_dir, batch_size=10, quantize=False, device_id=1)
11+
12+
# inference
13+
wav_or_scp = ["tests/data/example.wav"]
14+
for textnorm in ["woitn", "withitn"]:
15+
print(f"\n====== Text normalization: {textnorm} ======")
16+
start_time = time.time()
17+
res = model(wav_or_scp, language="auto", textnorm=textnorm)
18+
print(f"Time cost: {time.time() - start_time:.2f}s")
19+
20+
print(res)
21+
print([rich_transcription_postprocess(i) for i in res])
22+
23+
24+
model_dir = "iic/SenseVoiceSmall"
25+
model = OmniSenseVoiceSmall(model_dir, quantize=False, device_id=0 if torch.cuda.is_available() else -1)
26+
27+
28+
# inference
29+
wav_or_scp = ["tests/data/Laughter.wav", "tests/data/Cry.wav", "tests/data/Applause.wav"]
30+
for textnorm in ["woitn", "withitn"]:
31+
print(f"\n====== Text normalization: {textnorm} ======")
32+
start_time = time.time()
33+
res = model.transcribe(wav_or_scp, language="auto", textnorm=textnorm, timestamps=True)
34+
print(f"Time cost: {time.time() - start_time:.2f}s")
35+
print(res)
36+
37+
38+
wav_or_scp = ["tests/data/example.wav"]
39+
for textnorm in ["woitn", "withitn"]:
40+
print(f"\n====== Text normalization: {textnorm} ======")
41+
start_time = time.time()
42+
res = model.transcribe(wav_or_scp, language="auto", textnorm=textnorm, timestamps=True)
43+
print(f"Time cost: {time.time() - start_time:.2f}s")
44+
print(res)

tests/model_test.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
11
import time
22

33
import torch
4-
from funasr_onnx import SenseVoiceSmall
5-
from funasr_onnx.utils.postprocess_utils import rich_transcription_postprocess
6-
7-
from omnisense import OmniSenseVoiceSmall, OmniTranscription
8-
9-
model_dir = "iic/SenseVoiceSmall"
10-
model = SenseVoiceSmall(model_dir, batch_size=10, quantize=False, device_id=1)
11-
12-
# inference
13-
wav_or_scp = ["tests/data/example.wav"]
14-
for textnorm in ["woitn", "withitn"]:
15-
print(f"\n====== Text normalization: {textnorm} ======")
16-
start_time = time.time()
17-
res = model(wav_or_scp, language="auto", textnorm=textnorm)
18-
print(f"Time cost: {time.time() - start_time:.2f}s")
19-
20-
print(res)
21-
print([rich_transcription_postprocess(i) for i in res])
224

5+
from omnisense import OmniSenseVoiceSmall
236

247
model_dir = "iic/SenseVoiceSmall"
258
model = OmniSenseVoiceSmall(model_dir, quantize=False, device_id=0 if torch.cuda.is_available() else -1)
@@ -42,4 +25,3 @@
4225
res = model.transcribe(wav_or_scp, language="auto", textnorm=textnorm, timestamps=True)
4326
print(f"Time cost: {time.time() - start_time:.2f}s")
4427
print(res)
45-

0 commit comments

Comments
 (0)