使用 Lyria 3.5 生成音乐

Lyria 3.5 是 Google 的音乐创作模型系列,现已可通过 Gemini API 调用。借助 Lyria 3.5,您可以根据文本提示或图片生成高质量的 44.1 kHz 立体声音频。这些模型可提供结构一致性,包括人声、同步歌词和完整的乐器编排。

Lyria 系列包含以下模型:

模型 模型 ID 适用场景 时长 输出
Lyria 3 Clip lyria-3-clip-preview 短片、循环播放的视频、预览 30 秒 MP3
Lyria 3.5 lyria-3.5 包含主歌、副歌和桥段的完整歌曲 几分钟(可通过提示控制) MP3

这两种模型均可通过新的 Interactions API 使用,支持多模态输入(文本和图片),并生成 44.1 kHz 高保真立体声音频。

生成音乐片段

Lyria 3 Clip 模型始终生成 30 秒的片段。如需生成剪辑,请使用文本提示调用 interactions.create 方法。响应始终包含生成的歌词和歌曲结构,以及 steps 架构中的音频。

Python

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="lyria-3-clip-preview",
    input="A short instrumental acoustic guitar piece.",
)

generated_audio = interaction.output_audio
if generated_audio:
    with open("music.mp3", "wb") as f:
        f.write(base64.b64decode(generated_audio.data))

lyrics = interaction.output_text
if lyrics:
    print(f"Lyrics:\n{lyrics}")

JavaScript

import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
    model: 'lyria-3-clip-preview',
    input: 'A short instrumental acoustic guitar piece.',
});

const generatedAudio = interaction.output_audio;
if (generatedAudio) {
  fs.writeFileSync('music.mp3', Buffer.from(generatedAudio.data, 'base64'));
}

const lyrics = interaction.output_text;
if (lyrics) {
  console.log(`Lyrics:\n${lyrics}`);
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ResponseModality;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("lyria-3-generate-001"))
        .responseModalities(Arrays.asList(ResponseModality.AUDIO))
        .input(InteractionsInput.of("Upbeat electronic synthwave track"))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println("Audio generated: " + interaction.outputAudio().isPresent());

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "model": "lyria-3-clip-preview",
    "input": "A short instrumental acoustic guitar piece."
}'

您可以使用 interaction.output_audio 属性检索生成的音乐数据,该属性会返回上次生成的音频块。您还可以使用 interaction.output_text 属性检索歌曲的歌词和结构。如需详细了解便捷属性,请参阅互动概览

生成完整歌曲

使用 lyria-3.5 模型生成时长几分钟的完整歌曲。Pro 模型能理解音乐结构,并能创作出具有鲜明主歌、副歌和桥段的乐曲。您可以在提示中指定时长(例如“创作一首 2 分钟的歌曲”),也可以使用时间戳来定义结构,从而影响时长。

Python

interaction = client.interactions.create(
    model="lyria-3.5",
    input="An epic cinematic orchestral piece about a journey home. Starts with a solo piano intro, builds through sweeping strings, and climaxes with a massive wall of sound.",
)

JavaScript

const interaction = await client.interactions.create({
    model: 'lyria-3.5',
    input: 'A beautiful piano melody.',
});

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ResponseModality;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("lyria-3-generate-001"))
        .responseModalities(Arrays.asList(ResponseModality.AUDIO))
        .input(InteractionsInput.of("Upbeat electronic synthwave track"))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println("Audio generated: " + interaction.outputAudio().isPresent());

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "model": "lyria-3.5",
    "input": "A beautiful piano melody."
}'

选择输出格式

默认情况下,Lyria 3.5 模型会生成 MP3 格式的音频。对于 Lyria 3.5,您还可以通过设置 response_formatWAV 格式请求输出。

Python

interaction = client.interactions.create(
    model="lyria-3.5",
    input="A beautiful piano melody.",
    response_format={"type": "audio"},
)

JavaScript

