This commit is contained in:
1 parent
05a86ed10e
commit
92f7208559
3 files changed
+19
-23
No files matched your search
@@ -21,8 +21,6 @@ from vllm_omni.model_executor.models.cosyvoice3.utils import unpad_prompt_condit
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
_COSYVOICE3_SPEECH_TOKEN_SIZE = 6561
|
||||
|
||||
|
||||
def _build_prompt_embed_struct(prompt_payload: dict[str, Any]) -> EmbeddingsStruct | None:
|
||||
"""Wrap prompt_payload's flat speech_token/speech_feat/embedding tensors into EmbeddingsStruct."""
|
||||
@@ -85,20 +83,6 @@ def _prompt_speech_token_ids(multi_modal_data: dict[str, Any]) -> list[int]:
|
||||
return _to_token_id_list(speech_token)
|
||||
|
||||
|
||||
def _has_speech_stop_token(output_ids: list[Any]) -> bool:
|
||||
return any(token_id >= _COSYVOICE3_SPEECH_TOKEN_SIZE for token_id in _to_token_id_list(output_ids))
|
||||
|
||||
|
||||
def _set_non_stream_prompt_trim(additional_info: dict[str, Any], prompt_speech_len: int) -> None:
|
||||
if prompt_speech_len <= 0:
|
||||
return
|
||||
meta = additional_info.get("meta")
|
||||
if not isinstance(meta, dict):
|
||||
meta = {}
|
||||
additional_info["meta"] = meta
|
||||
meta["talker_prefill_offset"] = prompt_speech_len
|
||||
|
||||
|
||||
def _to_cpu_tensor(x: Any) -> torch.Tensor | None:
|
||||
if isinstance(x, list):
|
||||
if not x:
|
||||
@@ -154,8 +138,6 @@ def text2flow(
|
||||
output_ids = _strip_prompt_prefix(raw_output_ids, prefix_ids)
|
||||
output_ids = _strip_prompt_prefix(output_ids, prompt_speech_ids)
|
||||
additional_info = dict(multi_modal_data)
|
||||
if _has_speech_stop_token(raw_output_ids):
|
||||
_set_non_stream_prompt_trim(additional_info, len(prompt_speech_ids))
|
||||
additional_info.setdefault("ids", {})["prompt"] = prefix_ids
|
||||
engine_inputs.append(OmniTokensPrompt(prompt_token_ids=output_ids, additional_information=additional_info))
|
||||
return engine_inputs
|
||||
@@ -389,8 +371,6 @@ def text2flow_token_only(
|
||||
prompt_speech_ids = _prompt_speech_token_ids(multi_modal_data)
|
||||
output_ids = _strip_prompt_prefix(output_ids, prompt_speech_ids)
|
||||
additional_info: dict[str, Any] = dict(multi_modal_data)
|
||||
if _has_speech_stop_token(raw_output_ids):
|
||||
_set_non_stream_prompt_trim(additional_info, len(prompt_speech_ids))
|
||||
additional_info.setdefault("ids", {})["prompt"] = prefix_ids
|
||||
engine_inputs.append(
|
||||
OmniTokensPrompt(
|
||||
|
||||
Reference in new issue
Block a user