Menggunakan Gemini untuk meringkas video YouTube

Contoh ini menunjukkan cara menggunakan Gemini untuk meringkas video YouTube.

Contoh kode

Python

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Python di Panduan memulai Vertex AI menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi API Python Vertex AI.

Untuk melakukan autentikasi ke Vertex AI, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

import vertexai
from vertexai.generative_models import GenerativeModel, Part

# TODO (developer): update project id
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-1.5-flash-002")

contents = [
    # Text prompt
    "Summarize this video.",
    # YouTube video of Google Pixel 9
    Part.from_uri("https://youtu.be/sXrasaDZxw0", "video/mp4"),
]

response = model.generate_content(contents)
print(response.text)
# Example response:
#     'This Google Pixel 9 Pro advertisement shows how the Gemini AI feature enhances'
#     ' the capabilities of the phone. The video starts with ...'

Langkah selanjutnya

Untuk menelusuri dan memfilter contoh kode untuk produk Google Cloud lainnya, lihat Google Cloud browser contoh.