رفتن به متن مستندات
✦ایران جمینایمستندات فارسی Gemini
۲۶۸ صفحهٔ کامل فارسینسخهٔ فارسی ذخیره‌شده · دریافت 2026-09-29 · ۱۳ پیوند نامعتبر در منبع
پوشش مجموعه

ساخت موسیقی با Lyria 3.5

آخرین به‌روزرسانی منبع: 2026-09-18منبع Google

این متن دربارهٔ API رسمی Google است. نمونه‌کدها و آدرس‌ها بدون تغییر فنی حفظ شده‌اند؛ همهٔ امکانات Google الزاماً در API پل ایران‌جمینای ارائه نمی‌شوند. برای اتصال به پل، راهنمای «مستندات اتصال» فضای کاری را ببینید.

Lyria 3.5 خانواده‌ای از مدل‌های تولید موسیقی گوگل است که از طریق Gemini API در دسترس است. با Lyria 3.5، می‌توانید صدای استریو با کیفیت بالا و فرکانس ۴۴.۱ کیلوهرتز را از متن یا تصاویر تولید کنید. این مدل‌ها انسجام ساختاری، از جمله آواز، اشعار زمان‌بندی‌شده و تنظیم کامل سازها را ارائه می‌دهند.

خانواده لیریا شامل مدل‌های زیر است:

مدل شناسه مدل بهترین برای مدت زمان خروجی
کلیپ لیریا ۳ lyria-3-clip-preview کلیپ‌های کوتاه، حلقه‌ها، پیش‌نمایش‌ها ۳۰ ثانیه ام پی۳
لیریا ۳.۵ lyria-3.5 آهنگ‌های کامل با اشعار، همخوانی‌ها، پل‌ها چند دقیقه (قابل کنترل از طریق اعلان) ام پی۳

هر دو مدل می‌توانند با استفاده از روش استاندارد generateContent و API جدید Interactions ، با پشتیبانی از ورودی‌های چندوجهی (متن و تصویر) مورد استفاده قرار گیرند و صدای استریو با کیفیت بالا و وضوح ۴۴.۱ کیلوهرتز تولید کنند.

یک کلیپ موسیقی تولید کنید

مدل Lyria 3 Clip همیشه یک کلیپ 30 ثانیه‌ای تولید می‌کند. برای تولید یک کلیپ، متد generateContent را با یک اعلان متنی فراخوانی کنید. پاسخ همیشه شامل اشعار تولید شده و ساختار آهنگ در کنار صدا است.

پایتون

from google import genai

client = genai.Client()

response = client.models.generate_content(
    model="lyria-3-clip-preview",
    contents="Create a 30-second cheerful acoustic folk song with "
             "guitar and harmonica.",
)

# Parse the response
for part in response.parts:
    if part.text is not None:
        print(part.text)
    elif part.inline_data is not None:
        with open("clip.mp3", "wb") as f:
            f.write(part.inline_data.data)
        print("Audio saved to clip.mp3")

جاوا اسکریپت

import { GoogleGenAI } from "@google/genai";
import * as fs from "node:fs";

const ai = new GoogleGenAI({});

async function main() {
  const response = await ai.models.generateContent({
    model: "lyria-3-clip-preview",
    contents: "Create a 30-second cheerful acoustic folk song with " +
              "guitar and harmonica.",

  });

  for (const part of response.candidates[0].content.parts) {
    if (part.text) {
      console.log(part.text);
    } else if (part.inlineData) {
      const buffer = Buffer.from(part.inlineData.data, "base64");
      fs.writeFileSync("clip.mp3", buffer);
      console.log("Audio saved to clip.mp3");
    }
  }
}

main();

برو

package main

