Skip to content

Commit f6c3a82

Browse files
fix audio/wav response handling (opea-project#802)
* fix audio output * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 1a80740 commit f6c3a82

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

comps/cores/mega/orchestrator.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,16 @@ def generate():
202202
if LOGFLAG:
203203
logger.info(inputs)
204204
async with session.post(endpoint, json=inputs) as response:
205-
# Parse as JSON
206-
data = await response.json()
207-
# post process
208-
data = self.align_outputs(data, cur_node, inputs, runtime_graph, llm_parameters_dict, **kwargs)
205+
if response.content_type == "audio/wav":
206+
audio_data = await response.read()
207+
data = self.align_outputs(
208+
audio_data, cur_node, inputs, runtime_graph, llm_parameters_dict, **kwargs
209+
)
210+
else:
211+
# Parse as JSON
212+
data = await response.json()
213+
# post process
214+
data = self.align_outputs(data, cur_node, inputs, runtime_graph, llm_parameters_dict, **kwargs)
209215

210216
return data, cur_node
211217

0 commit comments

Comments
 (0)