Spaces:
Runtime error
Runtime error
fix alignment
Browse files30 unmodified lines313233343536321 unmodified lines35835936036136236336436536636736836937037137237337437537637737830 unmodified linesfrom tada.modules.encoder import Encoder, EncoderOutput # noqa: E402from tada.modules.tada import InferenceOptions, TadaForCausalLM # noqa: E402logging.basicConfig(level=logging.INFO)logger = logging.getLogger(__name__)321 unmodified linesaudio_duration = wav.shape[-1] / 24_000# Extract only user-text step_logs, reconstructing any prefilled (missing) entriesall_logs = output.step_logs or []if _model is not None and text and output.input_text_ids is not None:input_ids = output.input_text_ids[0]seq_len = input_ids.shape[0]n_eos = _model.config.shift_acoustic# Find text boundary: last <|end_header_id|> token marks end of assistant headerend_header_id = _model.tokenizer.convert_tokens_to_ids("<|end_header_id|>")# Scan backwards for the last end_header tokentext_start = 0for i in range(seq_len - 1, -1, -1):if input_ids[i].item() == end_header_id:text_start = i + 1breaktext_end = seq_len - n_eos# Build a step -> log lookup from existing step_logslog_by_step = {e["step"]: e for e in all_logs}30 unmodified lines31323334353637321 unmodified lines35936036136236336436536636736836937037137237337437530 unmodified linesfrom tada.modules.encoder import Encoder, EncoderOutput # noqa: E402from tada.modules.tada import InferenceOptions, TadaForCausalLM # noqa: E402from tada.utils.text import normalize_text as normalize_text_fn # noqa: E402logging.basicConfig(level=logging.INFO)logger = logging.getLogger(__name__)321 unmodified linesaudio_duration = wav.shape[-1] / 24_000# Extract only text-to-speak step_logs, reconstructing any prefilled (missing) entriesall_logs = output.step_logs or []if _model is not None and text and output.input_text_ids is not None:input_ids = output.input_text_ids[0]seq_len = input_ids.shape[0]n_eos = _model.config.shift_acoustic# Count text-to-speak tokens (same logic as generate())normalized = normalize_text_fn(text) if normalize_text else textn_text_tokens = len(_model.tokenizer.encode(normalized, add_special_tokens=False))text_end = seq_len - n_eostext_start = text_end - n_text_tokens# Build a step -> log lookup from existing step_logslog_by_step = {e["step"]: e for e in all_logs}
app.py+6-9