Audio-Text-to-Text
Transformers
Safetensors
English
Chinese
moss_transcribe_diarize
text-generation
moss
audio
speech
asr
diarization
timestamp-asr
long-form-audio
multimodal
multilingual
custom_code
Instructions to use OpenMOSS-Team/MOSS-Transcribe-Diarize with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenMOSS-Team/MOSS-Transcribe-Diarize with Transformers:
# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("OpenMOSS-Team/MOSS-Transcribe-Diarize", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
Update bilingual model card README
#1
by zylin12 - opened
README.md
ADDED
|
@@ -0,0 +1,459 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- zh
|
| 5 |
+
- en
|
| 6 |
+
library_name: transformers
|
| 7 |
+
pipeline_tag: automatic-speech-recognition
|
| 8 |
+
tags:
|
| 9 |
+
- automatic-speech-recognition
|
| 10 |
+
- speaker-diarization
|
| 11 |
+
- timestamped-transcription
|
| 12 |
+
- long-form-audio
|
| 13 |
+
- audio-to-text
|
| 14 |
+
- multimodal
|
| 15 |
+
- transformers
|
| 16 |
+
- remote-code
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# MOSS-Transcribe-Diarize
|
| 20 |
+
|
| 21 |
+
[English](#english) | [简体中文](#简体中文)
|
| 22 |
+
|
| 23 |
+
## English
|
| 24 |
+
|
| 25 |
+
**MOSS-Transcribe-Diarize** is an end-to-end audio understanding model for long-form, multi-speaker transcription. Given an audio or video file, it generates a compact speaker-aware transcript with timestamps, speaker labels, and transcribed text in one pass.
|
| 26 |
+
|
| 27 |
+
The model is designed for real-world recordings such as meetings, calls, podcasts, interviews, lectures, videos, and other long-form audio scenarios where multiple speakers and long context are common.
|
| 28 |
+
|
| 29 |
+
## Contents
|
| 30 |
+
|
| 31 |
+
- [Introduction](#introduction)
|
| 32 |
+
- [Model Architecture](#model-architecture)
|
| 33 |
+
- [Output Format](#output-format)
|
| 34 |
+
- [Intended Use](#intended-use)
|
| 35 |
+
- [Quickstart](#quickstart)
|
| 36 |
+
- [Evaluation](#evaluation)
|
| 37 |
+
- [Ethical Considerations](#ethical-considerations)
|
| 38 |
+
- [License](#license)
|
| 39 |
+
- [Citation](#citation)
|
| 40 |
+
- [简体中文](#简体中文)
|
| 41 |
+
|
| 42 |
+
## Introduction
|
| 43 |
+
|
| 44 |
+
Long-form speech transcription often requires more than plain ASR. In meetings, calls, podcasts, interviews, lectures, and video content, a useful transcript should answer three questions at the same time: what was said, who said it, and when it was said.
|
| 45 |
+
|
| 46 |
+
MOSS-Transcribe-Diarize is built to unify these capabilities within a single generative model:
|
| 47 |
+
|
| 48 |
+
- **Long-form ASR**: Transcribes long audio and video recordings into text.
|
| 49 |
+
- **Speaker-aware transcription**: Adds anonymous speaker labels such as `[S01]`, `[S02]`, and `[S03]`.
|
| 50 |
+
- **Timestamp prediction**: Produces segment-level start and end timestamps.
|
| 51 |
+
- **Audio/video input**: Supports common audio files and video containers decoded through PyAV.
|
| 52 |
+
- **Promptable generation**: Allows users to customize the transcription instruction.
|
| 53 |
+
|
| 54 |
+
## Model Architecture
|
| 55 |
+
|
| 56 |
+
MOSS-Transcribe-Diarize combines a Whisper-style audio encoder with a Qwen3-style causal language model decoder. Audio is converted into 16 kHz log-mel features, encoded by the audio encoder, merged temporally, projected through an MLP adaptor, and inserted into the language model embedding stream at audio placeholder positions.
|
| 57 |
+
|
| 58 |
+
| Component | Specification |
|
| 59 |
+
|---|---|
|
| 60 |
+
| Text backbone | Qwen3-0.6B style causal decoder |
|
| 61 |
+
| Audio encoder | Whisper-Medium encoder configuration |
|
| 62 |
+
| Audio frontend | `WhisperFeatureExtractor`, 16 kHz, 80 mel bins, 30 s chunks |
|
| 63 |
+
| Audio-text bridge | 4x temporal merge + MLP adaptor |
|
| 64 |
+
| Fusion method | Audio features replace `<|audio_pad|>` embeddings |
|
| 65 |
+
| Output format | Compact `[start][Sxx]text[end]` transcript |
|
| 66 |
+
|
| 67 |
+
## Output Format
|
| 68 |
+
|
| 69 |
+
The default prompt asks the model to output each speech segment in the following format:
|
| 70 |
+
|
| 71 |
+
```text
|
| 72 |
+
[start_time][Sxx]transcribed speech[end_time]
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
Example:
|
| 76 |
+
|
| 77 |
+
```text
|
| 78 |
+
[0.48][S01]Welcome everyone[1.66][12.26][S02]The new transcription pipeline is ready for evaluation[13.81][14.36][S01]Great, include the diarization results in the report[18.76]
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
In this format:
|
| 82 |
+
|
| 83 |
+
- `start_time` and `end_time` are timestamps in seconds.
|
| 84 |
+
- `[S01]`, `[S02]`, and similar labels are anonymous speaker labels generated by the model.
|
| 85 |
+
- Speaker labels are relative labels within the input audio and should not be interpreted as real speaker identities.
|
| 86 |
+
|
| 87 |
+
## Intended Use
|
| 88 |
+
|
| 89 |
+
This model is intended for:
|
| 90 |
+
|
| 91 |
+
- Long-form automatic speech recognition.
|
| 92 |
+
- Speaker-aware transcription.
|
| 93 |
+
- Speaker diarization with anonymous speaker labels.
|
| 94 |
+
- Timestamped transcripts for meetings, podcasts, interviews, lectures, calls, and videos.
|
| 95 |
+
- Downstream audio understanding pipelines that need both transcript text and "who spoke when" information.
|
| 96 |
+
|
| 97 |
+
This model is not intended to be used as the sole source of truth for medical, legal, financial, safety-critical, or other high-stakes transcription without human review.
|
| 98 |
+
|
| 99 |
+
## Quickstart
|
| 100 |
+
|
| 101 |
+
### Environment Setup
|
| 102 |
+
|
| 103 |
+
This repository uses custom Transformers model and processor code. Always load the model and processor with `trust_remote_code=True`.
|
| 104 |
+
|
| 105 |
+
The code requires Python 3.10 or later and is tested with Transformers 5.x.
|
| 106 |
+
|
| 107 |
+
```bash
|
| 108 |
+
python -m pip install -U pip
|
| 109 |
+
python -m pip install "transformers>=5.0.0,<6.0.0" "torch>=2.8" "torchaudio>=2.8"
|
| 110 |
+
python -m pip install "safetensors>=0.6.2" "numpy>=1.26,<2" "av>=14.0" "librosa>=0.11.0" "soundfile>=0.12" "soxr>=0.5" packaging
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
For command line inference and helper utilities, clone the repository and install it in editable mode:
|
| 114 |
+
|
| 115 |
+
```bash
|
| 116 |
+
git clone https://huggingface.co/OpenMOSS-Team/MOSS-Transcribe-Diarize
|
| 117 |
+
cd MOSS-Transcribe-Diarize
|
| 118 |
+
python -m pip install -e .
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
### Command Line Inference
|
| 122 |
+
|
| 123 |
+
Run greedy decoding:
|
| 124 |
+
|
| 125 |
+
```bash
|
| 126 |
+
python infer.py \
|
| 127 |
+
--model OpenMOSS-Team/MOSS-Transcribe-Diarize \
|
| 128 |
+
--audio /path/to/audio_or_video.mp4 \
|
| 129 |
+
--decoding greedy \
|
| 130 |
+
--max-new-tokens 2048
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
Run sampling decoding:
|
| 134 |
+
|
| 135 |
+
```bash
|
| 136 |
+
python infer.py \
|
| 137 |
+
--model OpenMOSS-Team/MOSS-Transcribe-Diarize \
|
| 138 |
+
--audio /path/to/audio_or_video.mp4 \
|
| 139 |
+
--decoding sample \
|
| 140 |
+
--temperature 0.7 \
|
| 141 |
+
--max-new-tokens 2048
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
Return JSON output:
|
| 145 |
+
|
| 146 |
+
```bash
|
| 147 |
+
python infer.py \
|
| 148 |
+
--model OpenMOSS-Team/MOSS-Transcribe-Diarize \
|
| 149 |
+
--audio /path/to/audio_or_video.mp4 \
|
| 150 |
+
--json
|
| 151 |
+
```
|
| 152 |
+
|
| 153 |
+
Audio files are loaded through the Transformers audio loader. Video containers such as MP4, MOV, and MKV are decoded with PyAV and resampled to mono 16 kHz before feature extraction.
|
| 154 |
+
|
| 155 |
+
### Python Usage
|
| 156 |
+
|
| 157 |
+
```python
|
| 158 |
+
import torch
|
| 159 |
+
from transformers import AutoModelForCausalLM, AutoProcessor
|
| 160 |
+
|
| 161 |
+
from moss_transcribe_diarize.inference_utils import (
|
| 162 |
+
build_transcription_messages,
|
| 163 |
+
generate_transcription,
|
| 164 |
+
resolve_device,
|
| 165 |
+
)
|
| 166 |
+
|
| 167 |
+
model_id = "OpenMOSS-Team/MOSS-Transcribe-Diarize"
|
| 168 |
+
audio_path = "/path/to/audio_or_video.mp4"
|
| 169 |
+
|
| 170 |
+
device = resolve_device("auto")
|
| 171 |
+
dtype = torch.bfloat16 if device.type == "cuda" else torch.float32
|
| 172 |
+
|
| 173 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 174 |
+
model_id,
|
| 175 |
+
trust_remote_code=True,
|
| 176 |
+
dtype="auto",
|
| 177 |
+
).to(dtype=dtype).to(device).eval()
|
| 178 |
+
|
| 179 |
+
processor = AutoProcessor.from_pretrained(
|
| 180 |
+
model_id,
|
| 181 |
+
trust_remote_code=True,
|
| 182 |
+
fix_mistral_regex=True,
|
| 183 |
+
)
|
| 184 |
+
|
| 185 |
+
messages = build_transcription_messages(audio_path)
|
| 186 |
+
result = generate_transcription(
|
| 187 |
+
model,
|
| 188 |
+
processor,
|
| 189 |
+
messages,
|
| 190 |
+
max_new_tokens=2048,
|
| 191 |
+
do_sample=False,
|
| 192 |
+
device=device,
|
| 193 |
+
dtype=dtype,
|
| 194 |
+
)
|
| 195 |
+
|
| 196 |
+
print(result["text"])
|
| 197 |
+
```
|
| 198 |
+
|
| 199 |
+
You can customize the transcription instruction by passing a custom prompt:
|
| 200 |
+
|
| 201 |
+
```python
|
| 202 |
+
messages = build_transcription_messages(
|
| 203 |
+
audio_path,
|
| 204 |
+
prompt="Please transcribe the audio with timestamps and speaker labels.",
|
| 205 |
+
)
|
| 206 |
+
```
|
| 207 |
+
|
| 208 |
+
The same can be done from the command line with `--prompt`.
|
| 209 |
+
|
| 210 |
+
## Evaluation
|
| 211 |
+
|
| 212 |
+
We evaluate MOSS-Transcribe-Diarize with Character Error Rate (CER), concatenated minimum-permutation Character Error Rate (cpCER), and Delta-cp. Lower is better for all metrics. A dash (`-`) indicates unavailable results.
|
| 213 |
+
|
| 214 |
+
| Dataset | Metric | Doubao | ElevenLabs | GPT-4o | Gemini 2.5 Pro | Gemini 3 Pro | VIBEVOICE ASR | MOSS Transcribe Diarize |
|
| 215 |
+
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
| 216 |
+
| **AISHELL-4** | CER ↓ | 18.18 | 19.58 | - | 42.70 | 22.75 | 21.40 | **14.19** |
|
| 217 |
+
| | cpCER ↓ | 27.86 | 37.95 | - | 53.42 | 27.43 | 24.99 | **14.98** |
|
| 218 |
+
| | Delta-cp ↓ | 9.68 | 18.36 | - | 10.72 | 4.68 | 3.59 | **0.79** |
|
| 219 |
+
| **Podcast** | CER ↓ | 7.93 | 8.50 | - | 7.38 | - | 27.94 | **4.46** |
|
| 220 |
+
| | cpCER ↓ | 10.54 | 11.34 | - | 10.23 | - | 48.30 | **6.97** |
|
| 221 |
+
| | Delta-cp ↓ | 2.61 | 2.85 | - | 2.85 | - | 20.36 | **2.50** |
|
| 222 |
+
| **Movies** | CER ↓ | 9.94 | 11.49 | 14.37 | 15.46 | 8.62 | 14.59 | **6.58** |
|
| 223 |
+
| | cpCER ↓ | 30.88 | 17.85 | 23.67 | 24.15 | 14.73 | 42.54 | **13.68** |
|
| 224 |
+
| | Delta-cp ↓ | 20.94 | **6.37** | 9.31 | 8.69 | 6.11 | 27.94 | 7.24 |
|
| 225 |
+
| **Alimeeting** | CER ↓ | 25.25 | 25.70 | - | 27.43 | 26.75 | 27.40 | **24.80** |
|
| 226 |
+
| | cpCER ↓ | 37.57 | 36.69 | - | 41.64 | 32.84 | 29.33 | **21.51** |
|
| 227 |
+
| | Delta-cp ↓ | 12.31 | 10.99 | - | 14.21 | 6.09 | 1.93 | **-0.33** |
|
| 228 |
+
|
| 229 |
+
## Ethical Considerations
|
| 230 |
+
|
| 231 |
+
Users should obtain appropriate consent before transcribing, diarizing, storing, or sharing recordings of people. The model generates anonymous speaker labels and does not verify real-world identities. Do not use the model for surveillance, unauthorized monitoring, or decisions that materially affect people without proper safeguards and human oversight.
|
| 232 |
+
|
| 233 |
+
## License
|
| 234 |
+
|
| 235 |
+
This project is released under the Apache License 2.0.
|
| 236 |
+
|
| 237 |
+
## Citation
|
| 238 |
+
|
| 239 |
+
Citation information will be added with the public model release.
|
| 240 |
+
|
| 241 |
+
---
|
| 242 |
+
|
| 243 |
+
## 简体中文
|
| 244 |
+
|
| 245 |
+
**MOSS-Transcribe-Diarize** 是一个面向长音频、多说话人场景的端到端音频理解模型。给定音频或视频文件后,模型可以在一次生成中输出带时间戳、说话人标签和转写文本的紧凑式说话人感知转录结果。
|
| 246 |
+
|
| 247 |
+
该模型适用于会议、电话、播客、访谈、课程、视频等真实录音场景,尤其适合需要同时处理长上下文和多说话人的音频内容。
|
| 248 |
+
|
| 249 |
+
## 目录
|
| 250 |
+
|
| 251 |
+
- [简介](#简介)
|
| 252 |
+
- [模型架构](#模型架构)
|
| 253 |
+
- [输出格式](#输出格式-1)
|
| 254 |
+
- [适用场景](#适用场景)
|
| 255 |
+
- [快速开始](#快速开始)
|
| 256 |
+
- [评测结果](#评测结果)
|
| 257 |
+
- [伦理说明](#伦理说明)
|
| 258 |
+
- [许可证](#许可证)
|
| 259 |
+
- [引用](#引用)
|
| 260 |
+
- [English](#english)
|
| 261 |
+
|
| 262 |
+
## 简介
|
| 263 |
+
|
| 264 |
+
长音频转写通常不只是普通 ASR。对于会议、电话、播客、访谈、课程和视频内容,一个有用的转录结果往往需要同时回答三个问题:说了什么、是谁说的、什么时候说的。
|
| 265 |
+
|
| 266 |
+
MOSS-Transcribe-Diarize 将这些能力统一在一个生成式模型中:
|
| 267 |
+
|
| 268 |
+
- **长音频语音识别**:将长音频和视频录音转写为文本。
|
| 269 |
+
- **说话人感知转写**:输出 `[S01]`、`[S02]`、`[S03]` 等匿名说话人标签。
|
| 270 |
+
- **时间戳预测**:为语音片段生成起止时间戳。
|
| 271 |
+
- **音频/视频输入**:支持常见音频文件和通过 PyAV 解码的视频容器���
|
| 272 |
+
- **可提示生成**:支持用户自定义转写指令。
|
| 273 |
+
|
| 274 |
+
## 模型架构
|
| 275 |
+
|
| 276 |
+
MOSS-Transcribe-Diarize 结合了 Whisper 风格的音频编码器和 Qwen3 风格的因果语言模型解码器。音频首先被转换为 16 kHz log-mel 特征,随后经过音频编码器、时间维度合并和 MLP 适配器投影,最终插入到语言模型中音频占位符对应的嵌入位置,并进行自回归文本生成。
|
| 277 |
+
|
| 278 |
+
| 组件 | 规格 |
|
| 279 |
+
|---|---|
|
| 280 |
+
| 文本骨干 | Qwen3-0.6B 风格因果解码器 |
|
| 281 |
+
| 音频编码器 | Whisper-Medium 编码器配置 |
|
| 282 |
+
| 音频前端 | `WhisperFeatureExtractor`,16 kHz,80 维 mel,30 秒切块 |
|
| 283 |
+
| 音频-文本桥接 | 4 倍时间维合并 + MLP 适配器 |
|
| 284 |
+
| 融合方式 | 音频特征替换 `<|audio_pad|>` 位置的嵌入 |
|
| 285 |
+
| 输出格式 | 紧凑式 `[start][Sxx]text[end]` 转录结果 |
|
| 286 |
+
|
| 287 |
+
## 输出格式
|
| 288 |
+
|
| 289 |
+
默认提示词要求模型按照如下格式输出每个语音片段:
|
| 290 |
+
|
| 291 |
+
```text
|
| 292 |
+
[start_time][Sxx]transcribed speech[end_time]
|
| 293 |
+
```
|
| 294 |
+
|
| 295 |
+
示例:
|
| 296 |
+
|
| 297 |
+
```text
|
| 298 |
+
[0.48][S01]Welcome everyone[1.66][12.26][S02]The new transcription pipeline is ready for evaluation[13.81][14.36][S01]Great, include the diarization results in the report[18.76]
|
| 299 |
+
```
|
| 300 |
+
|
| 301 |
+
其中:
|
| 302 |
+
|
| 303 |
+
- `start_time` 和 `end_time` 是以秒为单位的时间戳。
|
| 304 |
+
- `[S01]`、`[S02]` 等是模型生成的匿名说话人标签。
|
| 305 |
+
- 说话人标签只表示输入音频内部的相对说话人,不代表真实身份。
|
| 306 |
+
|
| 307 |
+
## 适用场景
|
| 308 |
+
|
| 309 |
+
该模型适用于:
|
| 310 |
+
|
| 311 |
+
- 长音频自动语音识别。
|
| 312 |
+
- 说话人感知转写。
|
| 313 |
+
- 使用匿名标签进行说话人分离,例如 `[S01]`、`[S02]`、`[S03]`。
|
| 314 |
+
- 为会议、播客、访谈、课程、电话和视频生成带时间戳的转录结果。
|
| 315 |
+
- 需要同时获得文本内容和“谁在何时说话”信息的下游音频理解流程。
|
| 316 |
+
|
| 317 |
+
在医疗、法律、金融、安全关键或其他高风险场景中,不应在没有人工复核的情况下将该模型作为唯一事实来源。
|
| 318 |
+
|
| 319 |
+
## 快速开始
|
| 320 |
+
|
| 321 |
+
### 环境安装
|
| 322 |
+
|
| 323 |
+
本仓库使用自定义 Transformers 模型和处理器代码。加载模型和处理器时请始终设置 `trust_remote_code=True`。
|
| 324 |
+
|
| 325 |
+
代码要求 Python 3.10 或更高版本,并已在 Transformers 5.x 上测试。
|
| 326 |
+
|
| 327 |
+
```bash
|
| 328 |
+
python -m pip install -U pip
|
| 329 |
+
python -m pip install "transformers>=5.0.0,<6.0.0" "torch>=2.8" "torchaudio>=2.8"
|
| 330 |
+
python -m pip install "safetensors>=0.6.2" "numpy>=1.26,<2" "av>=14.0" "librosa>=0.11.0" "soundfile>=0.12" "soxr>=0.5" packaging
|
| 331 |
+
```
|
| 332 |
+
|
| 333 |
+
如需使用命令行推理和辅助工具,请克隆仓库并以 editable 模式安装:
|
| 334 |
+
|
| 335 |
+
```bash
|
| 336 |
+
git clone https://huggingface.co/OpenMOSS-Team/MOSS-Transcribe-Diarize
|
| 337 |
+
cd MOSS-Transcribe-Diarize
|
| 338 |
+
python -m pip install -e .
|
| 339 |
+
```
|
| 340 |
+
|
| 341 |
+
### 命令行推理
|
| 342 |
+
|
| 343 |
+
使用 greedy decoding:
|
| 344 |
+
|
| 345 |
+
```bash
|
| 346 |
+
python infer.py \
|
| 347 |
+
--model OpenMOSS-Team/MOSS-Transcribe-Diarize \
|
| 348 |
+
--audio /path/to/audio_or_video.mp4 \
|
| 349 |
+
--decoding greedy \
|
| 350 |
+
--max-new-tokens 2048
|
| 351 |
+
```
|
| 352 |
+
|
| 353 |
+
使用采样解码:
|
| 354 |
+
|
| 355 |
+
```bash
|
| 356 |
+
python infer.py \
|
| 357 |
+
--model OpenMOSS-Team/MOSS-Transcribe-Diarize \
|
| 358 |
+
--audio /path/to/audio_or_video.mp4 \
|
| 359 |
+
--decoding sample \
|
| 360 |
+
--temperature 0.7 \
|
| 361 |
+
--max-new-tokens 2048
|
| 362 |
+
```
|
| 363 |
+
|
| 364 |
+
输出 JSON:
|
| 365 |
+
|
| 366 |
+
```bash
|
| 367 |
+
python infer.py \
|
| 368 |
+
--model OpenMOSS-Team/MOSS-Transcribe-Diarize \
|
| 369 |
+
--audio /path/to/audio_or_video.mp4 \
|
| 370 |
+
--json
|
| 371 |
+
```
|
| 372 |
+
|
| 373 |
+
音频文件会通过 Transformers 的音频加载器读取。MP4、MOV、MKV 等视频容器会通过 PyAV 解码,并在特征提取前重采样为单声道 16 kHz。
|
| 374 |
+
|
| 375 |
+
### Python 用法
|
| 376 |
+
|
| 377 |
+
```python
|
| 378 |
+
import torch
|
| 379 |
+
from transformers import AutoModelForCausalLM, AutoProcessor
|
| 380 |
+
|
| 381 |
+
from moss_transcribe_diarize.inference_utils import (
|
| 382 |
+
build_transcription_messages,
|
| 383 |
+
generate_transcription,
|
| 384 |
+
resolve_device,
|
| 385 |
+
)
|
| 386 |
+
|
| 387 |
+
model_id = "OpenMOSS-Team/MOSS-Transcribe-Diarize"
|
| 388 |
+
audio_path = "/path/to/audio_or_video.mp4"
|
| 389 |
+
|
| 390 |
+
device = resolve_device("auto")
|
| 391 |
+
dtype = torch.bfloat16 if device.type == "cuda" else torch.float32
|
| 392 |
+
|
| 393 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 394 |
+
model_id,
|
| 395 |
+
trust_remote_code=True,
|
| 396 |
+
dtype="auto",
|
| 397 |
+
).to(dtype=dtype).to(device).eval()
|
| 398 |
+
|
| 399 |
+
processor = AutoProcessor.from_pretrained(
|
| 400 |
+
model_id,
|
| 401 |
+
trust_remote_code=True,
|
| 402 |
+
fix_mistral_regex=True,
|
| 403 |
+
)
|
| 404 |
+
|
| 405 |
+
messages = build_transcription_messages(audio_path)
|
| 406 |
+
result = generate_transcription(
|
| 407 |
+
model,
|
| 408 |
+
processor,
|
| 409 |
+
messages,
|
| 410 |
+
max_new_tokens=2048,
|
| 411 |
+
do_sample=False,
|
| 412 |
+
device=device,
|
| 413 |
+
dtype=dtype,
|
| 414 |
+
)
|
| 415 |
+
|
| 416 |
+
print(result["text"])
|
| 417 |
+
```
|
| 418 |
+
|
| 419 |
+
可以通过自定义 prompt 调整转写指令:
|
| 420 |
+
|
| 421 |
+
```python
|
| 422 |
+
messages = build_transcription_messages(
|
| 423 |
+
audio_path,
|
| 424 |
+
prompt="Please transcribe the audio with timestamps and speaker labels.",
|
| 425 |
+
)
|
| 426 |
+
```
|
| 427 |
+
|
| 428 |
+
命令行中也可以通过 `--prompt` 参数传入自定义提示词。
|
| 429 |
+
|
| 430 |
+
## 评测结果
|
| 431 |
+
|
| 432 |
+
我们使用字符错误率(CER)、拼接后最小排列字符错误率(cpCER)和 Delta-cp 评测 MOSS-Transcribe-Diarize。所有指标均为越低越好。横线(`-`)表示结果暂不可用。
|
| 433 |
+
|
| 434 |
+
| 数据集 | 指标 | Doubao | ElevenLabs | GPT-4o | Gemini 2.5 Pro | Gemini 3 Pro | VIBEVOICE ASR | MOSS Transcribe Diarize |
|
| 435 |
+
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
| 436 |
+
| **AISHELL-4** | CER ↓ | 18.18 | 19.58 | - | 42.70 | 22.75 | 21.40 | **14.19** |
|
| 437 |
+
| | cpCER ↓ | 27.86 | 37.95 | - | 53.42 | 27.43 | 24.99 | **14.98** |
|
| 438 |
+
| | Delta-cp ↓ | 9.68 | 18.36 | - | 10.72 | 4.68 | 3.59 | **0.79** |
|
| 439 |
+
| **Podcast** | CER ↓ | 7.93 | 8.50 | - | 7.38 | - | 27.94 | **4.46** |
|
| 440 |
+
| | cpCER ↓ | 10.54 | 11.34 | - | 10.23 | - | 48.30 | **6.97** |
|
| 441 |
+
| | Delta-cp ↓ | 2.61 | 2.85 | - | 2.85 | - | 20.36 | **2.50** |
|
| 442 |
+
| **Movies** | CER ↓ | 9.94 | 11.49 | 14.37 | 15.46 | 8.62 | 14.59 | **6.58** |
|
| 443 |
+
| | cpCER ↓ | 30.88 | 17.85 | 23.67 | 24.15 | 14.73 | 42.54 | **13.68** |
|
| 444 |
+
| | Delta-cp ↓ | 20.94 | **6.37** | 9.31 | 8.69 | 6.11 | 27.94 | 7.24 |
|
| 445 |
+
| **Alimeeting** | CER ↓ | 25.25 | 25.70 | - | 27.43 | 26.75 | 27.40 | **24.80** |
|
| 446 |
+
| | cpCER ↓ | 37.57 | 36.69 | - | 41.64 | 32.84 | 29.33 | **21.51** |
|
| 447 |
+
| | Delta-cp ↓ | 12.31 | 10.99 | - | 14.21 | 6.09 | 1.93 | **-0.33** |
|
| 448 |
+
|
| 449 |
+
## 伦理说明
|
| 450 |
+
|
| 451 |
+
在转写、分离、存储或分享包含他人声音的录音前,用户应确保已获得适当授权或同意。该模型只生成匿名说话人标签,不验证真实身份。请勿将模型用于未授权监听、监控、监视或在缺乏充分保障和人工监督的情况下做出会对个人产生实质影响的决策。
|
| 452 |
+
|
| 453 |
+
## 许可证
|
| 454 |
+
|
| 455 |
+
本项目基于 Apache License 2.0 发布。
|
| 456 |
+
|
| 457 |
+
## 引用
|
| 458 |
+
|
| 459 |
+
公开模型发布后将补充引用信息。
|