import (
    "context"
    "fmt"
    "log"
    "os"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    result, err := client.Models.GenerateContent(
        ctx,
        "lyria-3-clip-preview",
        genai.Text("Create a 30-second cheerful acoustic folk song " +
                   "with guitar and harmonica."),
        nil,
    )
    if err != nil {
        log.Fatal(err)
    }

    for _, part := range result.Candidates[0].Content.Parts {
        if part.Text != "" {
            fmt.Println(part.Text)
        } else if part.InlineData != nil {
            err := os.WriteFile("clip.mp3", part.InlineData.Data, 0644)
            if err != nil {
                log.Fatal(err)
            }
            fmt.Println("Audio saved to clip.mp3")
        }
    }
}

جاوا

import com.google.genai.Client;
import com.google.genai.types.GenerateContentResponse;
import com.google.genai.types.Part;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

public class GenerateMusicClip {
  public static void main(String[] args) throws IOException {

    try (Client client = new Client()) {
      GenerateContentResponse response = client.models.generateContent(
          "lyria-3-clip-preview",
          "Create a 30-second cheerful acoustic folk song with "
              + "guitar and harmonica.");

      for (Part part : response.parts()) {
        if (part.text().isPresent()) {
          System.out.println(part.text().get());
        } else if (part.inlineData().isPresent()) {
          var blob = part.inlineData().get();
          if (blob.data().isPresent()) {
            Files.write(Paths.get("clip.mp3"), blob.data().get());
            System.out.println("Audio saved to clip.mp3");
          }
        }
      }
    }
  }
}

استراحت

curl -s -X POST \
  "https://generativelanguage.googleapis.com/v1beta/models/lyria-3-clip-preview:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{
      "parts": [
        {"text": "Create a 30-second cheerful acoustic folk song with guitar and harmonica."}
      ]
    }]
  }'

سی شارپ

using System.Threading.Tasks;
using Google.GenAI;
using Google.GenAI.Types;
using System.IO;

public class GenerateMusicClip {
  public static async Task main() {
    var client = new Client();
    var response = await client.Models.GenerateContentAsync(
      model: "lyria-3-clip-preview",
      contents: "Create a 30-second cheerful acoustic folk song with guitar and harmonica."
    );

    foreach (var part in response.Candidates[0].Content.Parts) {
      if (part.Text != null) {
        Console.WriteLine(part.Text);
      } else if (part.InlineData != null) {
        await File.WriteAllBytesAsync("clip.mp3", part.InlineData.Data);
        Console.WriteLine("Audio saved to clip.mp3");
      }
    }
  }
}

یک آهنگ کامل بسازید

از مدل lyria-3.5 برای تولید آهنگ‌های کامل که چند دقیقه طول می‌کشند استفاده کنید. مدل Pro ساختار موسیقی را درک می‌کند و می‌تواند آهنگ‌هایی با بندها، ترجیع‌بندها و پل‌های متمایز ایجاد کند. می‌توانید با مشخص کردن مدت زمان در اعلان خود (مثلاً "ایجاد یک آهنگ ۲ دقیقه‌ای") یا با استفاده از مهرهای زمانی برای تعریف ساختار، بر مدت زمان تأثیر بگذارید.

پایتون

response = client.models.generate_content(
    model="lyria-3.5",
    contents="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.",
)

جاوا اسکریپت

const response = await ai.models.generateContent({
  model: "lyria-3.5",
  contents: "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.",

});

برو

result, err := client.Models.GenerateContent(
    ctx,
    "lyria-3.5",
    genai.Text("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."),
    nil,
)

جاوا

GenerateContentResponse response = client.models.generateContent(
    "lyria-3.5",
    "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.");

استراحت

curl -s -X POST \
  "https://generativelanguage.googleapis.com/v1beta/models/lyria-3.5:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{
      "parts": [
        {"text": "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."}
      ]
    }]
  }'

سی شارپ

var response = await client.Models.GenerateContentAsync(
  model: "lyria-3.5",
  contents: "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."
);

انتخاب فرمت خروجی

