הבנת אודיו (רק לדיבור)

אתם יכולים להוסיף אודיו לבקשות ב-Gemini כדי לבצע משימות שדורשות הבנה של תוכן האודיו. בדף הזה מוסבר איך להוסיף אודיו לבקשות ל-Gemini ב-Gemini Enterprise Agent Platform באמצעות מסוףCloud de Confiance ו-Agent Platform API.

מודלים נתמכים

בטבלה הבאה מפורטים המודלים שתומכים בהבנת אודיו:

מודלים פרטים על המדיה סוגי MIME
  • אורך האודיו המקסימלי לכל הנחיה: כ-8.4 שעות, או עד מיליון טוקנים
  • מספר מקסימלי של קובצי אודיו לכל הנחיה: 1
  • הבנת דיבור לצורך: סיכום, תמלול ותרגום של אודיו
  • audio/x-aac
  • audio/flac
  • audio/mp3
  • audio/m4a
  • audio/mpeg
  • audio/mpga
  • audio/mp4
  • audio/ogg
  • audio/pcm
  • audio/wav
  • audio/webm
  • מספר מקסימלי של קובצי אודיו לכל הנחיה: 1-stream
  • פורמט קלט האודיו הנדרש: אודיו PCM גולמי של 16 ביט ב-16kHz, ‏ Little-endian
  • פורמט פלט האודיו הנדרש: אודיו PCM גולמי של 16 ביט ב-24kHz, ‏ Little-endian
  • audio/x-aac
  • audio/flac
  • audio/mp3
  • audio/m4a
  • audio/mpeg
  • audio/mpga
  • audio/mp4
  • audio/ogg
  • audio/pcm
  • audio/wav
  • audio/webm
  • audio/mpa
  • אורך האודיו המקסימלי לכל הנחיה: כ-8.4 שעות, או עד מיליון טוקנים
  • מספר מקסימלי של קובצי אודיו לכל הנחיה: 1
  • audio/x-aac
  • audio/flac
  • audio/mp3
  • audio/m4a
  • audio/mpeg
  • audio/mpga
  • audio/mp4
  • audio/ogg
  • audio/pcm
  • audio/wav
  • audio/webm
  • משך השיחה המקסימלי: ברירת המחדל היא 10 דקות, אבל אפשר להאריך את משך השיחה.
  • פורמט קלט האודיו הנדרש: אודיו PCM גולמי של 16 ביט ב-16kHz, ‏ Little-endian
  • פורמט פלט האודיו הנדרש: אודיו PCM גולמי של 16 ביט ב-24kHz, ‏ Little-endian
  • audio/x-aac
  • audio/flac
  • audio/mp3
  • audio/m4a
  • audio/mpeg
  • audio/mpga
  • audio/mp4
  • audio/ogg
  • audio/pcm
  • audio/wav
  • audio/webm

רשימת השפות שנתמכות במודלים של Gemini מופיעה במידע על המודלים של Google. איך מעצבים פרומפטים מולטי-מודאליים אם אתם מחפשים דרך להשתמש ב-Gemini ישירות מהאפליקציות לנייד ולאינטרנט, עיינו בערכות ה-SDK של לקוח Firebase AI Logic לאפליקציות Swift,‏ Android,‏ Web,‏ Flutter ו-Unity.

הוספת אודיו לבקשה

אתם יכולים להוסיף קובצי אודיו לבקשות שלכם ל-Gemini.

אודיו יחיד

כך משתמשים בקובץ אודיו כדי לסכם פודקאסט:

המסוף

