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
7 changes: 4 additions & 3 deletions .github/workflows/native-transformers-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Native Transformers examples

on:
pull_request:
paths: ['README*.md', 'examples/**', 'tests/**', '.github/workflows/native-transformers-examples.yml']
paths: ['README*.md', 'examples/**', 'tests/**', 'client_test.py', '.github/workflows/native-transformers-examples.yml']
push:
branches: [main, 'codex/transformers-first-*']
paths: ['README*.md', 'examples/**', 'tests/**', '.github/workflows/native-transformers-examples.yml']
paths: ['README*.md', 'examples/**', 'tests/**', 'client_test.py', '.github/workflows/native-transformers-examples.yml']

permissions:
contents: read
Expand All @@ -20,9 +20,10 @@ jobs:
with:
python-version: '3.12'
- name: Install model-free test dependencies
run: python -m pip install 'numpy==1.26.4' 'librosa==0.11.0' 'soundfile==0.13.1' 'pytest==8.4.2'
run: python -m pip install 'numpy==1.26.4' 'librosa==0.11.0' 'soundfile==0.13.1' 'pytest==8.4.2' 'websockets==16.0'
- name: Validate examples and documentation without downloading weights
run: >-
python -m pytest -q tests/test_transformers_quickstart.py
tests/test_examples_smoke.py tests/test_funasr_requirement.py
tests/test_timestamp_documentation.py tests/test_moss_ecosystem_docs.py
tests/test_streaming_client_collection.py
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Fun-ASR

「[简体中文](README_zh.md)」|「English」|「[日本語](README_ja.md)」|「[한국어](README_ko.md)」
「[简体中文](README_zh.md)」|「English」|「[日本語](README_ja.md)」|「[한국어](README_ko.md)」|「[Tiếng Việt](README_vi.md)」

Fun-ASR is a family of end-to-end speech recognition models from Tongyi Lab. Checkpoint capabilities are distinct: Fun-ASR-Nano-2512 is trained on tens of millions of hours of speech and supports Chinese, English, Japanese, and Chinese dialects and accents; Fun-ASR-MLT-Nano-2512 is an 800M multilingual checkpoint trained on hundreds of thousands of hours and supports 31 languages. Both checkpoints integrate with FunASR for inference and serving.

Expand Down
2 changes: 1 addition & 1 deletion README_ja.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Fun-ASR

「[简体中文](README_zh.md)」|「[English](README.md)」|「日本語」
「[简体中文](README_zh.md)」|「[English](README.md)」|「日本語」|「[Tiếng Việt](README_vi.md)」