به طور پیش‌فرض، مدل‌های Lyria 3.5 صدا را با فرمت MP3 تولید می‌کنند. برای Lyria 3.5، می‌توانید با تنظیم response_format در generationConfig ، خروجی را با فرمت WAV نیز درخواست کنید.

پایتون

from google.genai import types

response = client.models.generate_content(
    model="lyria-3.5",
    contents="An atmospheric ambient track.",
    config=types.GenerateContentConfig(
        response_modalities=["AUDIO", "TEXT"],
        response_format={"audio": {"mime_type": "audio/wav"}},
    ),
)

جاوا اسکریپت

const response = await ai.models.generateContent({
  model: "lyria-3.5",
  contents: "An atmospheric ambient track.",
  config: {
    responseModalities: ["AUDIO", "TEXT"],
    responseFormat: { audio: { mimeType: "audio/wav" } },
  },
});

برو

config := &genai.GenerateContentConfig{
    ResponseModalities: []string{"AUDIO", "TEXT"},
    ResponseMIMEType:   "audio/wav",
}

result, err := client.Models.GenerateContent(
    ctx,
    "lyria-3.5",
    genai.Text("An atmospheric ambient track."),
    config,
)

جاوا

GenerateContentConfig config = GenerateContentConfig.builder()
    .responseModalities("AUDIO", "TEXT")
    .responseFormat(ResponseFormat.builder().audio(AudioFormat.builder().mimeType("audio/wav").build()).build())
    .build();

GenerateContentResponse response = client.models.generateContent(
    "lyria-3.5",
    "An atmospheric ambient track.",
    config);

سی شارپ

var config = new GenerateContentConfig {
  ResponseModalities = { "AUDIO", "TEXT" },
  ResponseMimeType = "audio/wav"
};

var response = await client.Models.GenerateContentAsync(
  model: "lyria-3.5",
  contents: "An atmospheric ambient track.",
  config: config
);

استراحت

curl -s -X POST \
  "https://generativelanguage.googleapis.com/v1beta/models/lyria-3.5:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{
      "parts": [
        {"text": "An atmospheric ambient track."}
      ]
    }],
    "generationConfig": {
      "responseModalities": ["AUDIO", "TEXT"],
      "responseFormat": { "audio": { "mimeType": "audio/wav" } }
    }
  }'

پاسخ را تجزیه کنید

پاسخ Lyria 3.5 شامل چندین بخش است. بخش‌های متنی شامل اشعار تولید شده یا توضیحات JSON از ساختار آهنگ هستند. بخش‌های دارای inline_data شامل بایت‌های صوتی هستند.

پایتون

lyrics = []
audio_data = None

for part in response.parts:
    if part.text is not None:
        lyrics.append(part.text)
    elif part.inline_data is not None:
        audio_data = part.inline_data.data

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

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

جاوا اسکریپت

const lyrics = [];
let audioData = null;

for (const part of response.candidates[0].content.parts) {
  if (part.text) {
    lyrics.push(part.text);
  } else if (part.inlineData) {
    audioData = Buffer.from(part.inlineData.data, "base64");
  }
}

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

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

برو

var lyrics []string
var audioData []byte

for _, part := range result.Candidates[0].Content.Parts {
    if part.Text != "" {
        lyrics = append(lyrics, part.Text)
    } else if part.InlineData != nil {
        audioData = part.InlineData.Data
    }
}

if len(lyrics) > 0 {
    fmt.Println("Lyrics:\n" + strings.Join(lyrics, "\n"))
}

if audioData != nil {
    err := os.WriteFile("output.mp3", audioData, 0644)
    if err != nil {
        log.Fatal(err)
    }
}

جاوا

List<String> lyrics = new ArrayList<>();
byte[] audioData = null;

for (Part part : response.parts()) {
  if (part.text().isPresent()) {
    lyrics.add(part.text().get());
  } else if (part.inlineData().isPresent()) {
    audioData = part.inlineData().get().data().get();
  }
}