כדי לשלוח פרומפט מולטי-מודאלי באמצעות מסוף Cloud de Confiance :

  1. בקטע Agent Platform במסוף Cloud de Confiance , נכנסים לדף Agent Studio.

    מעבר אל Agent Studio

  2. לוחצים על יצירת הנחיה.

  3. אופציונלי: מגדירים את המודל והפרמטרים:

    • מודל: בוחרים מודל.
  4. אופציונלי: כדי להגדיר פרמטרים מתקדמים, לוחצים על Advanced ומגדירים את הפרמטרים הבאים:

    לוחצים כדי להרחיב את ההגדרות המתקדמות.

    • ‫Top-K: משתמשים בפס ההזזה או בתיבת הטקסט כדי להזין ערך ל-Top-K.

      הערך של Top-K משנה את האופן שבו המודל בוחר אסימונים לפלט. אם ערך ה-Top-K הוא 1, האסימון הבא שנבחר הוא האסימון עם ההסתברות הכי גבוהה מבין כל האסימונים באוצר המילים של המודל (נקרא גם פענוח חמדני). אם ערך ה-Top-K הוא 3, האסימון הבא נבחר מבין שלושת האסימונים עם ההסתברות הכי גבוהה באמצעות טמפרטורה.

      בכל שלב של בחירת אסימון, נדגמים האסימונים עם ההסתברות הכי גבוהה ב-Top-K. לאחר מכן, האסימונים מסוננים עוד יותר על סמך top-P, והאסימון הסופי נבחר באמצעות דגימת טמפרטורה.

      כדי לקבל תשובות פחות אקראיות, מציינים ערך נמוך יותר. כדי לקבל תשובות יותר אקראיות, מציינים ערך גבוה יותר.

    • ‫Top-P: משתמשים בפס ההזזה או בתיבת הטקסט כדי להזין ערך ל-top-P. הטוקנים נבחרים מהסבירות הגבוהה ביותר לנמוכה ביותר, עד שסכום ההסתברויות שלהם שווה לערך של top-P. כדי לקבל את התוצאות הכי פחות משתנות, מגדירים את top-P לערך 0.
    • מספר מקסימלי של תשובות: משתמשים בפס ההזזה או בתיבת הטקסט כדי להזין ערך למספר התשובות שרוצים ליצור.
    • תשובות בסטרימינג: הפעילו את האפשרות הזו כדי להדפיס תשובות תוך כדי שהן נוצרות.
    • סף מסנן הבטיחות: בוחרים את הסף של הסבירות שיוצגו תשובות שעלולות להיות מזיקות.
    • הפעלת ביסוס: אין תמיכה בביסוס בפרומפטים מולטי-מודאליים.
    • Region: בוחרים את האזור שרוצים להשתמש בו.
    • טמפרטורה: משתמשים בפס ההזזה או בתיבת הטקסט כדי להזין ערך לטמפרטורה.

          
      The temperature is used for sampling during response generation, which occurs when topP
      and topK are applied. Temperature controls the degree of randomness in token selection.
      Lower temperatures are good for prompts that require a less open-ended or creative response, while
      higher temperatures can lead to more diverse or creative results. A temperature of 0
      means that the highest probability tokens are always selected. In this case, responses for a given
      prompt are mostly deterministic, but a small amount of variation is still possible.
      
      

      If the model returns a response that's too generic, too short, or the model gives a fallback response, try increasing the temperature. If the model enters infinite generation, increasing the temperature to at least 0.1 may lead to improved results.

      1.0 is the recommended starting value for temperature. </li> <li>**Output token limit**: Use the slider or textbox to enter a value for the max output limit. <p>Maximum number of tokens that can be generated in the response. A token is approximately four characters. 100 tokens correspond to roughly 60-80 words.</p> <p>Specify a lower value for shorter responses and a higher value for potentially longer responses.</p></li> <li>**Add stop sequence**: Optional. Enter a stop sequence, which is a series of characters that includes spaces. If the model encounters a stop sequence, the response generation stops. The stop sequence isn't included in the response, and you can add up to five stop sequences.</li> </ul>

  5. לוחצים על הוספת מדיה ובוחרים מקור לקובץ.

    העלאה

    בוחרים את הקובץ שרוצים להעלות ולוחצים על פתיחה.

    לפי כתובת URL

    מזינים את כתובת ה-URL של הקובץ שבו רוצים להשתמש ולוחצים על הוספה.

    Cloud Storage

    בוחרים את הקטגוריה ואז את הקובץ מהקטגוריה שרוצים לייבא, ולוחצים על Select.

    Google Drive

    1. בפעם הראשונה שבוחרים באפשרות הזו, צריך לבחור חשבון ולתת ל-Agent Studio הרשאת גישה אליו. אפשר להעלות כמה קבצים בגודל כולל של עד 10MB. הגודל המקסימלי של קובץ בודד הוא 7MB.
    2. לוחצים על הקובץ שרוצים להוסיף.
    3. לוחצים על בחירה.

      התמונה הממוזערת של הקובץ מוצגת בחלונית הנחיה. מוצג גם המספר הכולל של האסימונים. אם נתוני ההנחיה חורגים ממגבלת הטוקנים, הטוקנים נחתכים ולא נכללים בעיבוד הנתונים.

  6. מזינים את הפרומפט הטקסטואלי בחלונית הנחיה.

  7. אופציונלי: כדי לראות את מזהה טוקן לטקסט ואת מזהי טוקנים, לוחצים על כמות טוקנים בחלונית פרומפט.

  8. לוחצים על שליחה.

  9. אם רוצים לשמור את ההנחיה בההנחיות שלי, לוחצים על שמירה.

  10. אופציונלי: כדי לקבל את קוד Python או פקודת curl להנחיה, לוחצים על פיתוח באמצעות קוד > קבלת קוד.

Python

התקנה

pip install --upgrade google-genai

מידע נוסף זמין ב מאמרי העזרה של ה-SDK.

מגדירים משתני סביבה כדי להשתמש ב-Google Gen AI SDK עם Vertex AI:

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_ENTERPRISE=True

from google import genai
from google.genai.types import HttpOptions, Part