const interaction = await client.interactions.create({
    model: 'lyria-3.5',
    input: 'A beautiful piano melody.',
    response_format: {
        type: 'audio',
    },
});

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ResponseModality;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("lyria-3-generate-001"))
        .responseModalities(Arrays.asList(ResponseModality.AUDIO))
        .input(InteractionsInput.of("Upbeat electronic synthwave track"))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println("Audio generated: " + interaction.outputAudio().isPresent());

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "lyria-3.5",
    "input": "A beautiful piano melody.",
    "response_format": {
        "type": "audio"
    }
  }'

解析响应

Lyria 3.5 的回答包含 steps 架构中的多个内容块。 互动会返回一系列步骤,其中 model_output 步包含生成的内容。文本内容块包含生成的歌词或歌曲结构的 JSON 说明。 类型为 audio 的内容块包含 base64 编码的音频数据。

Python

lyrics = []
audio_data = None

generated_audio = interaction.output_audio
if generated_audio:
    with open("output.mp3", "wb") as f:
        f.write(base64.b64decode(generated_audio.data))

lyrics = interaction.output_text
if lyrics:
    print(f"Lyrics:\n{lyrics}")

JavaScript

const lyrics = [];
let audioData = null;

const generatedAudio = interaction.output_audio;
if (generatedAudio) {
    fs.writeFileSync("output.mp3", Buffer.from(generatedAudio.data, 'base64'));
}

const lyrics = interaction.output_text;
if (lyrics) {
    console.log("Lyrics:\n" + lyrics);
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ResponseModality;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("lyria-3-generate-001"))
        .responseModalities(Arrays.asList(ResponseModality.AUDIO))
        .input(InteractionsInput.of("Upbeat electronic synthwave track"))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println("Audio generated: " + interaction.outputAudio().isPresent());

REST

# The output from the REST API is a JSON object containing base64 encoded data.
# You can extract the text or the audio data using a tool like jq.
# To extract the audio and save it to a file:
curl ... | jq -r '.steps[] | select(.type=="model_output") | .content[] | select(.type=="audio") | .data' | base64 -d > output.mp3

交错显示歌词和音乐

由于 Lyria 3.5 的输出较为复杂,包含生成歌词(文本)和歌曲本身(音频)的单独步骤和代码块,因此便利属性可提供快速且推荐的快捷方式。

不过,如果您想以程序化方式完全控制服务器返回的原始步进时间轴(例如在收到各个内容块时记录它们),可以手动迭代 steps

Python

lyrics = []
audio_data = None

for step in interaction.steps:
    if step.type == "model_output":
        for content_block in step.content:
            if content_block.type == "audio":
                audio_data = base64.b64decode(content_block.data)
            elif content_block.type == "text":
                lyrics.append(content_block.text)

if lyrics:
    print("Lyrics:\n" + "\n".join(lyrics))

if audio_data:
    with open("output.mp3", "wb") as f:
        f.write(audio_data)

JavaScript

const lyrics = [];
let audioData = null;

for (const step of interaction.steps) {
    if (step.type === 'model_output') {
        for (const contentBlock of step.content) {
            if (contentBlock.type === 'audio') {
                audioData = Buffer.from(contentBlock.data, 'base64');
            } else if (contentBlock.type === 'text') {
                lyrics.push(contentBlock.text);
            }
        }
    }
}

if (lyrics.length) {
    console.log("Lyrics:\n" + lyrics.join("\n"));
}

if (audioData) {
    fs.writeFileSync("output.mp3", audioData);
}

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ResponseModality;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("lyria-3-generate-001"))
        .responseModalities(Arrays.asList(ResponseModality.AUDIO))
        .input(InteractionsInput.of("Upbeat electronic synthwave track"))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println("Audio generated: " + interaction.outputAudio().isPresent());

根据图片生成音乐

Lyria 3.5 支持多模态输入 - 您可以在 input 列表中提供最多 10 张图片以及文本提示,模型将根据视觉内容创作音乐。

Python

import base64

