תמלול אודיו

‫Gemini API ממיר דיבור בקובצי אודיו לטקסט באמצעות מודל Gemini 3.5 Transcribe (gemini-3.5-transcribe). על סמך יכולות ההבנה של אודיו ב-Gemini, הוא מספק תמלול מדויק עם זיהוי שפה אוטומטי, זיהוי דוברים, חותמות זמן ברמת המילה ורמזים לגבי אוצר מילים מותאם אישית. הוא כולל גם מצב תמלול חכם עם הסרה אוטומטית של מילות מילוי ופורמט חכם.

כדי לתמלל קובץ אודיו, מעלים את האודיו ומעבירים אותו אל gemini-3.5-transcribe:

Python

from google import genai

client = genai.Client()

audio_file = client.files.upload(file="path/to/sample.mp3")

interaction = client.interactions.create(
    model="gemini-3.5-transcribe",
    input=[
        {
            "type": "audio",
            "uri": audio_file.uri,
            "mime_type": audio_file.mime_type,
        }
    ],
)

print(interaction.output_text)

JavaScript

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

const audioFile = await client.files.upload({
  file: "path/to/sample.mp3",
  config: { mime_type: "audio/mp3" },
});

const interaction = await client.interactions.create({
  model: "gemini-3.5-transcribe",
  input: [
    {
      type: "audio",
      uri: audioFile.uri,
      mime_type: audioFile.mimeType,
    },
  ],
});

console.log(interaction.output_text);

Go

package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
    "google.golang.org/genai/interactions/models/operations"
)

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

    audioFile, err := client.Files.UploadFromPath(ctx, "path/to/sample.mp3", nil)
    if err != nil {
        log.Fatal(err)
    }

    res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.5-transcribe"),
            Input: interactions.NewInteractionsInput([]interactions.Content{
                interactions.NewContent(interactions.AudioContent{
                    URI:      genai.Ptr(audioFile.URI),
                    MimeType: interactions.AudioContentMimeType(audioFile.MIMEType).ToPointer(),
                }),
            }),
        }),
    })
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(res.Interaction.GetOutputText())
}

REST

# First upload the file via the Files API, then pass its URI:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3.5-transcribe",
    "input": [
      {
        "type": "audio",
        "uri": "YOUR_FILE_URI",
        "mime_type": "audio/mp3"
      }
    ]
  }'

סקירה כללית

‫Gemini 3.5 Transcribe מותאם למשימות של המרת דיבור לטקסט. הוא מתמודד עם מבטאים שונים, רעשי רקע ושיחות בכמה שפות.

היכולות העיקריות:

  • ‫ASR: זיהוי אוטומטי של דיבור. המערכת מזהה שפות באופן אוטומטי ב-85+ לוקאלים. הוא מטפל בערבוב שפות בתוך משפט ובין משפטים בלי הגדרה ידנית.
  • אוצר מילים מותאם אישית: כדי להטות את הזיהוי למונחים, לראשי תיבות ולשמות פרטיים ספציפיים לדומיין, אפשר להעביר עד 1,000 ביטויים.
  • הפרדה בין דוברים: האפליקציה מבחינה בין כמה דוברים ומשייכת את הקטעים המדוברים לתוויות שונות.
  • חותמות זמן ברמת המילה: יצירת היסטים מדויקים של שעת ההתחלה ושעת הסיום לכל מילה מזוהה.
  • תמלול חכם: מוחק מילים מיותרות, חזרות ואי-רציפות בדיבור, ומחיל עיצוב מובנה.
  • עיצוב ונורמליזציה: המערכת משתמשת באותיות רישיות, בסימני פיסוק ובנורמליזציה הפוכה של טקסט, למשל המרה של 'twenty six million dollars' ל-'$26M'.

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

זיהוי שפה ורמזים

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

כדי להשתמש בזיהוי אוטומטי, משמיטים את language_codes או מספקים רשימה ריקה:

Python

interaction = client.interactions.create(
    model="gemini-3.5-transcribe",
    input=[
        {
            "type": "audio",
            "uri": audio_file.uri,
            "mime_type": audio_file.mime_type,
        }
    ],
    generation_config={
        "transcription_config": {
            "language_codes": [],
        }
    },
)

JavaScript

