MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / encode_prompt

Method encode_prompt

src/models/vibevoice/tokenizer_text.cpp:187–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
218int32_t VibeVoiceTextTokenizer::eos_id() const noexcept {
219 return impl_->eos;
220}
221
222int32_t VibeVoiceTextTokenizer::pad_id() const noexcept {
223 return impl_->pad;
224}
225

Callers 2

prepare_vibevoice_promptFunction · 0.45

Calls 9

parse_scriptFunction · 0.85
collect_speaker_idsFunction · 0.85
append_tokensFunction · 0.85
append_tokenFunction · 0.85
speech_token_countFunction · 0.85
assignMethod · 0.80
to_stringFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected