mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2025-04-25 13:30:12 +00:00
Merge d0f38def0878d13ee9fbb50a6c31c0232c4d07d9 into 2c502b3c009bc4b1465fdf3d0213cefab42d829d
This commit is contained in:
commit
712b560c58
@ -408,6 +408,9 @@ extern "C" {
|
||||
WHISPER_API const char * whisper_token_to_str(struct whisper_context * ctx, whisper_token token);
|
||||
WHISPER_API const char * whisper_model_type_readable(struct whisper_context * ctx);
|
||||
|
||||
// String -> Token Id. Uses the vocabulary in the provided context
|
||||
WHISPER_API bool whisper_token_exists(struct whisper_context * ctx, const char * str);
|
||||
WHISPER_API whisper_token whisper_str_to_token(struct whisper_context * ctx, const char * str);
|
||||
|
||||
// Special tokens
|
||||
WHISPER_API whisper_token whisper_token_eot (struct whisper_context * ctx);
|
||||
|
@ -4208,6 +4208,14 @@ const char * whisper_token_to_str(struct whisper_context * ctx, whisper_token to
|
||||
return ctx->vocab.id_to_token.at(token).c_str();
|
||||
}
|
||||
|
||||
whisper_token whisper_str_to_token(struct whisper_context * ctx, const char * str) {
|
||||
return ctx->vocab.token_to_id.at(str);
|
||||
}
|
||||
|
||||
bool whisper_token_exists(struct whisper_context * ctx, const char * str) {
|
||||
return ctx->vocab.token_to_id.find(str) != ctx->vocab.token_to_id.end();
|
||||
}
|
||||
|
||||
whisper_token whisper_token_eot(struct whisper_context * ctx) {
|
||||
return ctx->vocab.token_eot;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user