多语言 CTC 对齐
更新时间:2026-06-15
简介
音频 CTC 对齐算子,用于将音频与文本按时间戳实施对齐,目前支持中文和英文。
算子参数
输入
| 输入 | 含义 |
|---|---|
| audios | 包含音频数据的数组,支持以下格式: audio_url: 音频文件 URL 路径(支持 HTTP/BOS/S3 等协议 URL,以及本地文件路径); audio_binary: 原始音频字节数据 |
| texts | 与音频内容对应的文本列表 |
| langs | 音频文本对应的语言,目前仅支持 "en" (英文) 和 "zh" (中文) |
输出
| 输出 | 含义 |
|---|---|
| result | 算子输出 |
参数
| 参数名称 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| model_path | str | '/opt/aihc/models' | 模型path |
| model_name | str | 'MMS/ctc_alignment_mling_uroman_model.pt' | 模型名称 |
调用示例
Python
1from __future__ import annotations
2
3import os
4
5import daft
6from daft import col
7
8from daft.aihc.common.udf import aihc_udf
9from daft.aihc.functions.audio.audio_ctc_aligner import AudioCTCAligner
10
11if __name__ == "__main__":
12 if os.getenv("DAFT_RUNNER", "native") == "ray":
13 import ray
14 ray.init(dashboard_host="0.0.0.0", ignore_reinit_error=True)
15 daft.set_runner_ray()
16 daft.set_execution_config(actor_udf_ready_timeout=6000, min_cpu_per_task=0)
17
18 # TODO: 根据实际场景准备样本数据
19 samples = {"audios": [...], "texts": [...]}
20 ds = daft.from_pydict(samples)
21 constructor_kwargs = {
22 "model_path": '/opt/aihc/models',
23 "model_name": 'MMS/ctc_alignment_mling_uroman_model.pt',
24 }
25 ds = ds.with_column(
26 "result",
27 aihc_udf(
28 AudioCTCAligner,
29 construct_args=constructor_kwargs,
30 num_cpus=1,
31 concurrency=4,
32 batch_size=8,
33 )(col("audios"), col("texts"), col("langs")),
34 )
35 ds.show()
评价此篇文章
