Skip to content

Commit 462c3bd

Browse files
committed
add error handling for audio_transcribe
1 parent e0b2257 commit 462c3bd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bigframes/operations/blob.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,10 @@ def audio_transcribe(
962962
depend on the "verbose" parameter.
963963
Contains the transcribed text from the audio file.
964964
Includes error messages if verbosity is enabled.
965+
966+
Raises:
967+
ValueError: If engine is not 'bigquery'.
968+
RuntimeError: If the transcription result structure is invalid.
965969
"""
966970
if engine.casefold() != "bigquery":
967971
raise ValueError("Must specify the engine, supported value is 'bigquery'.")
@@ -984,6 +988,10 @@ def audio_transcribe(
984988
model_params={"generationConfig": {"temperature": 0.0}},
985989
)
986990

991+
# Validate that the result is not None
992+
if transcribed_results is None:
993+
raise RuntimeError("Transcription returned None result")
994+
987995
transcribed_content_series = transcribed_results.struct.field("result").rename(
988996
"transcribed_content"
989997
)
@@ -999,4 +1007,4 @@ def audio_transcribe(
9991007
results_struct = bbq.struct(results_df).rename("transcription_results")
10001008
return results_struct
10011009
else:
1002-
return transcribed_content_series.rename("transcribed_content")
1010+
return transcribed_content_series

0 commit comments

Comments
 (0)