if (!lyrics.isEmpty()) {
  System.out.println("Lyrics:\n" + String.join("\n", lyrics));
}

if (audioData != null) {
  Files.write(Paths.get("output.mp3"), audioData);
}

سی شارپ

var lyrics = new List<string>();
byte[] audioData = null;

foreach (var part in response.Candidates[0].Content.Parts) {
  if (part.Text != null) {
    lyrics.Add(part.Text);
  } else if (part.InlineData != null) {
    audioData = part.InlineData.Data;
  }
}

if (lyrics.Count > 0) {
  Console.WriteLine("Lyrics:\n" + string.Join("\n", lyrics));
}

if (audioData != null) {
  await File.WriteAllBytesAsync("output.mp3", audioData);
}

استراحت

# 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 '.candidates[0].content.parts[] | select(.inlineData) | .inlineData.data' | base64 -d > output.mp3

تولید موسیقی از تصاویر

Lyria 3.5 از ورودی‌های چندوجهی پشتیبانی می‌کند - شما می‌توانید تا 10 تصویر را در کنار متن خود ارائه دهید و مدل با الهام از محتوای بصری، موسیقی می‌سازد.

پایتون

from PIL import Image

image = Image.open("desert_sunset.jpg")

response = client.models.generate_content(
    model="lyria-3.5",
    contents=[
        "An atmospheric ambient track inspired by the mood and "
        "colors in this image.",
        image,
    ],
)

جاوا اسکریپت

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

const response = await ai.models.generateContent({
  model: "lyria-3.5",
  contents: [
    { text: "An atmospheric ambient track inspired by the mood " +
            "and colors in this image." },
    {
      inlineData: {
        mimeType: "image/jpeg",
        data: base64Image,
      },
    },
  ],

});

برو

imgData, err := os.ReadFile("desert_sunset.jpg")
if err != nil {
    log.Fatal(err)
}

parts := []*genai.Part{
    genai.NewPartFromText("An atmospheric ambient track inspired " +
        "by the mood and colors in this image."),
    &genai.Part{
        InlineData: &genai.Blob{
            MIMEType: "image/jpeg",
            Data:     imgData,
        },
    },
}

contents := []*genai.Content{
    genai.NewContentFromParts(parts, genai.RoleUser),
}

result, err := client.Models.GenerateContent(
    ctx,
    "lyria-3.5",
    contents,
    nil,
)

جاوا

GenerateContentResponse response = client.models.generateContent(
    "lyria-3.5",
    Content.fromParts(
        Part.fromText("An atmospheric ambient track inspired by "
            + "the mood and colors in this image."),
        Part.fromBytes(
            Files.readAllBytes(Path.of("desert_sunset.jpg")),
            "image/jpeg")));

استراحت

curl -s -X POST \
  "https://generativelanguage.googleapis.com/v1beta/models/lyria-3.5:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d "{
    \"contents\": [{
      \"parts\":[
          {\"text\": \"An atmospheric ambient track inspired by the mood and colors in this image.\"},
          {
            \"inline_data\": {
              \"mime_type\":\"image/jpeg\",
              \"data\": \"<BASE64_IMAGE_DATA>\"
            }
          }
      ]
    }]
  }"

سی شارپ

var response = await client.Models.GenerateContentAsync(
  model: "lyria-3.5",
  contents: new List<Part> {
    Part.FromText("An atmospheric ambient track inspired by the mood and colors in this image."),
    Part.FromBytes(await File.ReadAllBytesAsync("desert_sunset.jpg"), "image/jpeg")
  }
);

ارائه اشعار سفارشی

شما می‌توانید اشعار خودتان را بنویسید و آنها را در اعلان قرار دهید. از برچسب‌های بخش مانند [Verse] ، [Chorus] و [Bridge] برای کمک به مدل در درک ساختار آهنگ استفاده کنید:

پایتون

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.
"""

response = client.models.generate_content(
    model="lyria-3.5",
    contents=prompt,
)

جاوا اسکریپت

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 response = await ai.models.generateContent({
  model: "lyria-3.5",
  contents: prompt,

});

برو

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.
`

result, err := client.Models.GenerateContent(
    ctx,
    "lyria-3.5",
    genai.Text(prompt),
    nil,
)

جاوا

String 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.
    """;

GenerateContentResponse response = client.models.generateContent(
    "lyria-3.5",
    prompt);

سی شارپ

var 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.
";

var response = await client.Models.GenerateContentAsync(
  model: "lyria-3.5",
  contents: prompt
);

استراحت

curl -s -X POST \
  "https://generativelanguage.googleapis.com/v1beta/models/lyria-3.5:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{
      "parts": [
        {"text": "Create a dreamy indie pop song with the following lyrics: ..."}
      ]
    }]
  }'

کنترل زمان و ساختار

شما می‌توانید با استفاده از مهرهای زمانی دقیقاً مشخص کنید که در لحظات خاص آهنگ چه اتفاقی می‌افتد. این برای کنترل زمان ورود سازها، زمان اجرای اشعار و نحوه پیشرفت آهنگ مفید است:

پایتون

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.
"""

response = client.models.generate_content(
    model="lyria-3.5",
    contents=prompt,
)

جاوا اسکریپت

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 response = await ai.models.generateContent({
  model: "lyria-3.5",
  contents: prompt,

});

برو

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.
`

result, err := client.Models.GenerateContent(
    ctx,
    "lyria-3.5",
    genai.Text(prompt),
    nil,
)

جاوا

String 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.
    """;

GenerateContentResponse response = client.models.generateContent(
    "lyria-3.5",
    prompt);

سی شارپ

var 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.
";

var response = await client.Models.GenerateContentAsync(
  model: "lyria-3.5",
  contents: prompt
);

استراحت

curl -s -X POST \
  "https://generativelanguage.googleapis.com/v1beta/models/lyria-3.5:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{
      "parts": [
        {"text": "[0:00 - 0:10] Intro: ..."}
      ]
    }]
  }'

آهنگ‌های بی‌کلام تولید کنید

برای موسیقی پس‌زمینه، موسیقی متن بازی یا هر مورد استفاده‌ای که در آن نیازی به آواز نیست، می‌توانید مدل را طوری تنظیم کنید که فقط آهنگ‌های بی‌کلام تولید کند:

پایتون

response = client.models.generate_content(
    model="lyria-3-clip-preview",
    contents="A bright chiptune melody in C Major, retro 8-bit "
             "video game style. Instrumental only, no vocals.",
)

جاوا اسکریپت

const response = await ai.models.generateContent({
  model: "lyria-3-clip-preview",
  contents: "A bright chiptune melody in C Major, retro 8-bit " +
            "video game style. Instrumental only, no vocals.",

});

برو

result, err := client.Models.GenerateContent(
    ctx,
    "lyria-3-clip-preview",
    genai.Text("A bright chiptune melody in C Major, retro 8-bit " +
               "video game style. Instrumental only, no vocals."),
    nil,
)

جاوا

GenerateContentResponse response = client.models.generateContent(
    "lyria-3-clip-preview",
    "A bright chiptune melody in C Major, retro 8-bit "
        + "video game style. Instrumental only, no vocals.");

سی شارپ

var response = await client.Models.GenerateContentAsync(
  model: "lyria-3-clip-preview",
  contents: "A bright chiptune melody in C Major, retro 8-bit " +
            "video game style. Instrumental only, no vocals."
);

استراحت

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

تولید موسیقی به زبان‌های مختلف

Lyria 3.5 اشعار را به زبان سوال شما تولید می‌کند. برای تولید آهنگی با اشعار فرانسوی، سوال خود را به زبان فرانسوی بنویسید. این مدل سبک صوتی و تلفظ خود را برای مطابقت با زبان تطبیق می‌دهد.

