[bugfix] Fix multimodal_output property to check completion outputs where audio data is attached (#1203)
Signed-off-by: linyueqian <linyueqian@outlook.com>
This commit is contained in:
1 parent
53a44c56fe
commit
accf334112
2 files changed
+15
-4
No files matched your search
@@ -111,9 +111,14 @@ def run_tts_generation(args) -> None:
|
|||||||
print(response.text)
|
print(response.text)
|
||||||
return
|
return
|
||||||
|
|
||||||
if response.content.decode("utf-8").startswith('{"error"'):
|
# Check for JSON error response (only if content is valid UTF-8 text)
|
||||||
print(f"Error: {response.content.decode('utf-8')}")
|
try:
|
||||||
return
|
text = response.content.decode("utf-8")
|
||||||
|
if text.startswith('{"error"'):
|
||||||
|
print(f"Error: {text}")
|
||||||
|
return
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
pass # Binary audio data, not an error
|
||||||
|
|
||||||
# Save audio response
|
# Save audio response
|
||||||
output_path = args.output or "tts_output.wav"
|
output_path = args.output or "tts_output.wav"
|
||||||
|
|||||||
@@ -124,10 +124,16 @@ class OmniRequestOutput:
|
|||||||
def multimodal_output(self) -> dict[str, Any]:
|
def multimodal_output(self) -> dict[str, Any]:
|
||||||
"""Return multimodal output from the underlying request output or local field.
|
"""Return multimodal output from the underlying request output or local field.
|
||||||
|
|
||||||
For pipeline outputs, this proxies to request_output.multimodal_output.
|
For pipeline outputs, this checks completion outputs first, then request_output.
|
||||||
For diffusion outputs, this returns the local _multimodal_output field.
|
For diffusion outputs, this returns the local _multimodal_output field.
|
||||||
"""
|
"""
|
||||||
if self.request_output is not None:
|
if self.request_output is not None:
|
||||||
|
# Check completion outputs first (where multimodal_output is attached)
|
||||||
|
if self.request_output.outputs:
|
||||||
|
for output in self.request_output.outputs:
|
||||||
|
mm = getattr(output, "multimodal_output", None)
|
||||||
|
if mm:
|
||||||
|
return mm
|
||||||
return getattr(self.request_output, "multimodal_output", {})
|
return getattr(self.request_output, "multimodal_output", {})
|
||||||
return self._multimodal_output
|
return self._multimodal_output
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user