---
title: speech_timestamp_prediction-v1-16k-offline
canonical_url: "https://www.modelscope.cn/models/damo/speech_timestamp_prediction-v1-16k-offline"
md_url: "https://www.modelscope.cn/models/damo/speech_timestamp_prediction-v1-16k-offline.md"
repository: damo/speech_timestamp_prediction-v1-16k-offline
chinese_name: "Monotonic-Aligner语音时间戳预测-16k-离线"
last_updated: 2026-06-18
license: "Apache License 2.0"
pipeline_tag: timestamp-prediction
tasks:
  - timestamp-prediction
model_type:
  - Non-autoregressive
library_name:
  - pytorch
frameworks:
  - pytorch
language:
  - cn
domain:
  - audio
downloads: 1433545
stars: 53
tags:
  - FunASR
  - Timestamp
  - Alibaba
---

# speech_timestamp_prediction-v1-16k-offline

> speech_timestamp_prediction-v1-16k-offline - damo 在 ModelScope 开源的模型。输入语音与对应文本，生成文本中token的起止位置时间戳预测。

damo/speech_timestamp_prediction-v1-16k-offline 是 ModelScope 魔搭社区上的timestamp-prediction模型，采用 Apache License 2.0 许可。

- **Repository**: damo/speech_timestamp_prediction-v1-16k-offline
- **License**: Apache License 2.0
- **Tasks**: timestamp-prediction
- **Tags**: FunASR, Timestamp, Alibaba
- **Downloads**: 1433545
- **Stars**: 53
- **Last updated**: 2026-06-18

Source: https://www.modelscope.cn/models/damo/speech_timestamp_prediction-v1-16k-offline

---

# Highlights

<div align="center">

### 🚀 由 [FunASR](https://github.com/modelscope/FunASR) 驱动 · 阿里通义实验室开源工业级语音识别