const interaction = await client.interactions.create({
  model: "gemini-3.5-transcribe",
  input: [
    {
      type: "audio",
      uri: audioFile.uri,
      mime_type: audioFile.mimeType,
    },
  ],
  generation_config: {
    transcription_config: {
      language_codes: [],
    },
  },
});

Go

package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
    "google.golang.org/genai/interactions/models/operations"
)

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

    audioFile, err := client.Files.UploadFromPath(ctx, "path/to/sample.mp3", nil)
    if err != nil {
        log.Fatal(err)
    }

    res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.5-transcribe"),
            Input: interactions.NewInteractionsInput([]interactions.Content{
                interactions.NewContent(interactions.AudioContent{
                    URI:      genai.Ptr(audioFile.URI),
                    MimeType: interactions.AudioContentMimeType(audioFile.MIMEType).ToPointer(),
                }),
            }),
            GenerationConfig: &interactions.GenerationConfig{
                TranscriptionConfig: &interactions.TranscriptionConfig{
                    LanguageCodes: []string{},
                },
            },
        }),
    })
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(res.Interaction.GetOutputText())
}

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": "gemini-3.5-transcribe",
    "input": [
      {
        "type": "audio",
        "uri": "YOUR_FILE_URI",
        "mime_type": "audio/mp3"
      }
    ],
    "generation_config": {
      "transcription_config": {
        "language_codes": []
      }
    }
  }'

אם אתם יודעים מראש את השפה, כדאי לציין קודי שפה בתקן BCP-47 ב-language_codes כדי לשפר את דיוק התמלול (ראו שפות נתמכות):

Python

generation_config = {
    "transcription_config": {
        "language_codes": ["es-ES"],
    }
}

JavaScript

const generationConfig = {
  transcription_config: {
    language_codes: ["es-ES"],
  },
};

Go

package main

import (
    "google.golang.org/genai/interactions/models/interactions"
)

func main() {
    generationConfig := &interactions.GenerationConfig{
        TranscriptionConfig: &interactions.TranscriptionConfig{
            LanguageCodes: []string{"es-ES"},
        },
    }
    _ = generationConfig
}

REST

{
  "generation_config": {
    "transcription_config": {
      "language_codes": ["es-ES"]
    }
  }
}

אוצר מילים בהתאמה אישית

אתם יכולים להכווין את מודל הדיבור למילים לא נפוצות, למונחים מקצועיים, לשמות מותגים או לשמות עצם פרטיים. מספקים עד 1,000 מונחים במערך custom_vocabulary (בדרך כלל מקבלים את התוצאות הטובות ביותר עם עד 100 מונחים):

Python

interaction = client.interactions.create(
    model="gemini-3.5-transcribe",
    input=[
        {
            "type": "audio",
            "uri": audio_file.uri,
            "mime_type": audio_file.mime_type,
        }
    ],
    generation_config={
        "transcription_config": {
            "custom_vocabulary": ["Gemini", "Kubernetes", "BigQuery"],
        }
    },
)

JavaScript

const interaction = await client.interactions.create({
  model: "gemini-3.5-transcribe",
  input: [
    {
      type: "audio",
      uri: audioFile.uri,
      mime_type: audioFile.mimeType,
    },
  ],
  generation_config: {
    transcription_config: {
      custom_vocabulary: ["Gemini", "Kubernetes", "BigQuery"],
    },
  },
});

Go

package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
    "google.golang.org/genai/interactions/models/operations"
)

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

    audioFile, err := client.Files.UploadFromPath(ctx, "path/to/sample.mp3", nil)
    if err != nil {
        log.Fatal(err)
    }

    res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.5-transcribe"),
            Input: interactions.NewInteractionsInput([]interactions.Content{
                interactions.NewContent(interactions.AudioContent{
                    URI:      genai.Ptr(audioFile.URI),
                    MimeType: interactions.AudioContentMimeType(audioFile.MIMEType).ToPointer(),
                }),
            }),
            GenerationConfig: &interactions.GenerationConfig{
                TranscriptionConfig: &interactions.TranscriptionConfig{
                    CustomVocabulary: []string{"Gemini", "Kubernetes", "BigQuery"},
                },
            },
        }),
    })
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(res.Interaction.GetOutputText())
}

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": "gemini-3.5-transcribe",
    "input": [
      {
        "type": "audio",
        "uri": "YOUR_FILE_URI",
        "mime_type": "audio/mp3"
      }
    ],
    "generation_config": {
      "transcription_config": {
        "custom_vocabulary": ["Gemini", "Kubernetes", "BigQuery"]
      }
    }
  }'

