Lyria Music Generation Skill
Generate high-fidelity 44.1 kHz stereo audio, full songs with structured lyrics, instrumental soundtracks, and thematic compositions from text prompts or visual reference images using Google's Lyria foundation models (lyria-3.5 and lyria-3-clip-preview).
Available scripts
scripts/lyria.py: CLI tool for text-to-music and image-to-music generation, lyric export, and audio format conversion.
scripts/test_lyria.py: Test suite verifying Lyria argument parsing and multimodal input limit enforcement.
Trigger Conditions
Activate this skill whenever the user asks to:
- Generate music, songs, soundtracks, game audio beds, or background music.
- Compose musical themes inspired by artwork, concept photos, or screenshots.
- Create 30-second audio loops or multi-minute structured songs with verses, choruses, and custom lyrics.
- Synthesize instrumental audio tracks (
"Instrumental only, no vocals").
Model Selection & Comparison Matrix
| Model |
Model ID |
CLI Name |
Primary Use Case |
Duration |
Audio Format |
Reference Guide |
| Lyria 3.5 |
lyria-3.5 |
lyria-3.5 / 3.5 |
Flagship: full songs, expressive vocals, multi-section arrangements |
Controllable (up to ~3m) |
MP3, WAV |
lyria-3-5.md |
| Lyria 3 Clip |
lyria-3-clip-preview |
clip |
Short clips, loops, previews, rapid style testing |
Exactly 30s |
MP3, WAV |
lyria-3-clip.md |
| Lyria 3 Pro |
lyria-3-pro-preview |
pro |
Legacy preview: multi-section arrangements, film scoring |
Up to 184s |
MP3, WAV |
lyria-3-pro.md |
Model Selection Guide
- Full Song Production: Use Lyria 3.5 (
lyria-3.5, default) for complete tracks with timestamped transitions ([0:00 - 0:15] Intro...), multi-verse vocal delivery, or cinematic thematic development.
- Rapid Prototyping & Loops: Start with Lyria 3 Clip (
clip) to iterate quickly on genre combinations, tempos, and 30-second seamless loops.
Deep Technical References
Consult dedicated reference cards in references/ for detailed audio parameters, timing controls, and API schemas:
- references/lyria-3-5.md: Flagship specifications for full-length songs, rich vocal synthesis, and arrangements.
- references/lyria-3-clip.md: Specifications for 30-second clips, loops, and rapid prototyping.
- references/lyria-3-pro.md: Specifications for legacy full-length preview model, timestamp controls, and scoring.
- references/README.md: Musical composition prompt reference and index.
Core Execution Workflows
1. CLI Execution via scripts/lyria.py
Execute scripts/lyria.py with uv run:
# Generate a full song with Lyria 3.5 (default model)
uv run scripts/lyria.py \
-p "An energetic pop-rock song with driving drums and upbeat vocals" \
-f "song.mp3" \
-m "lyria-3.5" \
--lyrics-file "lyrics.txt"
# Generate a 30-second chiptune arcade loop with Lyria 3 Clip
uv run scripts/lyria.py \
-p "An energetic 8-bit chiptune arcade melody at 140 BPM in C major. Instrumental only." \
-f "chiptune.mp3" \
-m "clip"
# Multimodal Image-to-Music (compose music inspired by an image)
uv run scripts/lyria.py \
-p "Ambient relaxing soundscape matching the mood of this landscape. Instrumental only." \
-i "landscape.jpg" \
-f "landscape_theme.mp3" \
-m "lyria-3.5"
CLI Argument Reference
-p, --prompt: Text prompt describing style, genre, instruments, BPM, and structure (required).
-f, --filename: Output audio file path (default: music.mp3).
-m, --model: lyria-3.5 / 3.5 (default), clip / lyria-3-clip-preview, or pro / lyria-3-pro-preview.
-i, --input-image: Path to input image(s) for visual mood inspiration (up to 10).
--format: Audio container format (mp3 or wav).
--lyrics-file: Optional path to write generated lyric transcription / structure text.
--api: interactions (default) or models.
2. Dual SDK Integration Patterns
Interactions API (client.interactions.create) — Recommended
import base64
from google import genai
client = genai.Client()
# Generate full-length song with timestamp structure
prompt = """
An atmospheric lo-fi beat in D Minor at 80 BPM:
[0:00 - 0:15] Intro: Dusty vinyl crackle and mellow electric piano chords.
[0:15 - 0:45] Verse: Warm boom-bap drum groove enters with subtle bassline.
[0:45 - 1:15] Chorus: Full melodic progression with saxophone accents.
[1:15 - 1:30] Outro: Slow fade out with piano alone.
"""
interaction = client.interactions.create(
model="lyria-3.5",
input=prompt,
)
if interaction.output_audio:
with open("lofi_track.mp3", "wb") as f:
f.write(base64.b64decode(interaction.output_audio.data))
if interaction.output_text:
print("Generated Lyrics / Structure:\n", interaction.output_text)
Multimodal Image-to-Audio (Python)
import base64
from google import genai
client = genai.Client()
with open("art_concept.png", "rb") as f:
img_b64 = base64.b64encode(f.read()).decode("utf-8")
interaction = client.interactions.create(
model="lyria-3.5",
input=[
{"type": "image", "data": img_b64, "mime_type": "image/png"},
{"type": "text", "text": "Compose an ethereal cyberpunk synth soundtrack matching this neon cityscape. Instrumental only."},
],
)
if interaction.output_audio:
with open("cyberpunk_theme.mp3", "wb") as f:
f.write(base64.b64decode(interaction.output_audio.data))
Prompting Best Practices
- Genre & Subgenre: Be specific (e.g.
synthwave, delta blues, chamber pop, lo-fi hip-hop).
- Instrumentation: Name specific instruments (
Fender Rhodes, TR-808 drums, nylon-string guitar, cello).
- Tempo & Key: Include BPM and musical key (
120 BPM, in A Minor).
- Vocal Control: For instrumental tracks, explicitly specify
"Instrumental only, no vocals". For vocals, provide bracketed lyrics ([Verse], [Chorus]).
- Timestamp Arrangements: For Pro models, use bracketed timestamps (
[0:00 - 0:20]) to direct transitions and builds.
1---2name: lyria3description: Generative music and audio synthesis from text prompts or reference images using Google Lyria models. Generates 44.1 kHz stereo music clips, full songs with custom lyrics, and instrumental soundtracks using lyria-3.5 and lyria-3-clip-preview, with support for multimodal image inputs and MP3/WAV export. Activate when composing background music, generating songs, creating soundtracks from images, or producing AI audio clips.4license: Apache-2.05---67# Lyria Music Generation Skill89Generate high-fidelity **44.1 kHz stereo audio**, full songs with structured lyrics, instrumental soundtracks, and thematic compositions from text prompts or visual reference images using Google's **Lyria** foundation models (`lyria-3.5` and `lyria-3-clip-preview`).1011---1213## Available scripts1415- `scripts/lyria.py`: CLI tool for text-to-music and image-to-music generation, lyric export, and audio format conversion.16- `scripts/test_lyria.py`: Test suite verifying Lyria argument parsing and multimodal input limit enforcement.1718---1920## Trigger Conditions21Activate this skill whenever the user asks to:22- Generate music, songs, soundtracks, game audio beds, or background music.23- Compose musical themes inspired by artwork, concept photos, or screenshots.24- Create 30-second audio loops or multi-minute structured songs with verses, choruses, and custom lyrics.25- Synthesize instrumental audio tracks (`"Instrumental only, no vocals"`).2627---2829## Model Selection & Comparison Matrix3031| Model | Model ID | CLI Name | Primary Use Case | Duration | Audio Format | Reference Guide |32| :--- | :--- | :--- | :--- | :--- | :--- | :--- |33| **Lyria 3.5** | `lyria-3.5` | `lyria-3.5` / `3.5` | Flagship: full songs, expressive vocals, multi-section arrangements | Controllable (up to ~3m) | MP3, WAV | [lyria-3-5.md](references/lyria-3-5.md) |34| **Lyria 3 Clip** | `lyria-3-clip-preview` | `clip` | Short clips, loops, previews, rapid style testing | Exactly 30s | MP3, WAV | [lyria-3-clip.md](references/lyria-3-clip.md) |35| **Lyria 3 Pro** | `lyria-3-pro-preview` | `pro` | Legacy preview: multi-section arrangements, film scoring | Up to 184s | MP3, WAV | [lyria-3-pro.md](references/lyria-3-pro.md) |3637### Model Selection Guide38- **Full Song Production**: Use **Lyria 3.5** (`lyria-3.5`, default) for complete tracks with timestamped transitions (`[0:00 - 0:15] Intro...`), multi-verse vocal delivery, or cinematic thematic development.39- **Rapid Prototyping & Loops**: Start with **Lyria 3 Clip** (`clip`) to iterate quickly on genre combinations, tempos, and 30-second seamless loops.4041---4243## Deep Technical References4445Consult dedicated reference cards in `references/` for detailed audio parameters, timing controls, and API schemas:4647- **[references/lyria-3-5.md](references/lyria-3-5.md)**: Flagship specifications for full-length songs, rich vocal synthesis, and arrangements.48- **[references/lyria-3-clip.md](references/lyria-3-clip.md)**: Specifications for 30-second clips, loops, and rapid prototyping.49- **[references/lyria-3-pro.md](references/lyria-3-pro.md)**: Specifications for legacy full-length preview model, timestamp controls, and scoring.50- **[references/README.md](references/README.md)**: Musical composition prompt reference and index.5152---5354## Core Execution Workflows5556### 1. CLI Execution via `scripts/lyria.py`5758Execute `scripts/lyria.py` with `uv run`:5960```bash61# Generate a full song with Lyria 3.5 (default model)62uv run scripts/lyria.py \63 -p "An energetic pop-rock song with driving drums and upbeat vocals" \64 -f "song.mp3" \65 -m "lyria-3.5" \66 --lyrics-file "lyrics.txt"6768# Generate a 30-second chiptune arcade loop with Lyria 3 Clip69uv run scripts/lyria.py \70 -p "An energetic 8-bit chiptune arcade melody at 140 BPM in C major. Instrumental only." \71 -f "chiptune.mp3" \72 -m "clip"7374# Multimodal Image-to-Music (compose music inspired by an image)75uv run scripts/lyria.py \76 -p "Ambient relaxing soundscape matching the mood of this landscape. Instrumental only." \77 -i "landscape.jpg" \78 -f "landscape_theme.mp3" \79 -m "lyria-3.5"80```8182#### CLI Argument Reference83- `-p`, `--prompt`: Text prompt describing style, genre, instruments, BPM, and structure (required).84- `-f`, `--filename`: Output audio file path (default: `music.mp3`).85- `-m`, `--model`: `lyria-3.5` / `3.5` (default), `clip` / `lyria-3-clip-preview`, or `pro` / `lyria-3-pro-preview`.86- `-i`, `--input-image`: Path to input image(s) for visual mood inspiration (up to 10).87- `--format`: Audio container format (`mp3` or `wav`).88- `--lyrics-file`: Optional path to write generated lyric transcription / structure text.89- `--api`: `interactions` (default) or `models`.9091---9293### 2. Dual SDK Integration Patterns9495#### Interactions API (`client.interactions.create`) — Recommended9697```python98import base6499from google import genai100101client = genai.Client()102103# Generate full-length song with timestamp structure104prompt = """105An atmospheric lo-fi beat in D Minor at 80 BPM:106[0:00 - 0:15] Intro: Dusty vinyl crackle and mellow electric piano chords.107[0:15 - 0:45] Verse: Warm boom-bap drum groove enters with subtle bassline.108[0:45 - 1:15] Chorus: Full melodic progression with saxophone accents.109[1:15 - 1:30] Outro: Slow fade out with piano alone.110"""111112interaction = client.interactions.create(113 model="lyria-3.5",114 input=prompt,115)116117if interaction.output_audio:118 with open("lofi_track.mp3", "wb") as f:119 f.write(base64.b64decode(interaction.output_audio.data))120121if interaction.output_text:122 print("Generated Lyrics / Structure:\n", interaction.output_text)123```124125#### Multimodal Image-to-Audio (Python)126127```python128import base64129from google import genai130131client = genai.Client()132133with open("art_concept.png", "rb") as f:134 img_b64 = base64.b64encode(f.read()).decode("utf-8")135136interaction = client.interactions.create(137 model="lyria-3.5",138 input=[139 {"type": "image", "data": img_b64, "mime_type": "image/png"},140 {"type": "text", "text": "Compose an ethereal cyberpunk synth soundtrack matching this neon cityscape. Instrumental only."},141 ],142)143144if interaction.output_audio:145 with open("cyberpunk_theme.mp3", "wb") as f:146 f.write(base64.b64decode(interaction.output_audio.data))147```148149---150151## Prompting Best Practices1521. **Genre & Subgenre**: Be specific (e.g. `synthwave`, `delta blues`, `chamber pop`, `lo-fi hip-hop`).1532. **Instrumentation**: Name specific instruments (`Fender Rhodes`, `TR-808 drums`, `nylon-string guitar`, `cello`).1543. **Tempo & Key**: Include BPM and musical key (`120 BPM`, `in A Minor`).1554. **Vocal Control**: For instrumental tracks, explicitly specify `"Instrumental only, no vocals"`. For vocals, provide bracketed lyrics (`[Verse]`, `[Chorus]`).1565. **Timestamp Arrangements**: For Pro models, use bracketed timestamps (`[0:00 - 0:20]`) to direct transitions and builds.