google/lyria-2 - AI Audio Tools Tool
Overview
Lyria 2 is Google’s text-to-music model available on Replicate that generates professional-grade 48 kHz stereo audio from plain-language prompts. It is designed to produce finished-sounding music across multiple genres and instrumentation styles directly from text descriptions, making it suitable for rapid prototyping, demo creation, and integration into media projects. Outputs are high sample-rate stereo audio intended to be immediately usable in DAWs, video soundtracks, and streaming-ready content. The model implements SynthID audio watermarking (Google’s audio provenance watermarking initiative), enabling creators and platforms to embed traceable provenance metadata into generated audio. Lyria 2 is provided through a hosted API (Replicate model page) for straightforward programmatic access, allowing teams to integrate text-driven music generation into pipelines, apps, or content-production workflows without managing model infrastructure locally.
Key Features
- Text-to-music: generate full, multi-instrument tracks from plain-language prompts.
- 48 kHz stereo output suitable for DAWs and professional audio pipelines.
- Supports multiple genres and instrumentation styles via descriptive prompts.
- SynthID audio watermarking for embedded provenance and traceability.
- Hosted on Replicate for immediate API integration without local model hosting.
Example Usage
Example (python):
import os
import time
import requests
# This example uses the Replicate REST API. Replace VERSION_ID with the model version ID
# shown on the model page (https://replicate.com/google/lyria-2) and adjust inputs per model docs.
REPLICATE_API_TOKEN = os.environ.get("REPLICATE_API_TOKEN")
VERSION_ID = "<VERSION_ID>" # Replace with the actual version id from the Replicate model page
headers = {
"Authorization": f"Token {REPLICATE_API_TOKEN}",
"Content-Type": "application/json",
}
# Example prompt — customize for your desired genre/instruments/duration
payload = {
"version": VERSION_ID,
"input": {
"prompt": "A warm, cinematic piano and string score, slow build, 45 seconds",
# Note: exact input keys (e.g., length, tempo) depend on the model version's spec.
},
}
# Create prediction
resp = requests.post("https://api.replicate.com/v1/predictions", headers=headers, json=payload)
resp.raise_for_status()
pred = resp.json()
prediction_id = pred["id"]
# Poll for completion
status = pred.get("status")
while status not in ("succeeded", "failed", "canceled"):
time.sleep(1)
check = requests.get(f"https://api.replicate.com/v1/predictions/{prediction_id}", headers=headers)
check.raise_for_status()
data = check.json()
status = data.get("status")
if status == "succeeded":
outputs = data.get("output") or []
# Replicate often returns a list of output URLs; take first
audio_url = outputs[0] if outputs else None
if audio_url:
r = requests.get(audio_url)
r.raise_for_status()
with open("lyria_output.wav", "wb") as f:
f.write(r.content)
print("Saved generated audio to lyria_output.wav")
else:
print("No output URL returned.")
else:
print(f"Generation ended with status: {status}")
Key Information
- Category: Audio Tools
- Type: AI Audio Tools Tool