חלוקת קובץ האודיו לפי דוברים

התכונה 'זיהוי דוברים' מזהה קולות שונים בהקלטה ומתייגת כל קטע במזהה דובר כמו spk_1 או spk_2. יש תמיכה בעד 8 רמקולים (השיוך ל-3 רמקולים או יותר הוא ניסיוני).

כדי להפעיל את החלוקה לפי דוברים, צריך להגדיר את diarization_mode ב-mode:

Python

interaction = client.interactions.create(
    model="gemini-3.5-transcribe",
    input=[
        {
            "type": "audio",
            "uri": audio_file.uri,
            "mime_type": audio_file.mime_type,
        }
    ],
    generation_config={
        "transcription_config": {
            "mode": {
                "type": "verbatim",
                "diarization_mode": "speaker",
            },
        }
    },
)

JavaScript

const interaction = await client.interactions.create({
  model: "gemini-3.5-transcribe",
  input: [
    {
      type: "audio",
      uri: audioFile.uri,
      mime_type: audioFile.mimeType,
    },
  ],
  generation_config: {
    transcription_config: {
      mode: {
        type: "verbatim",
        diarization_mode: "speaker",
      },
    },
  },
});

Go

package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
    "google.golang.org/genai/interactions/models/operations"
)

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

    audioFile, err := client.Files.UploadFromPath(ctx, "path/to/sample.mp3", nil)
    if err != nil {
        log.Fatal(err)
    }

    res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.5-transcribe"),
            Input: interactions.NewInteractionsInput([]interactions.Content{
                interactions.NewContent(interactions.AudioContent{
                    URI:      genai.Ptr(audioFile.URI),
                    MimeType: interactions.AudioContentMimeType(audioFile.MIMEType).ToPointer(),
                }),
            }),
            GenerationConfig: &interactions.GenerationConfig{
                TranscriptionConfig: &interactions.TranscriptionConfig{
                    Mode: genai.Ptr(interactions.NewTranscriptionConfigMode(interactions.NewTranscriptionMode(interactions.VerbatimTranscriptionMode{
                        DiarizationMode: genai.Ptr("speaker"),
                    }))),
                },
            },
        }),
    })
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(res.Interaction.GetOutputText())
}

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": "gemini-3.5-transcribe",
    "input": [
      {
        "type": "audio",
        "uri": "YOUR_FILE_URI",
        "mime_type": "audio/mp3"
      }
    ],
    "generation_config": {
      "transcription_config": {
        "mode": {
          "type": "verbatim",
          "diarization_mode": "speaker"
        }
      }
    }
  }'

חותמות זמן ברמת המילה

חותמות זמן ברמת המילה מספקות היסטים מדויקים של התחלה וסיום לכל מילה שמזוהה בשידור האודיו.

כדי להפעיל את חותמות הזמן, מגדירים את timestamp_granularities בתוך mode:

Python

interaction = client.interactions.create(
    model="gemini-3.5-transcribe",
    input=[
        {
            "type": "audio",
            "uri": audio_file.uri,
            "mime_type": audio_file.mime_type,
        }
    ],
    generation_config={
        "transcription_config": {
            "mode": {
                "type": "verbatim",
                "timestamp_granularities": ["word"],
            },
        }
    },
)

JavaScript

const interaction = await client.interactions.create({
  model: "gemini-3.5-transcribe",
  input: [
    {
      type: "audio",
      uri: audioFile.uri,
      mime_type: audioFile.mimeType,
    },
  ],
  generation_config: {
    transcription_config: {
      mode: {
        type: "verbatim",
        timestamp_granularities: ["word"],
      },
    },
  },
});

Go

