(length: int)
| 153 | lengths_iter = iter(lengths) |
| 154 | |
| 155 | def _build_block(length: int) -> str: |
| 156 | if length == 0: |
| 157 | return f"{audio_start_token}{audio_end_token}" |
| 158 | step_tokens = gen_slot_token * length + delay_slot_token * (n_vq - 1) |
| 159 | return f"{audio_start_token}{step_tokens}{audio_end_token}" |
| 160 | |
| 161 | def replacer(match: re.Match) -> str: |
| 162 | return _build_block(next(lengths_iter)) |