Génération musicale avec Google Lyria 3

VérifiéPrudence

Générez des clips musicaux de 30 secondes ou des chansons complètes de 2-3 minutes avec Google Lyria 3 via l'API Gemini. Gratuit, contrôle du genre, BPM, instruments, ambiance.

Spar Skills Guide Bot
ContenuIntermédiaire
1024/07/2026
Claude Code
#music-generation#google-lyria#gemini-api#audio#creativity

Recommandé pour

Notre avis

Génère de la musique avec Google Lyria 3 via l'API Gemini, gratuitement. Permet de créer des clips de 30 secondes ou des chansons complètes de 2 à 3 minutes à partir de descriptions textuelles.

Points forts

  • Gratuit avec la clé API Gemini
  • Contrôle précis du genre, du tempo, des instruments et de l'ambiance
  • Production de fichiers MP3 de qualité studio
  • Deux modèles distincts pour clips ou chansons longues

Limites

  • Nécessite une installation préalable (clé API et SDK)
  • Limites de débit sur le niveau gratuit
  • La qualité des chansons longues peut être inégale
Quand l'utiliser

Lorsque vous avez besoin de générer rapidement de la musique originale pour des projets personnels, des prototypes ou des contenus créatifs sans compétences en composition musicale.

Quand l'éviter

Pour une production musicale professionnelle nécessitant un contrôle granulaire sur chaque piste ou un mixage avancé.

Analyse de sécurité

Prudence
Score qualité82/100

The skill uses bash to run a Python script with the user prompt stored in an environment variable via `PROMPT='$ARGUMENTS'`. If the prompt contains a single quote, it breaks out of the string and can inject shell commands. The note suggests escaping or using Write tool, but does not enforce safety. Since the user controls the input, risk is low if used carefully, but the vulnerability exists.

Points d'attention
  • Potential command injection via unsanitized single quotes in prompt when passed to PROMPT environment variable in shell, allowing arbitrary command execution if input contains single quote and command substitution.

Exemples

Lo-fi hip hop clip
Generate a 30-second lo-fi hip hop clip at 85 BPM with a Rhodes piano, soft vinyl crackle, and simple kick-snare drums, instrumental only, chill and nostalgic mood.
Synthwave song
Create a 2-minute synthwave song at 120 BPM in D minor with analog synthesizers, arpeggiated bass, and a retro drum machine. Energetic and neon-lit vibe, no vocals.
Acoustic folk song
Write a 3-minute acoustic folk song in G major with acoustic guitar, light percussion, and soft male vocals. Melancholic and introspective, with a verse-chorus structure.

name: make-music description: Generate music using Google Lyria 3 (FREE with Gemini API key). 30-second clips or full 2-3 minute songs from text prompts. Genre, BPM, instruments, mood - all controlled via prompt. argument-hint: <prompt describing the music you want> allowed-tools: Bash, Read, Write

Music Generation with Google Lyria 3 (FREE)

Generate 30-second music clips or full 2-3 minute songs using Google's Lyria 3 model via the Gemini API. Free tier — no cost.

Setup

  1. Get a free Gemini API key from Google AI Studio
  2. Set it as an environment variable:
    export GEMINI_API_KEY="your-key-here"
    
  3. Install the Google GenAI SDK:
    pip install google-genai
    

API Details

  • Model (clips): lyria-3-clip-preview — 30-second clips
  • Model (full songs): lyria-3-pro-preview — 2-3 minute complete songs
  • Output: MP3, 48kHz stereo, SynthID watermarked
  • Cost: FREE on Gemini free tier (rate limits apply)

Prompt Tips

Control everything through the text prompt:

  • Genre: "lo-fi hip hop", "synthwave", "jazz", "EDM", "acoustic folk"
  • BPM: "85 BPM", "120 BPM", "140 BPM"
  • Key: "C minor", "G major", "D minor pentatonic"
  • Instruments: "Rhodes piano", "TR-808 drums", "acoustic guitar", "analog synths"
  • Mood: "chill", "energetic", "melancholic", "triumphant", "dreamy"
  • Structure: [Intro], [Verse], [Chorus], [Bridge], [Outro]
  • Vocals: say "instrumental only" or "no vocals" to skip vocals
  • Timestamps: [0:00 - 0:10] Soft piano intro [0:10 - 0:25] Drums kick in

Usage

Run this inline Python script to generate music. The prompt is passed via the PROMPT env var and the Python body is a single-quoted heredoc — so the user's text can't break out of the Python string or inject code.

PROMPT='$ARGUMENTS' python3 - <<'PYEOF'
import os, time
from google import genai
from google.genai import types

key = os.environ.get('GEMINI_API_KEY')
if not key:
    print('ERROR: Set GEMINI_API_KEY environment variable first')
    print('Get a free key at: https://aistudio.google.com/apikey')
    exit(1)

client = genai.Client(api_key=key)
prompt = os.environ.get('PROMPT', '')
out_dir = os.path.join(os.path.expanduser('~'), '.claude-music-gen')
os.makedirs(out_dir, exist_ok=True)

response = client.models.generate_content(
    model='lyria-3-clip-preview',
    contents=prompt,
    config=types.GenerateContentConfig(response_modalities=['AUDIO', 'TEXT']),
)

ts = int(time.time())
for part in response.candidates[0].content.parts:
    if part.text:
        print(f'INFO: {part.text[:200]}')
    if part.inline_data:
        out = os.path.join(out_dir, f'music_{ts}.mp3')
        with open(out, 'wb') as f:
            f.write(part.inline_data.data)
        print(f'MUSIC: {out} ({len(part.inline_data.data) / 1024:.0f} KB)')
PYEOF

Full-Length Songs

For full 2-3 minute songs with verses/choruses, change the model to lyria-3-pro-preview:

PROMPT='$ARGUMENTS' python3 - <<'PYEOF'
import os, time
from google import genai
from google.genai import types

key = os.environ.get('GEMINI_API_KEY')
if not key:
    print('ERROR: Set GEMINI_API_KEY environment variable first')
    exit(1)

client = genai.Client(api_key=key)
prompt = os.environ.get('PROMPT', '')
out_dir = os.path.join(os.path.expanduser('~'), '.claude-music-gen')
os.makedirs(out_dir, exist_ok=True)

response = client.models.generate_content(
    model='lyria-3-pro-preview',
    contents=prompt,
    config=types.GenerateContentConfig(response_modalities=['AUDIO', 'TEXT']),
)

ts = int(time.time())
for part in response.candidates[0].content.parts:
    if part.text:
        print(f'INFO: {part.text[:200]}')
    if part.inline_data:
        out = os.path.join(out_dir, f'song_{ts}.mp3')
        with open(out, 'wb') as f:
            f.write(part.inline_data.data)
        print(f'SONG: {out} ({len(part.inline_data.data) / 1024:.0f} KB)')
PYEOF

Note: If your prompt contains a single quote ('), quote-escape it or use the Write tool to drop the prompt into a temp file first, then read that file in Python. The single-quoted heredoc protects the Python body but can't protect the outer PROMPT='...' assignment.

Rate Limits

  • Free tier has rate limits (be reasonable — add 30s between calls if generating multiple)
  • Clip model: always 30 seconds
  • Pro model: 2-3 minutes, full songs

Limitations

  • Non-deterministic (same prompt = different output each time)
  • Safety filters block copyrighted content or specific artist voice requests
  • Single-turn only (can't iteratively edit a track)

Requirements

  • Python 3.10+
  • google-genai SDK (pip install google-genai)
  • Free Gemini API key from Google AI Studio
Skills similaires