Skip to content

Commit ce0ae7b

Browse files
authored
fix encode_audio with dict input failure (#480)
## Summary <!-- Include a short paragraph of the changes introduced in this PR. If this PR requires additional context or rationale, explain why the changes are necessary. --> ## Details <!-- Provide a detailed list of all changes introduced in this pull request. --> - [ ] #479 ## Test Plan <!-- List the steps needed to test this PR. --> - ## Related Issues <!-- Link any relevant issues that this PR addresses. --> - Resolves # --- - [ ] "I certify that all code in this PR is my own, except as noted below." ## Use of AI - [ ] Includes AI-assisted code completion - [ ] Includes code generated by an AI application - [ ] Includes AI-generated tests (NOTE: AI written tests should have a docstring that includes `## WRITTEN BY AI ##`)
2 parents 765c875 + fd77ccc commit ce0ae7b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/guidellm/extras/audio.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,13 @@ def _decode_audio( # noqa: C901, PLR0912
107107
raise ValueError(
108108
f"Audio dict must contain either 'data' or 'url' keys, got {audio}"
109109
)
110+
audio_data = audio["data"] if "data" in audio else audio.get("url")
111+
if audio_data is None:
112+
raise ValueError(
113+
f"Audio dict must contain either 'data' or 'url' keys, got {audio}"
114+
)
110115
return _decode_audio(
111-
audio=audio.get("data") or audio.get("url"),
116+
audio=audio_data,
112117
sample_rate=sample_rate,
113118
max_duration=max_duration,
114119
)

0 commit comments

Comments
 (0)