Skip to content

Commit

Permalink
fix audio/wav response handling (opea-project#802)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Spycsh and pre-commit-ci[bot] authored Oct 18, 2024
1 parent 1a80740 commit f6c3a82
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions comps/cores/mega/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,16 @@ def generate():
if LOGFLAG:
logger.info(inputs)
async with session.post(endpoint, json=inputs) as response:
# Parse as JSON
data = await response.json()
# post process
data = self.align_outputs(data, cur_node, inputs, runtime_graph, llm_parameters_dict, **kwargs)
if response.content_type == "audio/wav":
audio_data = await response.read()
data = self.align_outputs(
audio_data, cur_node, inputs, runtime_graph, llm_parameters_dict, **kwargs
)
else:
# Parse as JSON
data = await response.json()
# post process
data = self.align_outputs(data, cur_node, inputs, runtime_graph, llm_parameters_dict, **kwargs)

return data, cur_node

Expand Down

0 comments on commit f6c3a82

Please sign in to comment.