Text To Audio
The Text To Audio pipeline generates audio from text.
Example
The following shows a simple example using this pipeline.
from txtai.pipeline import TextToAudio
# Create and run pipeline
tta = TextToAudio()
tta("Describe the audio to generate here")
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
texttoaudio:
# Run pipeline with workflow
workflow:
tta:
tasks:
- action: texttoaudio
Run with Workflows
from txtai import Application
# Create and run pipeline with workflow
app = Application("config.yml")
list(app.workflow("tta", ["Describe the audio to generate here"]))
Run with API
CONFIG=config.yml uvicorn "txtai.api:app" &
curl \
-X POST "http://localhost:8000/workflow" \
-H "Content-Type: application/json" \
-d '{"name":"tta", "elements":["Describe the audio to generate here"]}'
Methods
Python documentation for the pipeline.
__init__(path=None, quantize=False, gpu=True, model=None, rate=None, **kwargs)
Source code in txtai/pipeline/audio/texttoaudio.py
|
|
__call__(text, maxlength=512)
Generates audio from text.
This method supports text as a string or a list. If the input is a string, the return type is a single audio output. If text is a list, the return type is a list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text | text|list | required | |
maxlength | maximum audio length to generate | 512 |
Returns:
Type | Description |
---|---|
list of (audio, sample rate) |
Source code in txtai/pipeline/audio/texttoaudio.py
|
|