package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
    "google.golang.org/genai/interactions/models/operations"
)

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

    audioFile, err := client.Files.UploadFromPath(ctx, "path/to/sample.mp3", nil)
    if err != nil {
        log.Fatal(err)
    }

    res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.5-transcribe"),
            Input: interactions.NewInteractionsInput([]interactions.Content{
                interactions.NewContent(interactions.AudioContent{
                    URI:      genai.Ptr(audioFile.URI),
                    MimeType: interactions.AudioContentMimeType(audioFile.MIMEType).ToPointer(),
                }),
            }),
            GenerationConfig: &interactions.GenerationConfig{
                TranscriptionConfig: &interactions.TranscriptionConfig{
                    Mode: genai.Ptr(interactions.NewTranscriptionConfigMode(interactions.NewTranscriptionMode(interactions.VerbatimTranscriptionMode{
                        TimestampGranularities: []string{"word"},
                    }))),
                },
            },
        }),
    })
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(res.Interaction.GetOutputText())
}

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": "gemini-3.5-transcribe",
    "input": [
      {
        "type": "audio",
        "uri": "YOUR_FILE_URI",
        "mime_type": "audio/mp3"
      }
    ],
    "generation_config": {
      "transcription_config": {
        "mode": {
          "type": "verbatim",
          "timestamp_granularities": ["word"]
        }
      }
    }
  }'

אפשר לשלב בין diarization_mode לבין timestamp_granularities ב-mode כדי לקבל גם תוויות לזיהוי הדובר וגם חותמות זמן של מילים:

Python

generation_config = {
    "transcription_config": {
        "mode": {
            "type": "verbatim",
            "diarization_mode": "speaker",
            "timestamp_granularities": ["word"],
        },
    }
}

JavaScript

const generationConfig = {
  transcription_config: {
    mode: {
      type: "verbatim",
      diarization_mode: "speaker",
      timestamp_granularities: ["word"],
    },
  },
};

Go

package main

import (
    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
)

func main() {
    generationConfig := &interactions.GenerationConfig{
        TranscriptionConfig: &interactions.TranscriptionConfig{
            Mode: genai.Ptr(interactions.NewTranscriptionConfigMode(interactions.NewTranscriptionMode(interactions.VerbatimTranscriptionMode{
                DiarizationMode:        genai.Ptr("speaker"),
                TimestampGranularities: []string{"word"},
            }))),
        },
    }
    _ = generationConfig
}

REST

{
  "generation_config": {
    "transcription_config": {
      "mode": {
        "type": "verbatim",
        "diarization_mode": "speaker",
        "timestamp_granularities": ["word"]
      }
    }
  }
}

מצבי תמלול

‫Gemini 3.5 Transcribe תומך בשני מצבי תמלול באמצעות הפרמטר mode:

  • ‫verbatim (ברירת מחדל): מחזירה תמליל מדויק מילה במילה של כל מה שנאמר, תוך שמירה על מילות מילוי גולמיות ("אה", "אממ", "כאילו", "אתה יודע"), חזרות, הפסקות והתחלות שגויות. במצב הזה ({"type": "verbatim", ...}) מוגדרות חותמות זמן וחלוקת קובץ האודיו לפי דוברים.
  • ‫smart (תמלול חכם): התמלול עובר אופטימיזציה לקריאה באמצעות עיבוד מתקדם חכם:
    • הסרה אוטומטית של מילות מילוי: הסרת מילות מילוי, גמגום והתחלות שגויות.
    • תיקונים עצמיים בתוך המשפט: תיקונים שמתבצעים במהלך הדיבור נפתרים באופן ישיר (לדוגמה, "בוא ניפגש ביום שלישי, בעצם לא, ביום רביעי בשעה שתיים" הופך ל-"בוא ניפגש ביום רביעי בשעה 14:00").
    • עיצוב מובנה אוטומטי: המחשבות המדוברות מעוצבות באופן אוטומטי לפסקאות, לרשימות ממוספרות, לתבליטים, לתאריכים, למטבעות ולמספרים.
    • ניקוי דקדוקי: הוספת פיסוק טבעי, שימוש באותיות רישיות בתחילת משפטים ושיפור הרצף.
אודיו של דיבור פלט אחד (verbatim) פלט של smart (תמלול חכם)
"אה, אז לפגישה, אני חושב שכדאי לנו, אה, להזמין את אליס ו, רגע, לא, את בוב ואת קרול." "אממ אז לפגישה אני חושב שכדאי לנו להזמין את אליס, רגע לא, את בוב וקרול". "לפגישה, אני חושב שכדאי להזמין את בוב ואת קרול".
‫"First item review budget second item finalize timeline third item send recap" ‫"first item review budget second item finalize timeline third item send recap" "1. בדיקת התקציב
2. סוגרים את ציר הזמן
3. שליחת סיכום"

