Lyria 2
Lyria 2 by Google DeepMind is an advanced model that generates high-fidelity 48kHz stereo instrumental music from text prompts or lyrics, offering precise control over tempo, key, mood, and structure.
API
If you're looking for an API, you can choose from your desired programming language.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import requests
import base64
# Use this function to convert an image file from the filesystem to base64
def image_file_to_base64(image_path):
with open(image_path, 'rb') as f:
image_data = f.read()
return base64.b64encode(image_data).decode('utf-8')
# Use this function to fetch an image from a URL and convert it to base64
def image_url_to_base64(image_url):
response = requests.get(image_url)
image_data = response.content
return base64.b64encode(image_data).decode('utf-8')
# Use this function to convert a list of image URLs to base64
def image_urls_to_base64(image_urls):
return [image_url_to_base64(url) for url in image_urls]
api_key = "YOUR_API_KEY"
url = "https://api.segmind.com/v1/lyria-2"
# Request payload
data = {
"prompt": "Melodious guitar with gentle rain background.",
"negative_prompt": "No loud drums, no vocals."
}
headers = {'x-api-key': api_key}
response = requests.post(url, json=data, headers=headers)
print(response.content) # The response is the generated image
Attributes
Directs audio creation with a detailed theme; guides tone and mood. Example: 'Melodious guitar with gentle rain background.'
Ensures audio consistency across generations. Use '123' for repeated serene outputs, or omit for surprise variations.
Excludes specific unwanted elements from the audio. Use 'No loud drums' for softer compositions, 'No vocals' for instrumentals.
To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.
Resources to get you started
Everything you need to know to get the most out of Lyria 2
# Getting the Most Out of Lyria 2: A Practical Usage Guide
Lyria 2 is a powerful, text-driven AI model for generating 48 kHz instrumental music. By carefully tuning your input and parameters, you can produce bespoke tracks for apps, games, content, and more. This guide walks you through prompt best practices, parameter settings, and example recipes for common use cases.
## 1. Crafting Effective Prompts
- Be specific about **mood**, **genre**, **tempo**, and **instrumentation**.
- Use evocative language: “Warm piano with distant thunder,” “Driving synth bass in a neon-soaked cityscape.”
- Limit punctuation and avoid ambiguous words. Short, vivid phrases deliver clear instructions.
## 2. Leveraging Negative Prompts
- Exclude undesired elements succinctly:
• “No vocals, no heavy drums” for ambient tracks
• “No brass, no sudden tempo changes” for meditation or spa apps
- Negative prompts help maintain focus on intended style.
## 3. Managing the Seed Parameter
- **Fixed seed (e.g. 42, 123)**
• Guarantees reproducible outputs—perfect for iterative edits or A/B testing.
- **Omit seed**
• Unlocks more creative variation on each generation request.
- For stable series (game levels or podcast intros), pick one seed and re-use it. For one-off experiments, let it float.
## 4. Suggested Parameter Sets by Use Case
| Use Case | Prompt Example | Negative Prompt | Seed | Notes |
|-------------------------|-------------------------------------------------------------|-----------------------------------|-------|------------------------------------------------------------|
| Meditation & Wellness | “Soothing ambient pad with soft chimes and water droplets.” | “No percussion, no sudden swells” | 42 | Consistent, calming atmosphere for apps and sessions. |
| Game Soundtrack (Exploration) | “Mystical forest harp arpeggios under soft wind rustle.” | “No drums, no vocals” | — | Omit seed for unique variations per level. |
| Trailer & Film Scoring | “Epic orchestral surge with pulsing strings and horns.” | “No electronic elements” | 2023 | Reproducible high-impact themes for marketing assets. |
| Background for Podcasts | “Light jazzy piano with brushed snare and upright bass.” | “No brass, no electric guitar” | — | Fresh loops—omit seed—and moderate complexity. |
| Interactive Web App | “Upbeat loop with plucked guitar and gentle claps.” | “No synth bass” | 7 | Fixed seed ensures seamless loop stitching. |
## 5. Integration Tips
- **Vertex AI & Gemini API**: Native endpoints for prompt submission, real-time streaming, and batching.
- **Latency & Streaming**: Use WebSocket for on-the-fly composition adjustments in demos or live apps.
- **Automation**: Script prompt variations and seed cycling to generate asset libraries in bulk.
By focusing on clear prompt design, strategic negative constraints, and flexible seed usage, you can harness Lyria 2’s full potential—whether you need reliable background loops, cinematic swells, or interactive soundscapes. Enjoy creating!
Other Popular Models
Discover other models you might be interested in.
sadtalker
Audio-based Lip Synchronization for Talking Head Video

faceswap-v2
Take a picture/gif and replace the face in it with a face of your choice. You only need one image of the desired face. No dataset, no training

sdxl-inpaint
This model is capable of generating photo-realistic images given any text input, with the extra capability of inpainting the pictures by using a mask

codeformer
CodeFormer is a robust face restoration algorithm for old photos or AI-generated faces.