with open("desert_sunset.jpg", "rb") as f:
    image_bytes = f.read()
    image_b64 = base64.b64encode(image_bytes).decode("utf-8")

response = client.interactions.create(
    model="lyria-3.5",
    input=[
        {
            "type": "text",
            "text": "An atmospheric ambient track inspired by the mood and colors in this image.",
        },
        {
            "type": "image",
            "mime_type": "image/jpeg",
            "data": image_b64,
        },
    ],
)

JavaScript

import * as fs from "fs";

const imageBytes = fs.readFileSync("desert_sunset.jpg").toString("base64");

const interaction = await client.interactions.create({
    model: "lyria-3.5",
    input: [
        {
            type: "text",
            text: "An atmospheric ambient track inspired by the mood and colors in this image.",
        },
        {
            type: "image",
            mime_type: "image/jpeg",
            data: imageBytes,
        },
    ],
});

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ResponseModality;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("lyria-3-generate-001"))
        .responseModalities(Arrays.asList(ResponseModality.AUDIO))
        .input(InteractionsInput.of("Upbeat electronic synthwave track"))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println("Audio generated: " + interaction.outputAudio().isPresent());

REST

# Pass base64 encoded image data directly:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "lyria-3.5",
    "input": [
      {"type": "text", "text": "An atmospheric ambient track inspired by the mood and colors in this image."},
      {"type": "image", "mime_type": "image/jpeg", "data": "/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wgALCAABAAEBAREA/8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABPxA="}
    ]
  }'

提供自定义歌词

您可以自行撰写歌词,并将其添加到提示中。使用 [Verse][Chorus][Bridge] 等部分标记,帮助模型了解歌曲结构:

Python

prompt = """
Create a dreamy indie pop song with the following lyrics:

[Verse 1]
Walking through the neon glow,
city lights reflect below,
every shadow tells a story,
every corner, fading glory.

[Chorus]
We are the echoes in the night,
burning brighter than the light,
hold on tight, don't let me go,
we are the echoes down below.

[Verse 2]
Footsteps lost on empty streets,
rhythms sync to heartbeats,
whispers carried by the breeze,
dancing through the autumn leaves.
"""

interaction = client.interactions.create(
    model="lyria-3.5",
    input=prompt,
)

JavaScript

const prompt = `
Create a dreamy indie pop song with the following lyrics:

[Verse 1]
Walking through the neon glow,
city lights reflect below,
every shadow tells a story,
every corner, fading glory.

[Chorus]
We are the echoes in the night,
burning brighter than the light,
hold on tight, don't let me go,
we are the echoes down below.

[Verse 2]
Footsteps lost on empty streets,
rhythms sync to heartbeats,
whispers carried by the breeze,
dancing through the autumn leaves.
`;

const interaction = await client.interactions.create({
    model: 'lyria-3.5',
    input: prompt,
});

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ResponseModality;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("lyria-3-generate-001"))
        .responseModalities(Arrays.asList(ResponseModality.AUDIO))
        .input(InteractionsInput.of("Upbeat electronic synthwave track"))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println("Audio generated: " + interaction.outputAudio().isPresent());

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "lyria-3.5",
    "input": "Create a dreamy indie pop song with the following lyrics: ..."
  }'

控制时间和结构

您可以使用时间戳来精确指定歌曲中特定时刻发生的情况。这有助于控制乐器何时进入、歌词何时出现以及歌曲的进展方式:

Python

prompt = """
[0:00 - 0:10] Intro: Begin with a soft lo-fi beat and muffled
              vinyl crackle.
[0:10 - 0:30] Verse 1: Add a warm Fender Rhodes piano melody
              and gentle vocals singing about a rainy morning.
[0:30 - 0:50] Chorus: Full band with upbeat drums and soaring
              synth leads. The lyrics are hopeful and uplifting.
[0:50 - 1:00] Outro: Fade out with the piano melody alone.
"""

interaction = client.interactions.create(
    model="lyria-3.5",
    input=prompt,
)

JavaScript