本模型是 [**FunASR**](https://github.com/modelscope/FunASR) 语音生态的组件模型之一,可与 ASR 模型自由组合成完整流程。FunASR 一套工具打通 **ASR · VAD · 标点 · 说话人分离 · 情感 / 事件识别 · LLM-ASR**,一行代码即可调用本模型。

⭐ **觉得好用?欢迎给我们的开源项目点 Star 支持:**

[**🌟 FunASR**](https://github.com/modelscope/FunASR)  ·  [**🌟 SenseVoice**](https://github.com/FunAudioLLM/SenseVoice)  ·  [**🌟 Fun-ASR**](https://github.com/FunAudioLLM/Fun-ASR)  ·  [**🌟 FunClip**](https://github.com/modelscope/FunClip)

</div>

---

- 通过参数量较小的encoder与反卷积predictor实现时间戳预测，时间戳准确率与kaldi force-alignment系统相当（详见下方实验结果）。

## <strong>[FunASR开源项目介绍](https://github.com/alibaba-damo-academy/FunASR)</strong>
<strong>[FunASR](https://github.com/alibaba-damo-academy/FunASR)</strong>希望在语音识别的学术研究和工业应用之间架起一座桥梁。通过发布工业级语音识别模型的训练和微调，研究人员和开发人员可以更方便地进行语音识别模型的研究和生产，并推动语音识别生态的发展。让语音识别更有趣！

[**github仓库**](https://github.com/alibaba-damo-academy/FunASR)
| [**最新动态**](https://github.com/alibaba-damo-academy/FunASR#whats-new) 
| [**环境安装**](https://github.com/alibaba-damo-academy/FunASR#installation)
| [**服务部署**](https://www.funasr.com)
| [**模型库**](https://github.com/alibaba-damo-academy/FunASR/tree/main/model_zoo)
| [**联系我们**](https://github.com/alibaba-damo-academy/FunASR#contact)


## 模型原理介绍


Timestamp Prediction Model

目前大部分工业语音识别系统使用外接的强制对齐模型预测ASR模型识别结果的时间戳，这引入了额外的计算开销与时间开销，FunASR提供一种在ASR任务过程中天然的预测识别结果时间戳的方法。
Paraformer通过encoder之后的predictor模块实现token级别的声学表征的生成，predictor中的cif机制通过累积帧级别权重计算了每个token的持续区间与发射位置，这使得通过predictor实现与ASR任务一体化的时间戳预测（Timestamp Prediction, TP）成为了可能。本模型为Paraformer-large-长音频版的衍生模型，通过较小参数量的encoder与升采样cif predictor实现了时间戳预测功能，方便用户自由搭建ASR链路中的功能环节。

其核心点主要有：  
- Upsample Predictor 模块：在低帧率模型中predictor产生的帧级别权重可能存在预测不稳定的问题，表现为首尾帧出字与连续帧出字，这为基于cif权重的时间戳预测带来了困扰。本模型
  - (1) 在predictor的线性层之前引入了反卷积升采样模块与lstm模块，在多倍帧率的情况下预测权重；
  - (2) 通过scaled cif对权重进行尺度缩小与平滑，使得cif权重不表现为一个peak而是一段累积过程。通过上述两个操作得到了能用于时间戳预测的帧权重。
- 基于约5w小时工业数据训练的时间戳预测模型，鲁棒性更强，时间戳准确率更高。



#### 基于ModelScope进行推理

- 推理支持音频格式如下：
  - wav文件路径，例如：data/test/audios/asr_example.wav
  - pcm文件路径，例如：data/test/audios/asr_example.pcm
  - wav文件url，例如：https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_timestamps.wav
  - wav二进制数据，格式bytes，例如：用户直接从文件里读出bytes数据或者是麦克风录出bytes数据。
  - 已解析的audio音频，例如：audio, rate = soundfile.read("asr_example_zh.wav")，类型为numpy.ndarray或者torch.Tensor。
  - wav.scp文件，需符合如下要求：

```sh
cat wav.scp
asr_example1  data/test/audios/asr_example1.wav
asr_example2  data/test/audios/asr_example2.wav
...
```

- 若输入格式wav文件url，api调用方式可参考如下范例：

```python
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

inference_pipline = pipeline(
    task=Tasks.speech_timestamp,
    model='iic/speech_timestamp_prediction-v1-16k-offline',
    model_revision="v2.0.4",
    output_dir='./tmp')

wav_file = "https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_timestamps.wav"
text_file = "一 个 东 太 平 洋 国 家 为 什 么 跑 到 西 太 平 洋 来 了 呢"
rec_result = inference_pipline(input=(wav_file, text_file), data_type=("sound", "text"))
print(rec_result)
```
<!-- 
- 在普通ASR模型的inference中，FunASR支持自由组合timestamp prediction模型进入pipeline中以支持任意ASR模型之后的时间戳预测，参考以下范例：
```python
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

inference_pipeline = pipeline(
    task=Tasks.auto_speech_recognition,
    model='damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch',
    timestamp_model="damo/speech_timestamp_prediction-v1-16k-offline",
    timestamp_model_revision="v2.0.4")

rec_result = inference_pipeline(audio_in="https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_timestamps.wav")
print(rec_result)
``` -->

- 若输入格式为文件wav.scp与对应的抄本text.txt(注：文件名需要以.txt结尾)，可添加 output_dir 参数将识别结果写入文件中，api调用方式可参考如下范例:

```python
wav_file = "./wav.scp"
text_file = "/text.txt"
rec_result = inference_pipline(input=(wav_file, text_file), data_type=("sound", "text"))
print(rec_result)
```
输出的结果为带有静音标注时间戳的字符串以及排除了静音标注的与token数量一致的时间戳列表：

'text': '<sil> 0.000 0.380;一 0.380 0.560;个 0.560 0.800;东 0.800 0.980;太 0.980 1.140;平 1.140 1.260;洋 1.260 1.440;国 1.440 1.680;家 1.680 1.920;<sil> 1.920 2.040;为 2.040 2.200;什 2.200 2.320;么 2.320 2.500;跑 2.500 2.680;到 2.680 2.880;西 2.880 3.060;太 3.060 3.200;平 3.200 3.380;洋 3.380 3.500;来 3.500 3.660;了 3.660 3.800;呢 3.800 4.160;<sil> 4.160 4.440;', 

'timestamp': [\[380, 560], [560, 800], [800, 980], [980, 1140], [1140, 1260], [1260, 1440], [1440, 1680], [1680, 1920], [2040, 2200], [2200, 2320], [2320, 2500], [2500, 2680], [2680, 2880], [2880, 3060], [3060, 3200], [3200, 3380], [3380, 3500], [3500, 3660], [3660, 3800], [3800, 4160]]


## 基于FunASR进行推理

下面为快速上手教程，测试音频（[中文](https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/vad_example.wav)，[英文](https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_en.wav)）

### 可执行命令行
在命令行终端执行：

```shell
funasr audio.wav --model paraformer -f srt    # 旧版 `funasr +model=...` Hydra 命令行已迁移到 `funasr-hydra`
```

注：支持单条音频文件识别，也支持文件列表，列表为kaldi风格wav.scp：`wav_id   wav_path`

### python示例
#### 非实时语音识别
```python
from funasr import AutoModel
# paraformer-zh is a multi-functional asr model
# use vad, punc, spk or not as you need
model = AutoModel(model="paraformer-zh", model_revision="v2.0.4",
                  vad_model="fsmn-vad", vad_model_revision="v2.0.4",
                  punc_model="ct-punc-c", punc_model_revision="v2.0.4",
                  # spk_model="cam++", spk_model_revision="v2.0.2",
                  )
res = model.generate(input=f"{model.model_path}/example/asr_example.wav", 
            batch_size_s=300, 
            hotword='魔搭')
print(res)
```
注：`model_hub`：表示模型仓库，`ms`为选择modelscope下载，`hf`为选择huggingface下载。

#### 实时语音识别

```python
from funasr import AutoModel

chunk_size = [0, 10, 5] #[0, 10, 5] 600ms, [0, 8, 4] 480ms
encoder_chunk_look_back = 4 #number of chunks to lookback for encoder self-attention
decoder_chunk_look_back = 1 #number of encoder chunks to lookback for decoder cross-attention

model = AutoModel(model="paraformer-zh-streaming", model_revision="v2.0.4")

import soundfile
import os

wav_file = os.path.join(model.model_path, "example/asr_example.wav")
speech, sample_rate = soundfile.read(wav_file)
chunk_stride = chunk_size[1] * 960 # 600ms

cache = {}
total_chunk_num = int(len((speech)-1)/chunk_stride+1)
for i in range(total_chunk_num):
    speech_chunk = speech[i*chunk_stride:(i+1)*chunk_stride]
    is_final = i == total_chunk_num - 1
    res = model.generate(input=speech_chunk, cache=cache, is_final=is_final, chunk_size=chunk_size, encoder_chunk_look_back=encoder_chunk_look_back, decoder_chunk_look_back=decoder_chunk_look_back)
    print(res)
```

注：`chunk_size`为流式延时配置，`[0,10,5]`表示上屏实时出字粒度为`10*60=600ms`，未来信息为`5*60=300ms`。每次推理输入为`600ms`（采样点数为`16000*0.6=960`），输出为对应文字，最后一个语音片段输入需要设置`is_final=True`来强制输出最后一个字。

#### 语音端点检测（非实时）
```python
from funasr import AutoModel

model = AutoModel(model="fsmn-vad", model_revision="v2.0.4")

wav_file = f"{model.model_path}/example/asr_example.wav"
res = model.generate(input=wav_file)
print(res)
```

#### 语音端点检测（实时）
```python
from funasr import AutoModel

chunk_size = 200 # ms
model = AutoModel(model="fsmn-vad", model_revision="v2.0.4")

import soundfile

wav_file = f"{model.model_path}/example/vad_example.wav"
speech, sample_rate = soundfile.read(wav_file)
chunk_stride = int(chunk_size * sample_rate / 1000)

cache = {}
total_chunk_num = int(len((speech)-1)/chunk_stride+1)
for i in range(total_chunk_num):
    speech_chunk = speech[i*chunk_stride:(i+1)*chunk_stride]
    is_final = i == total_chunk_num - 1
    res = model.generate(input=speech_chunk, cache=cache, is_final=is_final, chunk_size=chunk_size)
    if len(res[0]["value"]):
        print(res)
```

#### 标点恢复
```python
from funasr import AutoModel

model = AutoModel(model="ct-punc", model_revision="v2.0.4")

res = model.generate(input="那今天的会就到这里吧 happy new year 明年见")
print(res)
```

#### 时间戳预测
```python
from funasr import AutoModel

model = AutoModel(model="fa-zh", model_revision="v2.0.4")

wav_file = f"{model.model_path}/example/asr_example.wav"
text_file = f"{model.model_path}/example/text.txt"
res = model.generate(input=(wav_file, text_file), data_type=("sound", "text"))
print(res)
```

更多详细用法（[示例](https://github.com/alibaba-damo-academy/FunASR/tree/main/examples/industrial_data_pretraining)）




## Benchmark
我们提供Aishell-1数据、内部工业大数据实验中本模型、Paraformer-large-长音频版模型以及kaldi hybrid系统的force-alignment模型的时间戳准确率比较。平均偏移时间（Accumulated averaged shift, AAS）通过计算文本中匹配的token时间戳起始位置相较于人工标注时间戳的相对偏移时间之和的平均值衡量时间戳的准确程度。

| Data            | System                | AAS(ms)  |
|-----------------|-----------------------|----------|
| Aishell-1       | Force-alignment       | 80.1     |
|                 | Paraformer CIF        | 71.0     |
| Industrial Data | Force-alignment       | 60.3     |
|                 | Paraformer-large CIF2 | 65.3     |
|                 | Paraformer-FA         | 69.3     |


## 使用方式以及适用范围

运行范围
- 支持Linux-x86_64，Mac和Windows。

使用方式
- 直接推理：可以直接通过输入的音频与文字进行时间戳预测，输出与文字序列同步的时间戳。

使用范围与目标场景
- 适合于离线场景，对不同声学环境中的语音均能够较好的支持，但需要注意输入的文字与语音中的内容不匹配时预测可能会不稳定。


## 模型局限性以及可能的偏差

考虑到特征提取流程和工具以及训练工具差异，会对AAS的数据带来一定的差异（<0.1%），推理GPU环境差异导致的RTF数值差异。



## 相关论文以及引用信息

```BibTeX
@inproceedings{gao2022paraformer,
  title={Paraformer: Fast and Accurate Parallel Transformer for Non-autoregressive End-to-End Speech Recognition},
  author={Gao, Zhifu and Zhang, Shiliang and McLoughlin, Ian and Yan, Zhijie},
  booktitle={INTERSPEECH},
  year={2022}
}
@inproceedings{Shi2023AchievingTP,
  title={Achieving Timestamp Prediction While Recognizing with Non-Autoregressive End-to-End ASR Model},
  author={Xian Shi and Yanni Chen and Shiliang Zhang and Zhijie Yan},
  booktitle={arXiv preprint arXiv:2301.12343}
  year={2023}
}
```