client = genai.Client(http_options=HttpOptions(api_version="v1"))
prompt = """
Provide a concise summary of the main points in the audio file.
"""
response = client.models.generate_content(
    model="gemini-3.5-flash",
    contents=[
        prompt,
        Part.from_uri(
            file_uri="gs://cloud-samples-data/generative-ai/audio/pixel.mp3",
            mime_type="audio/mpeg",
        ),
    ],
)
print(response.text)
# Example response:
# Here's a summary of the main points from the audio file:

# The Made by Google podcast discusses the Pixel feature drops with product managers Aisha Sheriff and De Carlos Love.  The key idea is that devices should improve over time, with a connected experience across phones, watches, earbuds, and tablets.

Go

איך מתקינים או מעדכנים את Go

מידע נוסף זמין ב מאמרי העזרה של ה-SDK.

מגדירים משתני סביבה כדי להשתמש ב-Google Gen AI SDK עם Vertex AI:

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_ENTERPRISE=True

import (
	"context"
	"fmt"
	"io"

	genai "google.golang.org/genai"
)

// generateWithAudio shows how to generate text using an audio input.
func generateWithAudio(w io.Writer) error {
	ctx := context.Background()

	client, err := genai.NewClient(ctx, &genai.ClientConfig{
		HTTPOptions: genai.HTTPOptions{APIVersion: "v1"},
	})
	if err != nil {
		return fmt.Errorf("failed to create genai client: %w", err)
	}

	modelName := "gemini-2.5-flash"
	contents := []*genai.Content{
		{Parts: []*genai.Part{
			{Text: `Provide the summary of the audio file.
Summarize the main points of the audio concisely.
Create a chapter breakdown with timestamps for key sections or topics discussed.`},
			{FileData: &genai.FileData{
				FileURI:  "gs://cloud-samples-data/generative-ai/audio/pixel.mp3",
				MIMEType: "audio/mpeg",
			}},
		},
			Role: genai.RoleUser},
	}

	resp, err := client.Models.GenerateContent(ctx, modelName, contents, nil)
	if err != nil {
		return fmt.Errorf("failed to generate content: %w", err)
	}

	respText := resp.Text()

	fmt.Fprintln(w, respText)

	// Example response:
	// Here is a summary and chapter breakdown of the audio file:
	//
	// **Summary:**
	//
	// The audio file is a "Made by Google" podcast episode discussing the Pixel Feature Drops, ...
	//
	// **Chapter Breakdown:**
	//
	// *   **0:00 - 0:54:** Introduction to the podcast and guests, Aisha Sharif and DeCarlos Love.
	// ...

	return nil
}

Node.js

התקנה

npm install @google/genai

מידע נוסף זמין ב מאמרי העזרה של ה-SDK.

מגדירים משתני סביבה כדי להשתמש ב-Google Gen AI SDK עם Vertex AI:

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_ENTERPRISE=True

const {GoogleGenAI} = require('@google/genai');

const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT;
const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global';

async function generateText(
  projectId = GOOGLE_CLOUD_PROJECT,
  location = GOOGLE_CLOUD_LOCATION
) {
  const client = new GoogleGenAI({
    vertexai: true,
    project: projectId,
    location: location,
  });

  const prompt =
    'Provide a concise summary of the main points in the audio file.';

  const response = await client.models.generateContent({
    model: 'gemini-2.5-flash',
    contents: [
      {
        fileData: {
          fileUri: 'gs://cloud-samples-data/generative-ai/audio/pixel.mp3',
          mimeType: 'audio/mpeg',
        },
      },
      {text: prompt},
    ],
  });

  console.log(response.text);

  // Example response:
  //  Here's a summary of the main points from the audio file:
  //  The Made by Google podcast discusses the Pixel feature drops with product managers Aisha Sheriff and De Carlos Love.  The key idea is that devices should improve over time, with a connected experience across phones, watches, earbuds, and tablets.

  return response.text;
}

Java

איך מתקינים או מעדכנים את Java

מידע נוסף זמין ב מאמרי העזרה של ה-SDK.

מגדירים משתני סביבה כדי להשתמש ב-Google Gen AI SDK עם Vertex AI:

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_ENTERPRISE=True


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

public class TextGenerationWithGcsAudio {

  public static void main(String[] args) {
    // TODO(developer): Replace these variables before running the sample.
    String modelId = "gemini-2.5-flash";
    generateContent(modelId);
  }

  // Generates text with audio input
  public static String generateContent(String modelId) {
    // Client Initialization. Once created, it can be reused for multiple requests.
    try (Client client =
        Client.builder()
            .location("global")
            .vertexAI(true)
            .httpOptions(HttpOptions.builder().apiVersion("v1").build())
            .build()) {

      GenerateContentResponse response =
          client.models.generateContent(
              modelId,
              Content.fromParts(
                  Part.fromUri(
                      "gs://cloud-samples-data/generative-ai/audio/pixel.mp3", "audio/mpeg"),
                  Part.fromText("Provide a concise summary of the main points in the audio file.")),
              null);

      System.out.print(response.text());
      // Example response:
      // The audio features Google product managers Aisha Sharif and D. Carlos Love discussing Pixel
      // Feature Drops, emphasizing their role in continually enhancing devices across the entire
      // Pixel ecosystem...
      return response.text();
    }
  }
}