const prompt = `
[0:00 - 0:10] Intro: Begin with a soft lo-fi beat and muffled
              vinyl crackle.
[0:10 - 0:30] Verse 1: Add a warm Fender Rhodes piano melody
              and gentle vocals singing about a rainy morning.
[0:30 - 0:50] Chorus: Full band with upbeat drums and soaring
              synth leads. The lyrics are hopeful and uplifting.
[0:50 - 1:00] Outro: Fade out with the piano melody alone.
`;

const interaction = await client.interactions.create({
    model: 'lyria-3.5',
    input: prompt,
});

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ResponseModality;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("lyria-3-generate-001"))
        .responseModalities(Arrays.asList(ResponseModality.AUDIO))
        .input(InteractionsInput.of("Upbeat electronic synthwave track"))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println("Audio generated: " + interaction.outputAudio().isPresent());

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "lyria-3.5",
    "input": "[0:00 - 0:10] Intro: ..."
  }'

生成乐器演奏轨道

对于背景音乐、游戏配乐或不需要人声的任何使用场景,您可以提示模型生成纯乐器曲目:

Python

interaction = client.interactions.create(
    model="lyria-3-clip-preview",
    input="A bright chiptune melody in C Major, retro 8-bit video game style. Instrumental only, no vocals.",
)

JavaScript

const interaction = await client.interactions.create({
    model: 'lyria-3-clip-preview',
    input: 'A bright chiptune melody in C Major, retro 8-bit video game style. Instrumental only, no vocals.',
});

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ResponseModality;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("lyria-3-generate-001"))
        .responseModalities(Arrays.asList(ResponseModality.AUDIO))
        .input(InteractionsInput.of("Upbeat electronic synthwave track"))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println("Audio generated: " + interaction.outputAudio().isPresent());

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "lyria-3-clip-preview",
    "input": "A bright chiptune melody in C Major, retro 8-bit video game style. Instrumental only, no vocals."
  }'

生成不同语言的音乐

Lyria 3.5 会以提示所用的语言生成歌词。如需生成带有法语歌词的歌曲,请使用法语撰写提示。模型会调整其发音风格和发音,以匹配相应语言。

Python

interaction = client.interactions.create(
    model="lyria-3.5",
    input="Crée une chanson pop romantique en français sur un coucher de soleil à Paris. Utilise du piano et de la guitare acoustique.",
)

JavaScript

const interaction = await client.interactions.create({
    model: 'lyria-3.5',
    input: 'Crée une chanson pop romantique en français sur un coucher de soleil à Paris. Utilise du piano et de la guitare acoustique.',
});

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.ResponseModality;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.Arrays;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("lyria-3-generate-001"))
        .responseModalities(Arrays.asList(ResponseModality.AUDIO))
        .input(InteractionsInput.of("Upbeat electronic synthwave track"))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println("Audio generated: " + interaction.outputAudio().isPresent());

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "lyria-3.5",
    "input": "Crée une chanson pop romantique en français sur un coucher de soleil à Paris. Utilise du piano et de la guitare acoustique."
  }'

模型智能

Lyria 3.5 会分析提示处理过程,其中模型会根据提示推断音乐结构(前奏、主歌、副歌、桥段等)。 此过程在生成音频之前进行,可确保结构连贯性和音乐性。

提示指南

您的提示可以很简单,例如“一首关于可爱猫咪躲避水坑的民谣,女声演唱,有雨声”,也可以是详细且结构化的提示,例如:

一首 1980 年代风格的合成器流行乐,节奏强劲、合成器音色梦幻,副歌朗朗上口、气势恢宏。这首歌应具有复古未来主义风格,让人想起 80 年代的经典流行金曲,并采用现代制作手法进行润色。节奏应欢快且适合跳舞,约为 120 BPM,具有清晰的主歌-副歌结构和令人难忘的器乐钩子。歌词讲述的是准备参加派对时的心情。

无论是简单提示还是复杂提示,都可以生成出色的输出结果。不妨尝试一下这些技巧,看看哪种最适合您。

流派

