오디오 이해

Gemini는 오디오 입력을 분석하여 텍스트 응답을 생성할 수 있습니다.

Python

from google import genai
import base64

client = genai.Client()

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

interaction = client.interactions.create(
    model="gemini-3.6-flash",
    input=[
        {"type": "text", "text": "Describe this audio clip"},
        {
            "type": "audio",
            "uri": uploaded_file.uri,
            "mime_type": uploaded_file.mime_type
        }
    ]
)
print(interaction.output_text)

자바스크립트

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

const client = new GoogleGenAI({});

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

const interaction = await client.interactions.create({
    model: "gemini-3.6-flash",
    input: [
        {type: "text", text: "Describe this audio clip"},
        {
            type: "audio",
            uri: uploadedFile.uri,
            mime_type: uploadedFile.mimeType
        }
    ]
});
console.log(interaction.output_text);

REST

# First upload the file, then use the 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.6-flash",
    "input": [
      {"type": "text", "text": "Describe this audio clip"},
      {
        "type": "audio",
        "uri": "YOUR_FILE_URI",
        "mime_type": "audio/mp3"
      }
    ]
  }'

개요

Gemini는 오디오 입력을 분석하고 이해하여 텍스트 응답을 생성할 수 있으므로 다음과 같은 사용 사례가 가능합니다.

  • 오디오 콘텐츠에 대해 설명하거나, 요약하거나, 질문에 답변하기
  • 음성 텍스트 변환
  • 화자 분할 (서로 다른 화자 식별)
  • 음성 및 음악의 감정 감지
  • 타임스탬프를 사용하여 특정 세그먼트 분석

실시간 음성 및 동영상 상호작용은 Live API를 참고하세요. 실시간 스크립트 작성을 지원하는 전용 음성 텍스트 변환 모델의 경우 Google Cloud Speech-to-Text API를 사용하세요.

음성을 텍스트로 변환

이 예에서는 구조화된 출력을 사용하여 타임스탬프, 화자 분리, 감정 감지와 함께 음성을 텍스트로 변환하고, 번역하고, 요약하는 방법을 보여줍니다.

Python