REST

אחרי שמגדירים את הסביבה, אפשר להשתמש ב-REST כדי לבדוק פרומפט טקסטואלי. בדוגמה הבאה נשלחת בקשה לנקודת הקצה של המודל של בעל התוכן הדיגיטלי.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • ‫PROJECT_ID: מזהה הפרויקט. .
  • ‫FILE_URI: ה-URI או כתובת ה-URL של הקובץ שרוצים לכלול בהנחיה. הערכים הקבילים כוללים:
    • ‫URI של קטגוריה ב-Cloud Storage: האובייקט צריך להיות קריא באופן ציבורי או להיות באותו פרויקט ב- Cloud de Confiance ששולח את הבקשה.
    • כתובת URL מסוג HTTP: כתובת ה-URL של הקובץ צריכה להיות ניתנת לקריאה באופן ציבורי. בכל בקשה אפשר לציין קובץ וידאו אחד, קובץ אודיו אחד ועד 10 קובצי תמונות. הגודל המקסימלי של קובצי אודיו, קובצי וידאו ומסמכים הוא 15MB.
    • כתובת ה-URL של הסרטון ב-YouTube: הסרטון ב-YouTube צריך להיות בבעלות החשבון שבו השתמשתם כדי להיכנס למסוף Cloud de Confiance , או להיות גלוי לכולם. אפשר להוסיף רק כתובת URL אחת של סרטון ב-YouTube לכל בקשה.

    כשמציינים fileURI, צריך לציין גם את סוג המדיה (mimeType) של הקובץ. אם VPC Service Controls מופעל, אי אפשר לציין כתובת URL של קובץ מדיה בשביל fileURI.

    אם אין לכם קובץ אודיו ב-Cloud Storage, אתם יכולים להשתמש בקובץ הציבורי הבא: gs://cloud-samples-data/generative-ai/audio/pixel.mp3 עם סוג MIME‏ audio/mp3. כדי להאזין לאודיו הזה, פתחו את קובץ ה-MP3 לדוגמה.

  • ‫MIME_TYPE: סוג המדיה של הקובץ שצוין בשדות fileUri. הערכים הקבילים כוללים:

    לחצו כדי להרחיב את סוגי ה-MIME

    • application/pdf
    • audio/mpeg
    • audio/mp3
    • audio/wav
    • image/png
    • image/jpeg
    • image/webp
    • text/plain
    • video/mov
    • video/mpeg
    • video/mp4
    • video/mpg
    • video/avi
    • video/wmv
    • video/mpegps
    • video/flv
  • ‫
    TEXT
    ההוראות בטקסט שצריך לכלול בהנחיה. לדוגמה, Please provide a summary for the audio. Provide chapter titles, be concise and short, no need to provide chapter summaries. Do not make up any information that is not part of the audio and do not be verbose.

כדי לשלוח את הבקשה אתם צריכים לבחור אחת מהאפשרויות הבאות:

curl

שומרים את גוף הבקשה בקובץ בשם request.json. כדי ליצור או להחליף את הקובץ הזה בספרייה הנוכחית, מריצים את הפקודה הבאה בטרמינל:

cat > request.json << 'EOF'
{
  "contents": {
    "role": "USER",
    "parts": [
      {
        "fileData": {
          "fileUri": "FILE_URI",
          "mimeType": "MIME_TYPE"
        }
      },
      {
        "text": "TEXT"
      }
    ]
  }
}
EOF

לאחר מכן מבצעים את הפקודה הבאה כדי לשלוח את בקשת ה-REST:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/global/publishers/google/models/gemini-3.5-flash:generateContent"

PowerShell

שומרים את גוף הבקשה בקובץ בשם request.json. כדי ליצור או להחליף את הקובץ הזה בספרייה הנוכחית, מריצים את הפקודה הבאה בטרמינל:

@'
{
  "contents": {
    "role": "USER",
    "parts": [
      {
        "fileData": {
          "fileUri": "FILE_URI",
          "mimeType": "MIME_TYPE"
        }
      },
      {
        "text": "TEXT"
      }
    ]
  }
}
'@  | Out-File -FilePath request.json -Encoding utf8

לאחר מכן מבצעים את הפקודה הבאה כדי לשלוח את בקשת ה-REST:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/global/publishers/google/models/gemini-3.5-flash:generateContent" | Select-Object -Expand Content

אתם אמורים לקבל תגובת JSON שדומה לזו:

