| 185 | |
| 186 | append_tokens(encoding, encode(kSystemPrompt), false); |
| 187 | |
| 188 | if (!request.speakers.empty()) { |
| 189 | append_tokens(encoding, encode(" Voice input:\n"), false); |
| 190 | for (size_t index = 0; index < request.speakers.size(); ++index) { |
| 191 | append_tokens(encoding, encode(" Speaker " + std::to_string(index) + ":"), false); |
| 192 | append_token(encoding, impl_->speech_start, false); |
| 193 | const int64_t speech_tokens = speech_token_count( |
| 194 | request.speakers[index].audio, |
| 195 | impl_->assets->processor.speech_tok_compress_ratio); |
| 196 | encoding.speech_prompt_token_counts.push_back(speech_tokens); |
| 197 | for (int64_t i = 0; i < speech_tokens; ++i) { |
| 198 | append_token(encoding, impl_->speech_diffusion, true); |
| 199 | } |
| 200 | append_token(encoding, impl_->speech_end, false); |
| 201 | append_tokens(encoding, encode("\n"), false); |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | append_tokens(encoding, encode(" Text input:\n"), false); |
| 206 | for (const auto & line : encoding.parsed_script) { |
| 207 | append_tokens( |
| 208 | encoding, |
| 209 | encode(" Speaker " + std::to_string(line.speaker_id) + ":" + line.text + "\n"), |
| 210 | false); |
| 211 | } |
| 212 | append_tokens(encoding, encode(" Speech output:\n"), false); |
| 213 | append_token(encoding, impl_->speech_start, false); |
| 214 | encoding.attention_mask.assign(encoding.input_ids.size(), 1); |
| 215 | return encoding; |
| 216 | } |
| 217 | |
| 218 | int32_t VibeVoiceTextTokenizer::eos_id() const noexcept { |
| 219 | return impl_->eos; |
| 220 | } |
| 221 | |
| 222 | int32_t VibeVoiceTextTokenizer::pad_id() const noexcept { |
| 223 | return impl_->pad; |
| 224 | } |
| 225 |
no test coverage detected