Python

interaction = client.interactions.create(
    model="gemini-3.5-transcribe",
    input=[
        {
            "type": "audio",
            "uri": audio_file.uri,
            "mime_type": audio_file.mime_type,
        }
    ],
    generation_config={
        "transcription_config": {
            "mode": "smart",
        }
    },
)
print(interaction.output_text)

JavaScript

const interaction = await client.interactions.create({
  model: "gemini-3.5-transcribe",
  input: [
    {
      type: "audio",
      uri: audioFile.uri,
      mime_type: audioFile.mimeType,
    },
  ],
  generation_config: {
    transcription_config: {
      mode: "smart",
    },
  },
});
console.log(interaction.output_text);

Go

package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
    "google.golang.org/genai/interactions/models/operations"
)

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

    audioFile, err := client.Files.UploadFromPath(ctx, "path/to/sample.mp3", nil)
    if err != nil {
        log.Fatal(err)
    }

    res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.5-transcribe"),
            Input: interactions.NewInteractionsInput([]interactions.Content{
                interactions.NewContent(interactions.AudioContent{
                    URI:      genai.Ptr(audioFile.URI),
                    MimeType: interactions.AudioContentMimeType(audioFile.MIMEType).ToPointer(),
                }),
            }),
            GenerationConfig: &interactions.GenerationConfig{
                TranscriptionConfig: &interactions.TranscriptionConfig{
                    Mode: genai.Ptr(interactions.NewTranscriptionConfigMode(interactions.TranscriptionConfigModeEnumSmart)),
                },
            },
        }),
    })
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(res.Interaction.GetOutputText())
}

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": "gemini-3.5-transcribe",
    "input": [
      {
        "type": "audio",
        "uri": "YOUR_FILE_URI",
        "mime_type": "audio/mp3"
      }
    ],
    "generation_config": {
      "transcription_config": {
        "mode": "smart"
      }
    }
  }'

ניתוח פלט התמלול

הטקסט המלא של התמליל מוחזר ב-interaction.output_text.

כשהאפשרויות timestamp_granularities או diarization_mode מופעלות, ה-API מחזיר גם הערות מפורטות ברמת המילה שמצורפות לתוכן האינטראקציה.

כך אפשר לחלץ חותמות זמן של מילים ושינויים של הדובר ולעבור עליהם:

Python

def extract_word_annotations(interaction):
    words = []
    for step in getattr(interaction, "steps", []) or []:
        for content in getattr(step, "content", []) or []:
            for annotation in getattr(content, "annotations", []) or []:
                if getattr(annotation, "type", None) == "word_info":
                    words.append(annotation)
    return words

words = extract_word_annotations(interaction)

for w in words:
    speaker = f"[{w.speaker}] " if getattr(w, "speaker", None) else ""
    start = getattr(w, "start_offset", "")
    end = getattr(w, "end_offset", "")
    timing = f"({start} -> {end}) " if start and end else ""
    print(f"{speaker}{timing}{w.text}")

JavaScript

function extractWordAnnotations(interaction) {
  const words = [];
  for (const step of interaction.steps ?? []) {
    for (const content of step.content ?? []) {
      for (const annotation of content.annotations ?? []) {
        if (annotation.type === "word_info") {
          words.push(annotation);
        }
      }
    }
  }
  return words;
}

const words = extractWordAnnotations(interaction);

for (const w of words) {
  const speaker = w.speaker ? `[${w.speaker}] ` : "";
  const timing = (w.start_offset && w.end_offset) ? `(${w.start_offset} -> ${w.end_offset}) ` : "";
  console.log(`${speaker}${timing}${w.text}`);
}

Go

package main

import (
    "fmt"

    "google.golang.org/genai/interactions/models/interactions"
)

func extractWordAnnotations(interaction *interactions.Interaction) []*interactions.WordInfo {
    var words []*interactions.WordInfo
    if interaction == nil {
        return words
    }
    for _, step := range interaction.Steps {
        if step.ModelOutputStep != nil {
            for _, content := range step.ModelOutputStep.Content {
                if content.TextContent != nil {
                    for _, annotation := range content.TextContent.Annotations {
                        if annotation.WordInfo != nil {
                            words = append(words, annotation.WordInfo)
                        }
                    }
                }
            }
        }
    }
    return words
}