שימו לב לפרטים הבאים בכתובת ה-URL של הדוגמה הזו:
  • משתמשים ב-method‏ generateContent כדי לבקש שהתשובה תוחזר אחרי שהיא נוצרת במלואה. כדי להפחית את תפיסת זמן האחזור בקרב קהל אנושי, אפשר להעביר בסטרימינג את התשובה בזמן שהיא נוצרת באמצעות השיטה streamGenerateContent.
  • המזהה של המודל המולטי-מודאלי נמצא בסוף כתובת ה-URL לפני ה-method (לדוגמה, gemini-3.5-flash). יכול להיות שהדוגמה הזו תומכת גם במודלים אחרים.
  • כשמשתמשים בנקודת קצה אזורית ל-API (לדוגמה, us-central1), האזור מכתובת ה-URL של נקודת הקצה קובע איפה הבקשה תעובד. המערכת מתעלמת מכל מיקום שמתנגש בנתיב המשאב.

תמלול אודיו

כך משתמשים בקובץ אודיו כדי לתמלל ראיון. כדי להפעיל את הבנת חותמות הזמן בקובצי אודיו בלבד, מפעילים את הפרמטר audioTimestamp ב-GenerationConfig:

המסוף

כדי לשלוח פרומפט מולטי-מודאלי באמצעות מסוף Cloud de Confiance :

  1. בקטע Agent Platform במסוף Cloud de Confiance , נכנסים לדף Agent Studio.

    מעבר אל Agent Studio

  2. לוחצים על יצירת הנחיה.

  3. אופציונלי: מגדירים את המודל והפרמטרים:

    • מודל: בוחרים מודל.
  4. אופציונלי: כדי להגדיר פרמטרים מתקדמים, לוחצים על Advanced ומגדירים את הפרמטרים הבאים:

    לוחצים כדי להרחיב את ההגדרות המתקדמות.

    • ‫Top-K: משתמשים בפס ההזזה או בתיבת הטקסט כדי להזין ערך ל-Top-K.

      הערך של Top-K משנה את האופן שבו המודל בוחר אסימונים לפלט. אם ערך ה-Top-K הוא 1, האסימון הבא שנבחר הוא האסימון עם ההסתברות הכי גבוהה מבין כל האסימונים באוצר המילים של המודל (נקרא גם פענוח חמדני). אם ערך ה-Top-K הוא 3, האסימון הבא נבחר מבין שלושת האסימונים עם ההסתברות הכי גבוהה באמצעות טמפרטורה.

      בכל שלב של בחירת אסימון, נדגמים האסימונים עם ההסתברות הכי גבוהה ב-Top-K. לאחר מכן, האסימונים מסוננים עוד יותר על סמך top-P, והאסימון הסופי נבחר באמצעות דגימת טמפרטורה.

      כדי לקבל תשובות פחות אקראיות, מציינים ערך נמוך יותר. כדי לקבל תשובות יותר אקראיות, מציינים ערך גבוה יותר.

    • ‫Top-P: משתמשים בפס ההזזה או בתיבת הטקסט כדי להזין ערך ל-top-P. הטוקנים נבחרים מהסבירות הגבוהה ביותר לנמוכה ביותר, עד שסכום ההסתברויות שלהם שווה לערך של top-P. כדי לקבל את התוצאות הכי פחות משתנות, מגדירים את top-P לערך 0.
    • מספר מקסימלי של תשובות: משתמשים בפס ההזזה או בתיבת הטקסט כדי להזין ערך למספר התשובות שרוצים ליצור.
    • תשובות בסטרימינג: הפעילו את האפשרות הזו כדי להדפיס תשובות תוך כדי שהן נוצרות.
    • סף מסנן הבטיחות: בוחרים את הסף של הסבירות שיוצגו תשובות שעלולות להיות מזיקות.
    • הפעלת ביסוס: אין תמיכה בביסוס בפרומפטים מולטי-מודאליים.
    • Region: בוחרים את האזור שרוצים להשתמש בו.
    • טמפרטורה: משתמשים בפס ההזזה או בתיבת הטקסט כדי להזין ערך לטמפרטורה.

          
      The temperature is used for sampling during response generation, which occurs when topP
      and topK are applied. Temperature controls the degree of randomness in token selection.
      Lower temperatures are good for prompts that require a less open-ended or creative response, while
      higher temperatures can lead to more diverse or creative results. A temperature of 0
      means that the highest probability tokens are always selected. In this case, responses for a given
      prompt are mostly deterministic, but a small amount of variation is still possible.
      
      

      If the model returns a response that's too generic, too short, or the model gives a fallback response, try increasing the temperature. If the model enters infinite generation, increasing the temperature to at least 0.1 may lead to improved results.

      1.0 is the recommended starting value for temperature. </li> <li>**Output token limit**: Use the slider or textbox to enter a value for the max output limit. <p>Maximum number of tokens that can be generated in the response. A token is approximately four characters. 100 tokens correspond to roughly 60-80 words.</p> <p>Specify a lower value for shorter responses and a higher value for potentially longer responses.</p></li> <li>**Add stop sequence**: Optional. Enter a stop sequence, which is a series of characters that includes spaces. If the model encounters a stop sequence, the response generation stops. The stop sequence isn't included in the response, and you can add up to five stop sequences.</li> </ul>

  5. לוחצים על הוספת מדיה ובוחרים מקור לקובץ.

    העלאה

    בוחרים את הקובץ שרוצים להעלות ולוחצים על פתיחה.

    לפי כתובת URL

    מזינים את כתובת ה-URL של הקובץ שבו רוצים להשתמש ולוחצים על הוספה.

    Cloud Storage

    בוחרים את הקטגוריה ואז את הקובץ מהקטגוריה שרוצים לייבא, ולוחצים על Select.

    Google Drive

    1. בפעם הראשונה שבוחרים באפשרות הזו, צריך לבחור חשבון ולתת ל-Agent Studio הרשאת גישה אליו. אפשר להעלות כמה קבצים בגודל כולל של עד 10MB. הגודל המקסימלי של קובץ בודד הוא 7MB.
    2. לוחצים על הקובץ שרוצים להוסיף.
    3. לוחצים על בחירה.

      התמונה הממוזערת של הקובץ מוצגת בחלונית הנחיה. מוצג גם המספר הכולל של האסימונים. אם נתוני ההנחיה חורגים ממגבלת הטוקנים, הטוקנים נחתכים ולא נכללים בעיבוד הנתונים.

  6. מזינים את הפרומפט הטקסטואלי בחלונית הנחיה.

  7. אופציונלי: כדי לראות את מזהה טוקן לטקסט ואת מזהי טוקנים, לוחצים על כמות טוקנים בחלונית פרומפט.

  8. לוחצים על שליחה.

  9. אם רוצים לשמור את ההנחיה בההנחיות שלי, לוחצים על שמירה.

  10. אופציונלי: כדי לקבל את קוד Python או פקודת curl להנחיה, לוחצים על פיתוח באמצעות קוד > קבלת קוד.