پایتون

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

جاوا اسکریپت

const response = await ai.models.generateContent({
  model: "lyria-3.5",
  contents: "Crée une chanson pop romantique en français sur un " +
            "coucher de soleil à Paris. Utilise du piano et de " +
            "la guitare acoustique.",

});

برو

result, err := client.Models.GenerateContent(
    ctx,
    "lyria-3.5",
    genai.Text("Crée une chanson pop romantique en français sur un " +
               "coucher de soleil à Paris. Utilise du piano et de " +
               "la guitare acoustique."),
    nil,
)

جاوا

GenerateContentResponse response = client.models.generateContent(
    "lyria-3.5",
    "Crée une chanson pop romantique en français sur un "
        + "coucher de soleil à Paris. Utilise du piano et de "
        + "la guitare acoustique.");

سی شارپ

var response = await client.Models.GenerateContentAsync(
  model: "lyria-3.5",
  contents: "Crée une chanson pop romantique en français sur un " +
            "coucher de soleil à Paris. Utilise du piano et de " +
            "la guitare acoustique."
);

استراحت

curl -s -X POST \
  "https://generativelanguage.googleapis.com/v1beta/models/lyria-3.5:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{
      "parts": [
        {"text": "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 فرآیند اجرای شما را تجزیه و تحلیل می‌کند، به این صورت که مدل بر اساس ساختار موسیقی (مقدمه، مصراع، همخوانی، پل و غیره) بر اساس اجرای شما استدلال می‌کند. این کار قبل از تولید صدا انجام می‌شود و انسجام ساختاری و موسیقیایی بودن را تضمین می‌کند.

API تعاملات

شما می‌توانید از مدل‌های Lyria 3.5 با Interactions API استفاده کنید؛ یک رابط یکپارچه برای تعامل با مدل‌ها و عامل‌های Gemini. این رابط، مدیریت حالت و وظایف طولانی‌مدت را برای موارد استفاده پیچیده چندوجهی ساده می‌کند.

پایتون

import base64
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="lyria-3.5",
    input="A melancholic jazz fusion track in D minor, " +
          "featuring a smooth saxophone melody, walking bass line, " +
          "and complex drum rhythms.",
)

generated_audio = interaction.output_audio
if generated_audio:
    with open("interaction_output.mp3", "wb") as f:
        f.write(base64.b64decode(generated_audio.data))
    print("Audio saved to interaction_output.mp3")

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

جاوا اسکریپت

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

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
  model: 'lyria-3.5',
  input: 'A melancholic jazz fusion track in D minor, ' +
         'featuring a smooth saxophone melody, walking bass line, ' +
         'and complex drum rhythms.',
});

const generatedAudio = interaction.output_audio;
if (generatedAudio) {
  fs.writeFileSync('interaction_output.mp3', Buffer.from(generatedAudio.data, 'base64'));
  console.log('Audio saved to interaction_output.mp3');
}

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

استراحت

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 melancholic jazz fusion track in D minor, featuring a smooth saxophone melody, walking bass line, and complex drum rhythms."
}'

راهنمای راهنمایی

برای یادگیری نحوه‌ی ایجاد جملات انگیزشی مؤثر برای ژانرهای موسیقی، سازها، ساختار آهنگ، اشعار سفارشی و سبک‌های اجرای آوازی، به راهنمای جملات انگیزشی Lyria مراجعه کنید.

