Run the Whisper decoder to obtain the logits and probabilities for the next token. Make sure to call whisper_encode() first. tokens + n_tokens is the provided context for the decoder. n_past is the number of tokens to use from previous decoder calls. Returns vec on success.
| 219 | // provided context for the decoder. n_past is the number of tokens to use |
| 220 | // from previous decoder calls. Returns vec<whisper_token> on success. |
| 221 | std::vector<whisper_token> Context::tokenize(std::string *text, |
| 222 | size_t max_tokens) { |
| 223 | std::vector<whisper_token> tokens; |
| 224 | tokens.reserve(max_tokens); |
| 225 | |
| 226 | int ret = whisper_tokenize(wctx, text->c_str(), tokens.data(), max_tokens); |
| 227 | |
| 228 | if (ret == -1) { |
| 229 | RAISE_RUNTIME_ERROR("Too many results tokens."); |
| 230 | } else { |
| 231 | // ret != -1 then length of the vector is at least ret tokens |
| 232 | tokens.reserve(ret); |
| 233 | } |
| 234 | return tokens; |
| 235 | }; |
| 236 | |
| 237 | // Returns id of a given language, raise exception if not found |
| 238 | int Context::lang_str_to_id(const char *lang) { |
nothing calls this directly
no outgoing calls
no test coverage detected