Python

התקנה

pip install --upgrade google-genai

מידע נוסף זמין ב מאמרי העזרה של ה-SDK.

מגדירים משתני סביבה כדי להשתמש ב-Google Gen AI SDK עם Vertex AI:

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_ENTERPRISE=True

from google import genai
from google.genai.types import GenerateContentConfig, HttpOptions, Part

client = genai.Client(http_options=HttpOptions(api_version="v1"))
prompt = """
Transcribe the interview, in the format of timecode, speaker, caption.
Use speaker A, speaker B, etc. to identify speakers.
"""
response = client.models.generate_content(
    model="gemini-3.5-flash",
    contents=[
        prompt,
        Part.from_uri(
            file_uri="gs://cloud-samples-data/generative-ai/audio/pixel.mp3",
            mime_type="audio/mpeg",
        ),
    ],
    # Required to enable timestamp understanding for audio-only files
    config=GenerateContentConfig(audio_timestamp=True),
)
print(response.text)
# Example response:
# [00:00:00] **Speaker A:** your devices are getting better over time. And so ...
# [00:00:14] **Speaker B:** Welcome to the Made by Google podcast where we meet ...
# [00:00:20] **Speaker B:** Here's your host, Rasheed Finch.
# [00:00:23] **Speaker C:** Today we're talking to Aisha Sharif and DeCarlos Love. ...
# ...

Go

איך מתקינים או מעדכנים את Go

מידע נוסף זמין ב מאמרי העזרה של ה-SDK.

מגדירים משתני סביבה כדי להשתמש ב-Google Gen AI SDK עם Vertex AI:

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_ENTERPRISE=True

import (
	"context"
	"fmt"
	"io"

	genai "google.golang.org/genai"
)

// generateAudioTranscript shows how to generate an audio transcript.
func generateAudioTranscript(w io.Writer) error {
	ctx := context.Background()

	client, err := genai.NewClient(ctx, &genai.ClientConfig{
		HTTPOptions: genai.HTTPOptions{APIVersion: "v1"},
	})
	if err != nil {
		return fmt.Errorf("failed to create genai client: %w", err)
	}

	modelName := "gemini-2.5-flash"
	contents := []*genai.Content{
		{Parts: []*genai.Part{
			{Text: `Transcribe the interview, in the format of timecode, speaker, caption.
Use speaker A, speaker B, etc. to identify speakers.`},
			{FileData: &genai.FileData{
				FileURI:  "gs://cloud-samples-data/generative-ai/audio/pixel.mp3",
				MIMEType: "audio/mpeg",
			}},
		},
			Role: genai.RoleUser},
	}

	resp, err := client.Models.GenerateContent(ctx, modelName, contents, nil)
	if err != nil {
		return fmt.Errorf("failed to generate content: %w", err)
	}

	respText := resp.Text()

	fmt.Fprintln(w, respText)

	// Example response:
	// 00:00:00, A: your devices are getting better over time.
	// 00:01:13, A: And so we think about it across the entire portfolio from phones to watch, ...
	// ...

	return nil
}

Node.js

התקנה

npm install @google/genai

