Skip to main content
def infill_create(client: Cartesia) -> None:
    """Create infill audio between two clips."""
    from pathlib import Path
    # Can pass file paths directly (as Path objects)
    response = client.tts.infill(
        model_id="sonic-3",
        language="en",
        transcript="Infill text",
        left_audio=Path("left.wav"),
        right_audio=Path("right.wav"),
        voice_id="6ccbfb76-1fc6-48f7-b71d-91ac6298247b",
        output_format={"container": "wav", "encoding": "pcm_f32le", "sample_rate": 44100},
    )
    response.write_to_file("infill_output.wav")
    print(f"Saved audio to infill_output.wav")
    print(f"Play with: ffplay -f wav infill_output.wav")
From cartesia-python/examples/examples.py:504

Run this example

cd cartesia-python
CARTESIA_API_KEY=YOUR_KEY python3 examples/examples.py infill_create