在提示中首先指定您想要的音乐流派,例如嘻哈、摇滚和说唱。您可以指定多种流派:

  • 金属乐与说唱乐的融合
  • 死亡金属与歌剧的结合
  • 一首包含电子嗡鸣元素的古典乐曲
  • 将现代电子舞曲 (EDM) 与欧陆流行音乐相融合

您还可以添加纪元:

  • 90 年代初的嘻哈音乐
  • 60 年代法国 ye-ye 流行乐
  • 80 年代的电子实验音乐
  • 2000 年代主流流行音乐

如果您提示模型生成特定风格或区域变体,例如“柏林 techno”或“湾区 hyphy”,模型会尝试捕捉这些风格的精髓,但可能并不总是能准确把握。

乐器

默认情况下,Lyria 3.5 会使用您预期的乐器和工具来创作相应曲风的歌曲。您无需规定具体做法。

不过,除非您要求,否则舞曲不会包含萨克斯管。因此,如果您想要一段萨克斯独奏,需要向其发出提示:

一首舞曲,具有强劲的节拍、闪耀的合成器音效和抓耳的颂歌式合唱。萨克斯独奏应在过渡段中出现。

提示可以包含特定乐器、乐器的音效以及乐器之间的互动方式。您可以利用这种组合来营造特定的氛围或质感:

  • 浑浊失真的低音与清脆的高音镲相互抗衡
  • 温暖的模拟合成器音垫在干燥、亲密的原声吉他下方逐渐增强
  • 由多层模糊吉他打造的音墙,人声埋在其中,听起来很遥远

歌曲结构

您可以在提示中概述歌曲的进展。使用箭头或列表定义流程:

  • [Intro] -> [Verse 1] -> [Chorus] -> [Verse 2] -> [Chorus] -> [Bridge] -> [Outro]
  • 以安静的钢琴前奏开始,逐渐过渡到高亢的主歌,然后突然静音,最后进入高潮。

您还可以指定这些部分之间的能级变化方式:

  • 在副歌前段营造紧张感,然后在副歌开始前突然静音,让副歌的爆发更具震撼力
  • 整首歌曲逐渐达到高潮,每次添加一种乐器,直到形成混乱的音墙
  • 过渡段后突然停止,然后是无伴奏合唱

您还可以提示确切的时间,让设备在指定时间执行操作:

  • 在 12 秒时达到高潮
  • 每 2 秒钟就有人说“什么”
  • 合唱部分从 22 秒开始

歌词

默认情况下,系统会生成人声和歌词。您可以提供自己的歌词,也可以要求不提供歌词(或提供纯音乐),还可以引导歌词生成朝着您想要的方向发展。

歌词将采用您输入提示时所用的语言。您还可以要求以其他语言显示歌词,例如“用法语写歌词”。

使用您自己的歌词

如需向模型提供您自己的歌词,请在提示中添加这些歌词,并在前面加上“歌词:”前缀:

Lyrics:

[Intro]
Oooh, oooh

[Verse 1]
Let's go
Let's go
Go with the flow

[Chorus]
...

您可以在歌曲的各个部分添加前缀,例如 [Intro][Verse 1][Pre-chorus][Chorus][Outro] 等部分标题。

如果您希望某个字词或某行文字重复出现,例如像回声或伴唱一样,可以将其放在英文圆括号中,例如“Let's go (go)”。

提示模型撰写歌词

如果您希望 Lyria 3.5 为您创作歌词,最好在提示中包含有关歌词内容的详细信息。否则,模型需要根据音乐提示推断主题,而这可能不是您想要的。

歌词讲述的是失恋和心碎的痛苦。这位歌手回忆起过去的一段感情,以及随之涌现的记忆。

如果您想要重复的合唱,最好在提示中明确提出:

歌词讲述的是失恋和心碎的痛苦。这位歌手回忆起过去的一段感情,以及随之涌现的记忆。强劲的合唱部分着重表达了摆脱痛苦、继续前行的决心。

