Skip to content

Commit 790fe97

Browse files
authored
docs(genai): Add audio_timestamp parameter for Audio Understanding (#13179)
1 parent 3b38d86 commit 790fe97

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

genai/text_generation/textgen_transcript_with_gcs_audio.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
def generate_content() -> str:
1717
# [START googlegenaisdk_textgen_transcript_with_gcs_audio]
1818
from google import genai
19-
from google.genai.types import HttpOptions, Part
19+
from google.genai.types import GenerateContentConfig, HttpOptions, Part
2020

2121
client = genai.Client(http_options=HttpOptions(api_version="v1"))
2222
prompt = """
@@ -32,6 +32,8 @@ def generate_content() -> str:
3232
mime_type="audio/mpeg",
3333
),
3434
],
35+
# Required to enable timestamp understanding for audio-only files
36+
config=GenerateContentConfig(audio_timestamp=True),
3537
)
3638
print(response.text)
3739
# Example response:

genai/text_generation/textgen_with_gcs_audio.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ def generate_content() -> str:
2020

2121
client = genai.Client(http_options=HttpOptions(api_version="v1"))
2222
prompt = """
23-
Provide the summary of the audio file.
24-
Summarize the main points of the audio concisely.
25-
Create a chapter breakdown with timestamps for key sections or topics discussed.
23+
Provide a concise summary of the main points in the audio file.
2624
"""
2725
response = client.models.generate_content(
2826
model="gemini-2.0-flash-001",
@@ -36,13 +34,9 @@ def generate_content() -> str:
3634
)
3735
print(response.text)
3836
# Example response:
39-
# This episode of the Made by Google podcast features product managers ...
40-
#
41-
# **Chapter Breakdown:**
42-
#
43-
# * **[0:00-1:14] Introduction:** Host Rasheed Finch introduces Aisha and DeCarlos and ...
44-
# * **[1:15-2:44] Transformative Features:** Aisha and DeCarlos discuss their ...
45-
# ...
37+
# Here's a summary of the main points from the audio file:
38+
39+
# 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.
4640
# [END googlegenaisdk_textgen_with_gcs_audio]
4741
return response.text
4842

0 commit comments

Comments
 (0)