func main() {
    var interaction *interactions.Interaction
    words := extractWordAnnotations(interaction)

    for _, w := range words {
        speaker := ""
        if w.Speaker != nil && *w.Speaker != "" {
            speaker = fmt.Sprintf("[%s] ", *w.Speaker)
        }
        timing := ""
        if w.StartOffset != nil && w.EndOffset != nil {
            timing = fmt.Sprintf("(%s -> %s) ", *w.StartOffset, *w.EndOffset)
        }
        fmt.Printf("%s%s%s\n", speaker, timing, w.GetText())
    }
}

REST

{
  "id": "interactions/abc123xyz",
  "status": "completed",
  "steps": [
    {
      "id": "step_001",
      "type": "model_output",
      "content": [
        {
          "type": "text",
          "text": "Hello world",
          "annotations": [
            {
              "type": "word_info",
              "text": "Hello",
              "speaker": "spk_1",
              "start_offset": "0.100s",
              "end_offset": "0.450s"
            },
            {
              "type": "word_info",
              "text": "world",
              "speaker": "spk_1",
              "start_offset": "0.500s",
              "end_offset": "0.850s"
            }
          ]
        }
      ]
    }
  ]
}

שפות נתמכות

השפות הבאות וקודי השפה שלהן בתקן BCP-47 נתמכות ב-Gemini 3.5 Transcribe:

שפה קוד BCP-47 שפה קוד BCP-47
אפריקאנס af-ZA יפנית ja-JP
אמהרית am-ET ג'אווה jv-ID
ערבית (מצרים) ar-EG קאבוורדיאנו kea-CV
ארמנית hy-AM קנאדה kn-IN
אסאמית as-IN קזחית kk-KZ
אזרית az-AZ קוריאנית ko-KR
בלארוסית be-BY קירגיזית ky-KG
בנגלית (בנגלדש) bn-BD לטבית lv-LV
בנגלית (הודו) bn-IN לינגלה ln-CD
בוסנית bs-BA ליטאית lt-LT
בולגרית bg-BG מקדונית mk-MK
בולגרית (ארומנית) rup-BG מלאית ms-MY
בורמזית my-MM מליאלאם ml-IN
קנטונזית (מסורתית) yue-Hant-HK מלטית mt-MT
קטלאנית ca-ES מנדרינית (פשוטה) cmn-Hans-CN
סבואנו ceb מראטהית mr-IN
חמר מרכזית km-KH מונגולית mn-MN
קרואטית hr-HR נפאלית ne-NP
צ'כית cs-CZ נורווגית nb-NO
דנית da-DK אורייה or-IN
הולנדית nl-NL פולנית pl-PL
אנגלית (בריטניה) en-GB פורטוגזית (ברזיל) pt-BR
אנגלית (הודו) en-IN פורטוגזית (פורטוגל) pt-PT
אנגלית (ארצות הברית) en-US פנג'אבי pa-IN
אסטונית et-EE פנג'אבי (כתב גורמוקי) pa-Guru-IN
פרסית fa-IR רומנית ro-RO
פיליפינית fil-PH רוסית ru-RU
פינית fi-FI סרבית sr-RS
צרפתית fr-FR סינדהי (כתב ערבי) sd-Arab-IN
גליציאנית gl-ES סלובקית sk-SK
גאורגית ka-GE סלובנית sl-SI
גרמנית de-DE ספרדית (אמריקה הלטינית) es-419
יוונית el-GR ספרדית (ארצות הברית) es-US
גוג'ראטי gu-IN סוואהילית (קניה) sw-KE
האוסה ha-NG שוודית sv-SE
עברית he-IL טג'יקית tg-TJ
הינדי hi-IN טלוגו te-IN
הונגרית hu-HU תאית th-TH
איסלנדית is-IS טורקית tr-TR
אנגלית הודית en-IN אוקראינית uk-UA
אינדונזית id-ID אוזבקית uz-UZ
איטלקית it-IT וייטנאמית vi-VN

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

