Skip to content

Commit baa588c

Browse files
feat(generative-ai): Update audio example to use audio_timestamp config (#12755)
1 parent eacdfc8 commit baa588c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

generative_ai/understand_audio/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pandas==2.0.3; python_version == '3.8'
33
pandas==2.1.4; python_version > '3.8'
44
pillow==10.3.0; python_version < '3.8'
55
pillow==10.3.0; python_version >= '3.8'
6-
google-cloud-aiplatform[all]==1.69.0
6+
google-cloud-aiplatform[all]==1.71.1
77
sentencepiece==0.2.0
88
google-auth==2.29.0
99
anthropic[vertex]==0.28.0

generative_ai/understand_audio/transcription_example.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def transcript_audio() -> str:
2121
# [START generativeaionvertexai_gemini_audio_transcription]
2222

2323
import vertexai
24-
from vertexai.generative_models import GenerativeModel, Part
24+
from vertexai.generative_models import GenerativeModel, GenerationConfig, Part
2525

2626
# TODO(developer): Update and un-comment below line
2727
# PROJECT_ID = "your-project-id"
@@ -40,14 +40,14 @@ def transcript_audio() -> str:
4040

4141
contents = [audio_file, prompt]
4242

43-
response = model.generate_content(contents)
43+
response = model.generate_content(contents, generation_config=GenerationConfig(audio_timestamp=True))
4444

4545
print(response.text)
4646
# Example response:
47-
# [00:00:00] Speaker A: your devices are getting better over time...
47+
# [00:00:00] Speaker A: Your devices are getting better over time...
4848
# [00:00:16] Speaker B: Welcome to the Made by Google podcast, ...
4949
# [00:01:00] Speaker A: So many features. I am a singer. ...
50-
# [00:01:33] Speaker B: Amazing. DeCarlos, same question to you. ...
50+
# [00:01:33] Speaker B: Amazing. DeCarlos, same question to you, ...
5151

5252
# [END generativeaionvertexai_gemini_audio_transcription]
5353
return response.text

0 commit comments

Comments
 (0)