[BugFix] Qwen2.5-Omni streaming code2wav input handling (#3396)
Signed-off-by: yinpeiqi <yinpeiqi809@gmail.com>
This commit is contained in:
1 parent
3c85ca5536
commit
5d4b16e6e3
3 files changed
+31
-3
No files matched your search
@@ -51,6 +51,7 @@ QWEN2_5_OMNI_PIPELINE = PipelineConfig(
|
||||
final_output=True,
|
||||
final_output_type="audio",
|
||||
engine_output_type="audio",
|
||||
custom_process_input_func=f"{_PROC}.talker2code2wav",
|
||||
sampling_constraints={"detokenize": True},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -351,10 +351,12 @@ class Qwen2_5OmniForConditionalGeneration(
|
||||
)
|
||||
)
|
||||
|
||||
code = code[:-1] if code[-1] == TALKER_CODEC_EOS_TOKEN_ID else code
|
||||
code = code[1:] if code[0] == TALKER_CODEC_BOS_TOKEN_ID else code
|
||||
if code.numel() and code[-1] == TALKER_CODEC_EOS_TOKEN_ID:
|
||||
code = code[:-1]
|
||||
if code.numel() and code[0] == TALKER_CODEC_BOS_TOKEN_ID:
|
||||
code = code[1:]
|
||||
|
||||
audio_tensor = self.generate_audio(code, voice_type)
|
||||
audio_tensor = self.generate_audio(code, voice_type) if code.numel() else torch.zeros(0, device=code.device)
|
||||
return OmniOutput(text_hidden_states=None, multimodal_outputs={"model_outputs": audio_tensor})
|
||||
|
||||
return OmniOutput(
|
||||
|
||||
@@ -56,3 +56,28 @@ def thinker2talker(
|
||||
)
|
||||
)
|
||||
return talker_inputs
|
||||
|
||||
|
||||
def talker2code2wav(
|
||||
source_outputs,
|
||||
_prompt: OmniTokensPrompt | TextPrompt = None,
|
||||
_requires_multimodal_data: bool = False,
|
||||
):
|
||||
code2wav_inputs = []
|
||||
for talker_output in source_outputs:
|
||||
output = talker_output.outputs[0]
|
||||
token_ids = list(output.cumulative_token_ids)
|
||||
if token_ids and token_ids[0] == TALKER_CODEC_START_TOKEN_ID:
|
||||
token_ids = token_ids[1:]
|
||||
if token_ids and token_ids[-1] == TALKER_CODEC_END_TOKEN_ID:
|
||||
token_ids = token_ids[:-1]
|
||||
if not token_ids:
|
||||
continue
|
||||
code2wav_inputs.append(
|
||||
OmniTokensPrompt(
|
||||
prompt_token_ids=token_ids,
|
||||
multi_modal_data=None,
|
||||
mm_processor_kwargs=None,
|
||||
)
|
||||
)
|
||||
return code2wav_inputs
|
||||
Reference in new issue
Block a user