Audio Mixer
The Audio Mixer pipeline mixes multiple audio streams into a single stream.
Example
The following shows a simple example using this pipeline.
from txtai.pipeline import AudioMixer
# Create and run pipeline
mixer = AudioMixer()
mixer(((audio1, rate1), (audio2, rate2)))
See the link below for a more detailed example.
Notebook | Description | |
---|---|---|
Generative Audio | Storytelling with generative audio workflows |
Configuration-driven example
Pipelines are run with Python or configuration. Pipelines can be instantiated in configuration using the lower case name of the pipeline. Configuration-driven pipelines are run with workflows or the API.
config.yml
# Create pipeline using lower case class name
audiomixer:
# Run pipeline with workflow
workflow:
audiomixer:
tasks:
- action: audiomixer
Run with Workflows
from txtai import Application
# Create and run pipeline with workflow
app = Application("config.yml")
list(app.workflow("audiomixer", [[[audio1, rate1], [audio2, rate2]]]))
Run with 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]]]}'
Methods
Python documentation for the pipeline.
__init__(rate=None)
Creates an AudioMixer pipeline.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rate | optional target sample rate, otherwise uses input target rate with each audio segment | None |
Source code in txtai/pipeline/audio/audiomixer.py
|
|
__call__(segment, scale1=1, scale2=1)
Mixes multiple audio streams into a single stream.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
segment | ((audio1, sample rate), (audio2, sample rate))|list | required | |
scale1 | optional scaling factor for segment1 | 1 | |
scale2 | optional scaling factor for segment2 | 1 |
Returns:
Type | Description |
---|---|
list of (audio, sample rate) |
Source code in txtai/pipeline/audio/audiomixer.py
|
|