‫Gemini 3.5 Transcribe תומך בסוגי ה-MIME הבאים של פורמטים של אודיו:

  • ‫WAV - audio/wav
  • MP3 - audio/mp3
  • AIFF - audio/aiff
  • ‫AAC – audio/aac
  • ‫OGG – audio/ogg
  • ‫FLAC – audio/flac
  • MPEG - audio/mpeg
  • M4A - audio/m4a
  • ‫L16 - audio/l16
  • ‫Opus – audio/opus
  • ‫ALAW – audio/alaw
  • MULAW - audio/mulaw
  • ‫WebM – audio/webm

רשימה מלאה של סוגי MIME וסכימות פרמטרים נתמכים מופיעה בחומר העזר בנושא Interactions API.

הפניה לפרמטר

מגדירים את התמלול על ידי הגדרת שדות באובייקט transcription_config ב-generation_config:

שדה סוג תיאור
language_codes מערך של מחרוזות קודי שפה בתקן BCP-47 (למשל ["en-US"]). אם לא מציינים קוד שפה או אם הקוד ריק ([]), המודל מזהה אוטומטית את השפה ומטפל במעבר בין שפות.
custom_vocabulary מערך של מחרוזות עד 1,000 מונחים, ראשי תיבות או שמות עצם בהתאמה אישית כדי להטות את זיהוי הדיבור. האפשרות לא תואמת לחלוקת קובץ האודיו לפי דוברים ולחותמות זמן ברמת המילה.
mode אובייקט או מחרוזת הגדרת מצב התמלול. מקבל "smart" או אובייקט במצב מילולי ({"type": "verbatim", ...}). ברירת המחדל היא תמלול מילולי.
mode.type מחרוזת (במצב 'מילה במילה' בלבד) מזהה מצב. הערך תמיד יהיה "verbatim".
mode.timestamp_granularities מערך של מחרוזות (במצב מילה במילה בלבד) רמת הפירוט של חותמות הזמן שיוחזרו. מעבירים את הערך ["word"] כדי להפעיל את ההזחות של תחילת המילה וסוף המילה. לא תואם לאוצר מילים מותאם אישית.
mode.diarization_mode מחרוזת (במצב מילה במילה בלבד) מצב דיאריזציה. מעבירים את "speaker" כדי לזהות את הדוברים השונים ולהוסיף להם תוויות. לא תואם לאוצר מילים מותאם אישית.

שיטות מומלצות

  • לספק אודיו ברור: חשוב לוודא שההקלטות של האודיו כוללות הפרדה ברורה של הקול, ולהימנע מקטיעת אודיו חמורה.
  • הוספת רמזים לגבי השפה כשמכירים אותה: אם אתם יודעים מראש מה השפה של האודיו, כדאי לציין אותה באמצעות language_codes כדי לשפר את הדיוק.
  • טרגוט אוצר מילים מותאם אישית: כדאי לכלול ב-custom_vocabulary רק מונחים ייחודיים שקשורים לדומיין, שמות של מותגים או שמות עצם, ולא מילים נפוצות שמשמשות בחיי היום-יום.
  • שימוש ב-Files API להקלטות ארוכות: אם הקובץ ארוך מכמה שניות, מעלים את הקובץ באמצעות client.files.upload ומעבירים את ה-URI של הקובץ שמוחזר למודל.

מגבלות

  • ‫Audio duration: בקשות סטנדרטיות של unary תומכות בקובצי אודיו באורך של עד שעה. כשמפעילים תכונות כמו זיהוי דוברים או חותמות זמן ברמת המילה, עיבוד האודיו מוגבל ל-30 דקות.
  • חותמות זמן ברמת המילה: הפעלת חותמות זמן ברמת המילה עלולה לפגוע בדיוק הכולל של התמלול.
  • חלוקת קובץ האודיו לפי דוברים: חלוקת קובץ האודיו לפי דוברים תומכת בעד 8 דוברים. השיוך של דוברים בשיחות עם 3 דוברים או יותר הוא ניסיוני.
  • אוצר מילים מותאם אישית: אפשר לספק עד 1,000 מונחים ב-custom_vocabulary, אבל בדרך כלל התוצאות הכי טובות מתקבלות עם עד 100 מונחים. אי אפשר לשלב את custom_vocabulary עם תיוג דוברים או עם חותמות זמן ברמת המילה. ה-API דוחה בקשות שמציינות את custom_vocabulary לצד אחת מהתכונות האלה.
  • תאימות למצבים: אי אפשר לשלב תמלול חכם ("smart") עם timestamp_granularities או diarization_mode.

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