מידע נוסף זמין ב מאמרי העזרה של ה-SDK.

מגדירים משתני סביבה כדי להשתמש ב-Google Gen AI SDK עם Vertex AI:

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_ENTERPRISE=True

const {GoogleGenAI} = require('@google/genai');

const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT;
const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global';

async function generateText(
  projectId = GOOGLE_CLOUD_PROJECT,
  location = GOOGLE_CLOUD_LOCATION
) {
  const client = new GoogleGenAI({
    vertexai: true,
    project: projectId,
    location: location,
  });

  const prompt = `Transcribe the interview, in the format of timecode, speaker, caption.
    Use speaker A, speaker B, etc. to identify speakers.`;

  const response = await client.models.generateContent({
    model: 'gemini-2.5-flash',
    contents: [
      {text: prompt},
      {
        fileData: {
          fileUri: 'gs://cloud-samples-data/generative-ai/audio/pixel.mp3',
          mimeType: 'audio/mpeg',
        },
      },
    ],
    // Required to enable timestamp understanding for audio-only files
    config: {
      audioTimestamp: true,
    },
  });

  console.log(response.text);

  // Example response:
  // [00:00:00] **Speaker A:** your devices are getting better over time. And so ...
  // [00:00:14] **Speaker B:** Welcome to the Made by Google podcast where we meet ...
  // [00:00:20] **Speaker B:** Here's your host, Rasheed Finch.
  // [00:00:23] **Speaker C:** Today we're talking to Aisha Sharif and DeCarlos Love. ...
  // ...

  return response.text;
}

Java

איך מתקינים או מעדכנים את Java

מידע נוסף זמין ב מאמרי העזרה של ה-SDK.

מגדירים משתני סביבה כדי להשתמש ב-Google Gen AI SDK עם Vertex AI:

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_ENTERPRISE=True


import com.google.genai.Client;
import com.google.genai.types.Content;
import com.google.genai.types.GenerateContentConfig;
import com.google.genai.types.GenerateContentResponse;
import com.google.genai.types.HttpOptions;
import com.google.genai.types.Part;

public class TextGenerationTranscriptWithGcsAudio {

  public static void main(String[] args) {
    // TODO(developer): Replace these variables before running the sample.
    String modelId = "gemini-2.5-flash";
    generateContent(modelId);
  }

  // Generates transcript with audio input
  public static String generateContent(String modelId) {
    // Client Initialization. Once created, it can be reused for multiple requests.
    try (Client client =
        Client.builder()
            .location("global")
            .vertexAI(true)
            .httpOptions(HttpOptions.builder().apiVersion("v1").build())
            .build()) {

      String prompt =
          "Transcribe the interview, in the format of timecode, speaker, caption.\n"
              + "Use speaker A, speaker B, etc. to identify speakers.";

      // Enable audioTimestamp to generate timestamps for audio-only files.
      GenerateContentConfig contentConfig =
          GenerateContentConfig.builder().audioTimestamp(true).build();

      GenerateContentResponse response =
          client.models.generateContent(
              modelId,
              Content.fromParts(
                  Part.fromUri(
                      "gs://cloud-samples-data/generative-ai/audio/pixel.mp3", "audio/mpeg"),
                  Part.fromText(prompt)),
              contentConfig);

      System.out.print(response.text());
      // Example response:
      // 00:00 - Speaker A: your devices are getting better over time. And so we think about it...
      // 00:14 - Speaker B: Welcome to the Made by Google Podcast, where we meet the people who...
      // 00:41 - Speaker A: So many features. I am a singer, so I actually think recorder...
      return response.text();
    }
  }
}

REST