بهترین شیوه‌ها

  • ابتدا با Clip تکرار کنید. قبل از اینکه با lyria-3.5 به تولید کامل بپردازید، از مدل سریع‌تر lyria-3-clip-preview برای آزمایش دستورات استفاده کنید.
  • دقیق باشید. دستورالعمل‌های مبهم نتایج کلی ایجاد می‌کنند. برای بهترین خروجی، سازها، ریتم، گام، حال و هوا و ساختار را ذکر کنید.
  • زبان خود را مطابقت دهید. به زبانی که می‌خواهید متن آهنگ به آن باشد، درخواست دهید.
  • از تگ‌های بخش استفاده کنید. تگ‌های [Verse] ، [Chorus] ، [Bridge] به مدل ساختار واضحی برای دنبال کردن می‌دهند.
  • اشعار را از دستورالعمل‌ها جدا کنید. هنگام ارائه اشعار سفارشی، آنها را به وضوح از دستورالعمل‌های جهت‌گیری موسیقی خود جدا کنید.

محدودیت‌ها

  • ایمنی : همه درخواست‌ها توسط فیلترهای ایمنی بررسی می‌شوند. درخواست‌هایی که فیلترها را فعال می‌کنند مسدود خواهند شد. این شامل درخواست‌هایی می‌شود که صدای هنرمند خاصی را درخواست می‌کنند یا اشعار دارای حق چاپ را تولید می‌کنند.
  • واترمارک : تمام صداهای تولید شده شامل یک واترمارک صوتی SynthID برای شناسایی هستند. این واترمارک برای گوش انسان غیرقابل مشاهده است و بر تجربه شنیداری تأثیری نمی‌گذارد.
  • ویرایش چند مرحله‌ای : تولید موسیقی یک فرآیند تک مرحله‌ای است. ویرایش یا اصلاح مکرر یک کلیپ تولید شده از طریق چندین دستور در نسخه فعلی Lyria 3.5 پشتیبانی نمی‌شود.
  • مدت زمان : مدل کلیپ همیشه کلیپ‌های ۳۰ ثانیه‌ای تولید می‌کند. مدل پرو آهنگ‌هایی تولید می‌کند که چند دقیقه طول می‌کشند؛ مدت زمان دقیق را می‌توان از طریق اعلان شما تغییر داد.
  • جبرگرایی : نتایج ممکن است بین فراخوانی‌ها، حتی با یک درخواست یکسان، متفاوت باشد.

قدم بعدی چیست؟

منبع، ترجمه و مجوز

متن این صفحه از مستندات منتشرشده توسط Google بازنشر شده است؛ ترجمهٔ فارسی توسط Google Cloud Translation انجام شده و ممکن است خطا داشته باشد. این متن ترجمهٔ انسانی ایران‌جمینای نیست.

بازنشر متن طبق CC BY 4.0 و نمونه‌کدها طبق Apache 2.0، با رعایت استثناهای سیاست‌های Google انجام شده است. تغییرات ما: پاک‌سازی اجزای اجرایی، قالب‌بندی راست‌به‌چپ و محلی‌سازی پیوندهای مستندات. تصاویر، صدا، ویدیو و علائم تجاری با مجوز مستقل بازنشر نشده‌اند؛ پیوند منبع رسانه باقی مانده است.

صفحهٔ اصلی: ساخت موسیقی با Lyria 3.5

پوشش و وضعیت مجموعه

تمام صفحات HTML راهنماهای /gemini-api/docs و مرجع /api در نقشهٔ سایت رسمی Google، همراه پیوندهای داخلی مقالات؛ متن کامل فارسی و نمونه‌کدها. کتاب‌های آموزشی GitHub، گالری پرامپت، منابع خارجی، آرشیو قراردادهای حقوقی و رسانه‌های دارای مجوز جداگانه جزو بازنشر این مجموعه نیستند.

۲۶۸ صفحه از ۲۸۱ نشانی فهرست‌شده. نشانی‌های قدیمی ممکن است به محتوای یکسان هدایت شوند؛ تعداد بالا تعداد نشانی‌هاست، نه تعداد موضوعات یکتا. این مجموعه نسخهٔ ذخیره‌شده است و به‌روزرسانی زنده نیست.

۱۳ پیوند منبع که متن کامل آن قابل دریافت نیست