音频混合器
音频混合器流水线将多个音频流混合成一个单一流。
示例
以下展示了一个使用此流水线的简单示例。
from txtai.pipeline import AudioMixer
# Create and run pipeline
mixer = AudioMixer()
mixer(((audio1, rate1), (audio2, rate2)))
查看下方链接获取更详细的示例。
Notebook | 描述 | |
---|---|---|
生成式音频 | 使用生成式音频工作流进行故事讲述 |
配置驱动的示例
流水线可以通过 Python 或配置运行。流水线可以在 配置 中使用流水线的名称小写进行实例化。配置驱动的流水线可以通过 工作流 或 API 运行。
config.yml
# Create pipeline using lower case class name
audiomixer:
# Run pipeline with workflow
workflow:
audiomixer:
tasks:
- action: audiomixer
使用工作流运行
from txtai import Application
# Create and run pipeline with workflow
app = Application("config.yml")
list(app.workflow("audiomixer", [[[audio1, rate1], [audio2, rate2]]]))
使用 API 运行
CONFIG=config.yml uvicorn "txtai.api:app" &
curl \
-X POST "http://localhost:8000/workflow" \
-H "Content-Type: application/json" \
-d '{"name":"audiomixer", "elements":[[[audio1, rate1], [audio2, rate2]]]}'
方法
此流水线的 Python 文档。
__init__(rate=None)
创建一个 AudioMixer 流水线。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
rate
|
可选的目标采样率,否则使用每个音频段的输入目标采样率 |
None
|
源代码位于 txtai/pipeline/audio/audiomixer.py
14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
__call__(segment, scale1=1, scale2=1)
将多个音频流混合成一个单一流。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
segment
|
((audio1, 采样率), (audio2, 采样率))|list |
必需 | |
scale1
|
segment1 的可选缩放因子 |
1
|
|
scale2
|
segment2 的可选缩放因子 |
1
|
返回
类型 | 描述 |
---|---|
(音频, 采样率) 列表 |
源代码位于 txtai/pipeline/audio/audiomixer.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|