Lyria 3.5 会自动将歌词结构引导至您请求的音乐类型,但您也可以在提示中再次强调这一点。例如:

一首反复播放同一段充满活力的乐句的 EDM 音乐。

您还可以提示添加不属于歌词的音效,例如:

  • 电影中的一段重复采样在整首歌曲中不断重复,内容为“I can't believe this!”
  • 一首高能的 Techno 音乐,在 drop 之前,所有声音都停止了,一个小声音说“我不知道我在这里做什么”,然后音乐 drop 了。
  • 这首歌以一段关于 90 年代电影比现在更好的对话开场。然后,曲目会过渡到一首流行歌曲。

人声

您可以提示系统以何种方式呈现歌词。为获得最佳效果,请指定详细的歌手个人资料,包括性别、音色和音域。

  • 女高音:音色清澈透明,音质灵活高亢。能够发出空灵、气声感十足的哨音高音。
  • 女低音:低音浑厚、温暖、沙哑。烟嗓,略带气泡音,深情而富有共鸣。
  • 男高音:明亮、穿透力强、充满活力。音色年轻,略带鼻音,高音穿透力强,能穿透混音。
  • 男中音:深沉、醇厚、丝滑。共鸣胸腔声音,以舒缓的低吟方式传递。
  • 饱经风霜的摇滚歌手(男):音色沙哑粗犷,带有砾石般的音质,让人想起 90 年代的垃圾摇滚。情感强度过高,声音紧张。

其他提示参数

您还可以添加以下参数来进一步优化提示:

  • BPM:设置节奏(例如“120 BPM”“70 BPM 左右的慢节奏”)。
  • 调/音阶:指定音乐调(例如“G 大调”“D 小调”)。
  • 曲调和氛围:使用描述性的形容词(例如“怀旧”“激进”“空灵”“梦幻”)。
  • 时长:Clip 模型始终生成 30 秒的片段。对于 Pro 版,请在提示中指定所需的时长(例如“创作一首 2 分钟的歌曲”),或使用时间戳来控制时长。

示例提示

以下是一些有效提示的示例:

  • "A 30-second lofi hip hop beat with dusty vinyl crackle, mellow Rhodes piano chords, a slow boom-bap drum pattern at 85 BPM, and a jazzy upright bass line. Instrumental only."
  • "An upbeat, feel-good pop song in G major at 120 BPM with bright acoustic guitar strumming, claps, and warm vocal harmonies about a summer road trip."
  • "A dark, atmospheric trap beat at 140 BPM with heavy 808 bass, eerie synth pads, sharp hi-hats, and a haunting vocal sample. In D minor."

最佳做法

  • 先使用 Clip 进行迭代。使用速度更快的 lyria-3-clip-preview 模型来测试提示,然后再使用 lyria-3.5 生成完整内容。
  • 内容要具体。模糊的提示会产生泛泛的结果。提及乐器、BPM、调、情绪和结构,以获得最佳输出。
  • 语言保持一致。以您想要的歌词语言输入提示。
  • 使用部分标记。[Verse][Chorus][Bridge] 标记为模型提供了清晰的结构,以便模型遵循。
  • 将歌词与说明分开。提供自定义歌词时,请务必将其与音乐指导说明分开。

限制

  • 安全性:所有提示都会经过安全过滤器的检查。触发过滤条件的提示将被屏蔽。这包括要求使用特定音乐人声音或生成受版权保护的歌词的提示。
  • 水印:所有生成的音频都包含 SynthID 音频水印,以便进行识别。这种水印人耳无法察觉,不会影响聆听体验。
  • 多轮编辑:音乐创作是一个单轮过程。在当前版本的 Lyria 3.5 中,不支持通过多个提示迭代编辑或优化生成的剪辑。
  • 时长:Clip 模型始终生成 30 秒的片段。Pro 模型生成的歌曲时长为几分钟;确切时长会受到提示的影响。
  • 确定性:即使使用相同的提示,不同调用之间的结果也可能会有所不同。

后续步骤