> **FunASR 1.4.15:** 現在の Python リリースで、source install、MOSS の導線、realtime / industrial deployment を提供します。`python -m pip install -U "funasr==1.4.15"`。[Release ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.15) · [Runtime v0.2.6 ->](https://github.com/modelscope/FunASR/releases/tag/runtime-llamacpp-v0.2.6)

Expand Down
2 changes: 1 addition & 1 deletion README_ko.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Fun-ASR

「[简体中文](README_zh.md)」|「[English](README.md)」|「[日本語](README_ja.md)」|「한국어」
「[简体中文](README_zh.md)」|「[English](README.md)」|「[日本語](README_ja.md)」|「한국어」|「[Tiếng Việt](README_vi.md)」

> **FunASR 1.4.15:** 현재 Python 릴리스로 source install, MOSS 탐색 경로, realtime / industrial deployment를 제공합니다. `python -m pip install -U "funasr==1.4.15"`. [Release ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.15) · [Runtime v0.2.6 ->](https://github.com/modelscope/FunASR/releases/tag/runtime-llamacpp-v0.2.6)

Expand Down
461 changes: 461 additions & 0 deletions README_vi.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Fun-ASR

「简体中文」|「[English](README.md)」
「简体中文」|「[English](README.md)」|「[Tiếng Việt](README_vi.md)」

Fun-ASR 是通义实验室推出的端到端语音识别模型家族,不同 checkpoint 的能力范围不同:Fun-ASR-Nano-2512 基于数千万小时语音训练,支持中文、英文、日文及中文方言和地域口音;Fun-ASR-MLT-Nano-2512 是基于数十万小时多语种语音训练的 8 亿参数 checkpoint,支持 31 种语言。两者均可通过 FunASR 完成推理与服务部署。

Expand Down
12 changes: 6 additions & 6 deletions client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def load_audio(file_path):
return audio.astype(np.float32)


async def test_basic(server, audio, hotwords=None):
async def check_basic(server, audio, hotwords=None):
"""Test basic streaming ASR flow."""
print("=" * 60)
print("TEST: Basic Streaming ASR")
Expand Down Expand Up @@ -136,7 +136,7 @@ async def test_basic(server, audio, hotwords=None):
return True


async def test_empty_audio(server):
async def check_empty_audio(server):
"""Test with very short/empty audio."""
print("\n" + "=" * 60)
print("TEST: Empty/Short Audio Handling")
Expand Down Expand Up @@ -167,7 +167,7 @@ async def test_empty_audio(server):
return True


async def test_multiple_sessions(server, audio):
async def check_multiple_sessions(server, audio):
"""Test multiple consecutive sessions on same connection."""
print("\n" + "=" * 60)
print("TEST: Multiple Sessions")
Expand Down Expand Up @@ -210,9 +210,9 @@ async def run_tests(args):
failed = 0

tests = [
("Basic Streaming", lambda: test_basic(args.server, audio, args.hotwords)),
("Empty Audio", lambda: test_empty_audio(args.server)),
("Multiple Sessions", lambda: test_multiple_sessions(args.server, audio)),
("Basic Streaming", lambda: check_basic(args.server, audio, args.hotwords)),
("Empty Audio", lambda: check_empty_audio(args.server)),
("Multiple Sessions", lambda: check_multiple_sessions(args.server, audio)),
]

for name, test_fn in tests:
Expand Down
2 changes: 1 addition & 1 deletion docs/finetune.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Finetune

「[简体中文](finetune_zh.md)」|「English」
「[简体中文](finetune_zh.md)」|「English」|「[Tiếng Việt](finetune_vi.md)」

## Requirements

Expand Down
122 changes: 122 additions & 0 deletions docs/finetune_vi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Tinh chỉnh (Finetune)

「[简体中文](finetune_zh.md)」|「[English](finetune.md)」|「Tiếng Việt」

## Yêu cầu

```
pip install "funasr>=1.3.26"
```

## Chuẩn bị dữ liệu

Ví dụ dữ liệu

```
head -n1 data/train_example.jsonl | jq

{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "语音转写:<|startofspeech|>!https://modelscope.cn/datasets/FunAudioLLM/funasr-demo/resolve/master/audios/IT0011W0002.wav<|endofspeech|>"
},
{
"role": "assistant",
"content": "几点了?"
}
],
"speech_length": 145,
"text_length": 3
}
```

Xem đầy đủ tại `data/train_example.jsonl`

Mô tả:

- Nội dung của `system` cố định là `You are a helpful assistant.`
- Nội dung của `user` gồm câu lệnh (prompt) và đường dẫn tới file audio (đặt giữa `<|startofspeech|>!` và `<|endofspeech|>`).
- Prompt mặc định là `语音转写:` và `Speech transcription: `.
- Với từng ngôn ngữ tương ứng, có thể kết hợp prompt, ví dụ `语音转写成英文:` và `Transcribe speech into Chinese: `.
- Khi nhãn văn bản của file audio không chứa chữ số Ả Rập hoặc dấu câu, có thể dùng `语音转写,不进行文本规整:` và `Speech transcription without text normalization: `.
- Nội dung của `assistant` là nhãn văn bản (bản phiên âm) của file audio.
- speech_length: Số khung fbank của file audio (mỗi khung 10ms).
- text_length: Số token trong nhãn văn bản của file audio (mã hóa bằng `Qwen/Qwen3-0.6B`).

- `messages[2]["content"]`: bản phiên âm
- `speech_length`: số khung fbank của file audio
- `text_length`: số token của bản phiên âm (tách token bằng `Qwen3-0.6B`)

Chúng tôi cung cấp công cụ chuyển đổi định dạng dữ liệu `scp2jsonl.py`, có thể chuyển các định dạng dữ liệu huấn luyện nhận dạng giọng nói phổ biến như wav scp và file phiên âm sang định dạng ChatML.

`train_wav.scp`

```
BAC009S0764W0121 https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/BAC009S0764W0121.wav
BAC009S0916W0489 https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/BAC009S0916W0489.wav
```

`train_text.txt`

```
BAC009S0764W0121 甚至出现交易几乎停滞的情况
BAC009S0916W0489 湖北一公司以员工名义贷款数十员工负债千万
```

```
python tools/scp2jsonl.py \
++scp_file=data/train_wav.scp \
++transcript_file=data/train_text.txt \
++jsonl_file=data/train_example.jsonl
```

## Tinh chỉnh

Sửa các tham số `audio_encoder_conf.freeze`, `audio_adaptor_conf.freeze` và `llm_conf.freeze` trong `finetune.sh`.

Đặt tham số `freeze` của các mô-đun cần tinh chỉnh thành false (mặc định chỉ tinh chỉnh LLM).

Để biết thêm chi tiết về các tham số, tham khảo: [Huấn luyện và kiểm thử mô hình SenseVoice](https://github.com/modelscope/FunASR/blob/main/docs/tutorial/README.md#Model%20Training%20and%20Testing)

```
bash finetune.sh
```

### Cấu hình khuyến nghị

- Với dữ liệu huấn luyện dưới 1000 giờ, nên tinh chỉnh audio_adaptor.
- Với dữ liệu huấn luyện dưới 5000 giờ, nên tinh chỉnh audio_encoder và audio_adaptor.
- Với dữ liệu huấn luyện trên 10000 giờ, nên tinh chỉnh toàn bộ tham số.

## Đánh giá mô hình

Sau khi tinh chỉnh xong, bạn có thể giải mã bằng mô hình mới thông qua script decode.py:

```
python decode.py \
++model_dir=/path/to/finetuned \
++scp_file=data/val_wav.scp \
++output_file=output.txt
```

Sau khi giải mã xong, cần chuẩn hóa văn bản cho cả nhãn và kết quả nhận dạng, rồi tính WER:

```
python tools/whisper_mix_normalize.py data/val_text.txt data/val_norm.txt
python tools/whisper_mix_normalize.py output.txt output_norm.txt
compute-wer data/val_norm.txt output_norm.txt cer.txt
tail -n8 cer.txt
```

Với tiếng Nhật, hãy chuẩn hóa cả hai file sang katakana bằng OpenJTalk trước khi tính
CER. Quy trình chạy bằng một lệnh và các tùy chọn tái lập kết quả được mô tả trong
[Đánh giá CER tiếng Nhật](japanese_cer.md) (tiếng Anh):

```bash
python tools/compute_ja_cer.py data/val_text.txt output.txt japanese_cer.txt
```
2 changes: 1 addition & 1 deletion docs/finetune_zh.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 微调

「简体中文」|「[English](finetune.md)」
「简体中文」|「[English](finetune.md)」|「[Tiếng Việt](finetune_vi.md)」

## 安装训练环境

Expand Down
Loading
Loading