אחרי שמגדירים את הסביבה, אפשר להשתמש ב-REST כדי לבדוק פרומפט טקסטואלי. בדוגמה הבאה נשלחת בקשה לנקודת הקצה של המודל של בעל התוכן הדיגיטלי.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: .
  • ‫FILE_URI: ה-URI או כתובת ה-URL של הקובץ שרוצים לכלול בהנחיה. הערכים הקבילים כוללים:
    • ‫URI של קטגוריה ב-Cloud Storage: האובייקט צריך להיות קריא באופן ציבורי או להיות באותו פרויקט ב- Cloud de Confiance ששולח את הבקשה.
    • כתובת URL מסוג HTTP: כתובת ה-URL של הקובץ צריכה להיות ניתנת לקריאה באופן ציבורי. בכל בקשה אפשר לציין קובץ וידאו אחד, קובץ אודיו אחד ועד 10 קובצי תמונות. הגודל המקסימלי של קובצי אודיו, קובצי וידאו ומסמכים הוא 15MB.
    • כתובת ה-URL של הסרטון ב-YouTube: הסרטון ב-YouTube צריך להיות בבעלות החשבון שבו השתמשתם כדי להיכנס למסוף Cloud de Confiance , או להיות גלוי לכולם. אפשר להוסיף רק כתובת URL אחת של סרטון ב-YouTube בכל בקשה.

    כשמציינים fileURI, צריך לציין גם את סוג המדיה (mimeType) של הקובץ. אם VPC Service Controls מופעל, אי אפשר לציין כתובת URL של קובץ מדיה בשביל fileURI.

    אם אין לכם קובץ אודיו ב-Cloud Storage, אתם יכולים להשתמש בקובץ הציבורי הבא: gs://cloud-samples-data/generative-ai/audio/pixel.mp3 עם סוג MIME‏ audio/mp3. כדי להאזין לאודיו הזה, פתחו את קובץ ה-MP3 לדוגמה.

  • ‫MIME_TYPE: סוג המדיה של הקובץ שצוין בשדות data או fileUri. הערכים הקבילים כוללים את האפשרויות הבאות:

    לחצו כדי להרחיב את סוגי ה-MIME

    • application/pdf
    • audio/mpeg
    • audio/mp3
    • audio/wav
    • image/png
    • image/jpeg
    • image/webp
    • text/plain
    • video/mov
    • video/mpeg
    • video/mp4
    • video/mpg
    • video/avi
    • video/wmv
    • video/mpegps
    • video/flv
  • ‫
    TEXT
    ההוראות בטקסט שצריך לכלול בהנחיה. לדוגמה, Can you transcribe this interview, in the format of timecode, speaker, caption. Use speaker A, speaker B, etc. to identify speakers.

כדי לשלוח את הבקשה אתם צריכים לבחור אחת מהאפשרויות הבאות:

curl

שומרים את גוף הבקשה בקובץ בשם request.json. כדי ליצור או להחליף את הקובץ הזה בספרייה הנוכחית, מריצים את הפקודה הבאה בטרמינל:

cat > request.json << 'EOF'
{
  "contents": {
    "role": "USER",
    "parts": [
      {
        "fileData": {
          "fileUri": "FILE_URI",
          "mimeType": "MIME_TYPE"
        }
      },
      {
        "text": "TEXT"
      }
    ]
  },
  "generationConfig": {
    "audioTimestamp": true
  }
}
EOF

לאחר מכן מבצעים את הפקודה הבאה כדי לשלוח את בקשת ה-REST:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/global/publishers/google/models/gemini-3.5-flash:generateContent"

PowerShell

שומרים את גוף הבקשה בקובץ בשם request.json. כדי ליצור או להחליף את הקובץ הזה בספרייה הנוכחית, מריצים את הפקודה הבאה בטרמינל:

@'
{
  "contents": {
    "role": "USER",
    "parts": [
      {
        "fileData": {
          "fileUri": "FILE_URI",
          "mimeType": "MIME_TYPE"
        }
      },
      {
        "text": "TEXT"
      }
    ]
  },
  "generationConfig": {
    "audioTimestamp": true
  }
}
'@  | Out-File -FilePath request.json -Encoding utf8

לאחר מכן מבצעים את הפקודה הבאה כדי לשלוח את בקשת ה-REST:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/global/publishers/google/models/gemini-3.5-flash:generateContent" | Select-Object -Expand Content

אתם אמורים לקבל תגובת JSON שדומה לזו:

שימו לב לפרטים הבאים בכתובת ה-URL של הדוגמה הזו:
  • משתמשים ב-method‏ generateContent כדי לבקש שהתשובה תוחזר אחרי שהיא נוצרת במלואה. כדי להפחית את תפיסת זמן האחזור בקרב קהל אנושי, אפשר להעביר בסטרימינג את התשובה בזמן שהיא נוצרת באמצעות השיטה streamGenerateContent.
  • המזהה של המודל המולטי-מודאלי נמצא בסוף כתובת ה-URL לפני ה-method (לדוגמה, gemini-3.5-flash). יכול להיות שהדוגמה הזו תומכת גם במודלים אחרים.
  • כשמשתמשים בנקודת קצה אזורית ל-API (לדוגמה, us-central1), האזור מכתובת ה-URL של נקודת הקצה קובע איפה הבקשה תעובד. המערכת מתעלמת מכל מיקום שמתנגש בנתיב המשאב.

הגדרת פרמטרים אופציונליים של המודל

לכל מודל יש קבוצה של פרמטרים אופציונליים שאפשר להגדיר. מידע נוסף מופיע במאמר פרמטרים ליצירת תוכן.

מגבלות

המודלים המולטי-מודאליים של Gemini הם עוצמתיים בהרבה תרחישי שימוש מולטי-מודאליים, אבל חשוב להבין את המגבלות של המודלים:

  • זיהוי צלילים שהם לא דיבור: המודלים שתומכים באודיו עלולים לטעות בזיהוי צלילים שהם לא דיבור.
  • חותמות זמן של אודיו בלבד: כדי ליצור חותמות זמן מדויקות לקובצי אודיו בלבד, צריך להגדיר את הפרמטר audio_timestamp ב-generation_config.

המאמרים הבאים