Merge branch 'ggerganov:master' into master

pull/357/head
Chidi Williams 3 years ago committed by GitHub
commit ef004b054c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -223,6 +223,7 @@ target_compile_definitions(${TARGET} PUBLIC
install(TARGETS ${TARGET} install(TARGETS ${TARGET}
LIBRARY DESTINATION lib LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static ARCHIVE DESTINATION lib/static
RUNTIME DESTINATION bin
) )
# #

@ -510,86 +510,23 @@ std::vector<std::string> read_allowed_commands(const std::string & fname) {
return allowed_commands; return allowed_commands;
} }
int main(int argc, char ** argv) { // command-list mode
whisper_params params; // guide the transcription to match the most likely command from a provided list
int process_command_list(struct whisper_context * ctx, audio_async &audio, const whisper_params &params) {
if (whisper_params_parse(argc, argv, params) == false) {
return 1;
}
if (whisper_lang_id(params.language.c_str()) == -1) {
fprintf(stderr, "error: unknown language '%s'\n", params.language.c_str());
whisper_print_usage(argc, argv, params);
exit(0);
}
// whisper init
struct whisper_context * ctx = whisper_init(params.model.c_str());
// print some info about the processing
{
fprintf(stderr, "\n");
if (!whisper_is_multilingual(ctx)) {
if (params.language != "en" || params.translate) {
params.language = "en";
params.translate = false;
fprintf(stderr, "%s: WARNING: model is not multilingual, ignoring language and translation options\n", __func__);
}
}
fprintf(stderr, "%s: processing, %d threads, lang = %s, task = %s, timestamps = %d ...\n",
__func__,
params.n_threads,
params.language.c_str(),
params.translate ? "translate" : "transcribe",
params.no_timestamps ? 0 : 1);
fprintf(stderr, "\n");
}
// init audio
audio_async audio(30*1000);
if (!audio.init(params.capture_id, WHISPER_SAMPLE_RATE)) {
fprintf(stderr, "%s: audio.init() failed!\n", __func__);
return 1;
}
audio.resume();
// wait for 1 second to avoid any buffered noise
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
audio.clear();
int max_len = 0;
bool is_running = true;
bool have_prompt = false;
bool ask_prompt = true;
float prob0 = 0.0f;
float prob = 0.0f;
std::vector<float> pcmf32_cur;
std::vector<float> pcmf32_prompt;
std::vector<std::string> allowed_commands;
std::vector<std::vector<whisper_token>> allowed_tokens;
std::string k_prompt;
std::vector<whisper_token> k_tokens;
if (!params.commands.empty()) {
fprintf(stderr, "\n"); fprintf(stderr, "\n");
fprintf(stderr, "%s: guided mode\n", __func__); fprintf(stderr, "%s: guided mode\n", __func__);
allowed_commands = read_allowed_commands(params.commands); std::vector<std::string> allowed_commands = read_allowed_commands(params.commands);
if (allowed_commands.empty()) { if (allowed_commands.empty()) {
fprintf(stderr, "%s: error: failed to read allowed commands from '%s'\n", __func__, params.commands.c_str()); fprintf(stderr, "%s: error: failed to read allowed commands from '%s'\n", __func__, params.commands.c_str());
return 2; return 2;
} }
int max_len = 0;
std::vector<std::vector<whisper_token>> allowed_tokens;
for (const auto & cmd : allowed_commands) { for (const auto & cmd : allowed_commands) {
whisper_token tokens[1024]; whisper_token tokens[1024];
allowed_tokens.emplace_back(); allowed_tokens.emplace_back();
@ -623,7 +560,7 @@ int main(int argc, char ** argv) {
fprintf(stderr, " ]\n"); fprintf(stderr, " ]\n");
} }
k_prompt = "select one from the available words: "; std::string k_prompt = "select one from the available words: ";
for (int i = 0; i < (int) allowed_commands.size(); ++i) { for (int i = 0; i < (int) allowed_commands.size(); ++i) {
if (i > 0) { if (i > 0) {
k_prompt += ", "; k_prompt += ", ";
@ -633,6 +570,7 @@ int main(int argc, char ** argv) {
k_prompt += ". selected word: "; k_prompt += ". selected word: ";
// tokenize prompt // tokenize prompt
std::vector<whisper_token> k_tokens;
{ {
k_tokens.resize(1024); k_tokens.resize(1024);
const int n = whisper_tokenize(ctx, k_prompt.c_str(), k_tokens.data(), 1024); const int n = whisper_tokenize(ctx, k_prompt.c_str(), k_tokens.data(), 1024);
@ -655,12 +593,10 @@ int main(int argc, char ** argv) {
fprintf(stderr, "%s: listening for a command ...\n", __func__); fprintf(stderr, "%s: listening for a command ...\n", __func__);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} else { bool is_running = true;
fprintf(stderr, "\n");
fprintf(stderr, "%s: general-purpose mode\n", __func__);
k_prompt = "Ok Whisper, start listening for commands."; std::vector<float> pcmf32_cur;
} std::vector<float> pcmf32_prompt;
// main loop // main loop
while (is_running) { while (is_running) {
@ -679,16 +615,145 @@ int main(int argc, char ** argv) {
} }
if (!is_running) { if (!is_running) {
break; return 0;
} }
} }
// delay // delay
std::this_thread::sleep_for(std::chrono::milliseconds(100)); std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (allowed_commands.empty()) { audio.get(2000, pcmf32_cur);
// general-purpose mode
// freely transcribe the voice into text if (vad_simple(pcmf32_cur, WHISPER_SAMPLE_RATE, 1000, params.vad_thold, params.freq_thold, params.print_energy)) {
fprintf(stdout, "%s: Speech detected! Processing ...\n", __func__);
const auto t_start = std::chrono::high_resolution_clock::now();
whisper_full_params wparams = whisper_full_default_params(WHISPER_SAMPLING_GREEDY);
wparams.print_progress = false;
wparams.print_special = params.print_special;
wparams.print_realtime = false;
wparams.print_timestamps = !params.no_timestamps;
wparams.translate = params.translate;
wparams.no_context = true;
wparams.single_segment = true;
wparams.max_tokens = 1;
wparams.language = params.language.c_str();
wparams.n_threads = params.n_threads;
wparams.audio_ctx = params.audio_ctx;
wparams.speed_up = params.speed_up;
wparams.prompt_tokens = k_tokens.data();
wparams.prompt_n_tokens = k_tokens.size();
// run the transformer and a single decoding pass
if (whisper_full(ctx, wparams, pcmf32_cur.data(), pcmf32_cur.size()) != 0) {
fprintf(stderr, "%s: ERROR: whisper_full() failed\n", __func__);
break;
}
const auto * probs = whisper_get_probs(ctx);
std::vector<std::pair<float, int>> probs_id;
double psum = 0.0;
for (int i = 0; i < (int) allowed_commands.size(); ++i) {
probs_id.emplace_back(probs[allowed_tokens[i][0]], i);
for (int j = 1; j < (int) allowed_tokens[i].size(); ++j) {
probs_id.back().first += probs[allowed_tokens[i][j]];
}
probs_id.back().first /= allowed_tokens[i].size();
psum += probs_id.back().first;
}
// normalize
for (auto & p : probs_id) {
p.first /= psum;
}
// sort descending
{
using pair_type = decltype(probs_id)::value_type;
std::sort(probs_id.begin(), probs_id.end(), [](const pair_type & a, const pair_type & b) {
return a.first > b.first;
});
}
// print the commands and the respective probabilities
{
fprintf(stdout, "\n");
for (const auto & cmd : probs_id) {
fprintf(stdout, "%s: %s%-*s%s = %f | ", __func__, "\033[1m", max_len, allowed_commands[cmd.second].c_str(), "\033[0m", cmd.first);
for (int token : allowed_tokens[cmd.second]) {
fprintf(stdout, "'%4s' %f ", whisper_token_to_str(ctx, token), probs[token]);
}
fprintf(stdout, "\n");
}
}
// best command
{
const auto t_end = std::chrono::high_resolution_clock::now();
const float prob = probs_id[0].first;
const int index = probs_id[0].second;
fprintf(stdout, "\n");
fprintf(stdout, "%s: detected command: %s%s%s | p = %f | t = %d ms\n", __func__,
"\033[1m", allowed_commands[index].c_str(), "\033[0m", prob,
(int) std::chrono::duration_cast<std::chrono::milliseconds>(t_end - t_start).count());
fprintf(stdout, "\n");
}
audio.clear();
}
}
return 0;
}
// general-purpose mode
// freely transcribe the voice into text
int process_general_transcription(struct whisper_context * ctx, audio_async &audio, const whisper_params &params) {
bool is_running = true;
bool have_prompt = false;
bool ask_prompt = true;
float prob0 = 0.0f;
float prob = 0.0f;
std::vector<float> pcmf32_cur;
std::vector<float> pcmf32_prompt;
const std::string k_prompt = "Ok Whisper, start listening for commands.";
fprintf(stderr, "\n");
fprintf(stderr, "%s: general-purpose mode\n", __func__);
// main loop
while (is_running) {
// handle Ctrl + C
{
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
{
is_running = false;
} break;
default:
break;
}
}
if (!is_running) {
return 0;
}
}
// delay
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (ask_prompt) { if (ask_prompt) {
fprintf(stdout, "\n"); fprintf(stdout, "\n");
@ -699,13 +764,13 @@ int main(int argc, char ** argv) {
} }
{ {
int64_t t_ms = 0;
audio.get(2000, pcmf32_cur); audio.get(2000, pcmf32_cur);
if (vad_simple(pcmf32_cur, WHISPER_SAMPLE_RATE, 1000, params.vad_thold, params.freq_thold, params.print_energy)) { if (vad_simple(pcmf32_cur, WHISPER_SAMPLE_RATE, 1000, params.vad_thold, params.freq_thold, params.print_energy)) {
fprintf(stdout, "%s: Speech detected! Processing ...\n", __func__); fprintf(stdout, "%s: Speech detected! Processing ...\n", __func__);
int64_t t_ms = 0;
if (!have_prompt) { if (!have_prompt) {
// wait for activation phrase // wait for activation phrase
audio.get(params.prompt_ms, pcmf32_cur); audio.get(params.prompt_ms, pcmf32_cur);
@ -767,94 +832,68 @@ int main(int argc, char ** argv) {
audio.clear(); audio.clear();
} }
} }
} else { }
// command-list mode
// guide the transcription to match the most likely command from a provided list
audio.get(2000, pcmf32_cur);
if (vad_simple(pcmf32_cur, WHISPER_SAMPLE_RATE, 1000, params.vad_thold, params.freq_thold, params.print_energy)) {
fprintf(stdout, "%s: Speech detected! Processing ...\n", __func__);
const auto t_start = std::chrono::high_resolution_clock::now();
whisper_full_params wparams = whisper_full_default_params(WHISPER_SAMPLING_GREEDY);
wparams.print_progress = false;
wparams.print_special = params.print_special;
wparams.print_realtime = false;
wparams.print_timestamps = !params.no_timestamps;
wparams.translate = params.translate;
wparams.no_context = true;
wparams.single_segment = true;
wparams.max_tokens = 1;
wparams.language = params.language.c_str();
wparams.n_threads = params.n_threads;
wparams.audio_ctx = params.audio_ctx; return 0;
wparams.speed_up = params.speed_up; }
wparams.prompt_tokens = k_tokens.data(); int main(int argc, char ** argv) {
wparams.prompt_n_tokens = k_tokens.size(); whisper_params params;
// run the transformer and a single decoding pass if (whisper_params_parse(argc, argv, params) == false) {
if (whisper_full(ctx, wparams, pcmf32_cur.data(), pcmf32_cur.size()) != 0) { return 1;
fprintf(stderr, "%s: ERROR: whisper_full() failed\n", __func__);
break;
} }
const auto * probs = whisper_get_probs(ctx); if (whisper_lang_id(params.language.c_str()) == -1) {
std::vector<std::pair<float, int>> probs_id; fprintf(stderr, "error: unknown language '%s'\n", params.language.c_str());
whisper_print_usage(argc, argv, params);
double psum = 0.0; exit(0);
for (int i = 0; i < (int) allowed_commands.size(); ++i) {
probs_id.emplace_back(probs[allowed_tokens[i][0]], i);
for (int j = 1; j < (int) allowed_tokens[i].size(); ++j) {
probs_id.back().first += probs[allowed_tokens[i][j]];
}
probs_id.back().first /= allowed_tokens[i].size();
psum += probs_id.back().first;
} }
// normalize // whisper init
for (auto & p : probs_id) {
p.first /= psum;
}
// sort descending struct whisper_context * ctx = whisper_init(params.model.c_str());
{
using pair_type = decltype(probs_id)::value_type;
std::sort(probs_id.begin(), probs_id.end(), [](const pair_type & a, const pair_type & b) {
return a.first > b.first;
});
}
// print the commands and the respective probabilities // print some info about the processing
{ {
fprintf(stdout, "\n"); fprintf(stderr, "\n");
for (const auto & cmd : probs_id) { if (!whisper_is_multilingual(ctx)) {
fprintf(stdout, "%s: %s%-*s%s = %f | ", __func__, "\033[1m", max_len, allowed_commands[cmd.second].c_str(), "\033[0m", cmd.first); if (params.language != "en" || params.translate) {
for (int i = 0; i < (int) allowed_tokens[cmd.second].size(); ++i) { params.language = "en";
fprintf(stdout, "'%4s' %f ", whisper_token_to_str(ctx, allowed_tokens[cmd.second][i]), probs[allowed_tokens[cmd.second][i]]); params.translate = false;
fprintf(stderr, "%s: WARNING: model is not multilingual, ignoring language and translation options\n", __func__);
} }
fprintf(stdout, "\n");
} }
fprintf(stderr, "%s: processing, %d threads, lang = %s, task = %s, timestamps = %d ...\n",
__func__,
params.n_threads,
params.language.c_str(),
params.translate ? "translate" : "transcribe",
params.no_timestamps ? 0 : 1);
fprintf(stderr, "\n");
} }
// best command // init audio
{
const auto t_end = std::chrono::high_resolution_clock::now();
fprintf(stdout, "\n"); audio_async audio(30*1000);
fprintf(stdout, "%s: detected command: %s%s%s | p = %f | t = %d ms\n", __func__, if (!audio.init(params.capture_id, WHISPER_SAMPLE_RATE)) {
"\033[1m", allowed_commands[probs_id[0].second].c_str(), "\033[0m", probs_id[0].first, fprintf(stderr, "%s: audio.init() failed!\n", __func__);
(int) std::chrono::duration_cast<std::chrono::milliseconds>(t_end - t_start).count()); return 1;
fprintf(stdout, "\n");
} }
audio.resume();
// wait for 1 second to avoid any buffered noise
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
audio.clear(); audio.clear();
}
} int ret_val = 0;
if (!params.commands.empty()) {
ret_val = process_command_list(ctx, audio, params);
} else {
ret_val = process_general_transcription(ctx, audio, params);
} }
audio.pause(); audio.pause();
@ -862,5 +901,5 @@ int main(int argc, char ** argv) {
whisper_print_timings(ctx); whisper_print_timings(ctx);
whisper_free(ctx); whisper_free(ctx);
return 0; return ret_val;
} }

@ -781,18 +781,25 @@ inline static void ggml_vec_dot_f16(const int n, float * restrict s, ggml_fp16_t
const int n32 = (n & ~31); const int n32 = (n & ~31);
vector float sum0 = vec_splats (0.0f); vector float sum0 = vec_splats (0.0f);
vector float sum1 = vec_splats (0.0f);
for (int i = 0; i < n32; i += 32) { vector float sum2 = vec_splats (0.0f);
vector float sum3 = vec_splats (0.0f);
vector float sum4 = vec_splats (0.0f);
vector float sum5 = vec_splats (0.0f);
vector float sum6 = vec_splats (0.0f);
vector float sum7 = vec_splats (0.0f);
for (int i = 0, j = 0; i < n32; i += 32, j += 64) {
// Use vec_xl, not vec_ld, because x is sometimes unaligned. // Use vec_xl, not vec_ld, because x is sometimes unaligned.
vector unsigned short x0 = vec_xl(i * 2 + 0, x); vector unsigned short x0 = vec_xl(j + 0, x);
vector unsigned short x1 = vec_xl(i * 2 + 16, x); vector unsigned short x1 = vec_xl(j + 16, x);
vector unsigned short x2 = vec_xl(i * 2 + 32, x); vector unsigned short x2 = vec_xl(j + 32, x);
vector unsigned short x3 = vec_xl(i * 2 + 48, x); vector unsigned short x3 = vec_xl(j + 48, x);
vector unsigned short y0 = vec_xl(i * 2 + 0, y); vector unsigned short y0 = vec_ld(j + 0, y);
vector unsigned short y1 = vec_xl(i * 2 + 16, y); vector unsigned short y1 = vec_ld(j + 16, y);
vector unsigned short y2 = vec_xl(i * 2 + 32, y); vector unsigned short y2 = vec_ld(j + 32, y);
vector unsigned short y3 = vec_xl(i * 2 + 48, y); vector unsigned short y3 = vec_ld(j + 48, y);
vector float fx0l = vec_extract_fp32_from_shortl(x0); vector float fx0l = vec_extract_fp32_from_shortl(x0);
vector float fx0h = vec_extract_fp32_from_shorth(x0); vector float fx0h = vec_extract_fp32_from_shorth(x0);
@ -812,16 +819,26 @@ inline static void ggml_vec_dot_f16(const int n, float * restrict s, ggml_fp16_t
vector float fy3l = vec_extract_fp32_from_shortl(y3); vector float fy3l = vec_extract_fp32_from_shortl(y3);
vector float fy3h = vec_extract_fp32_from_shorth(y3); vector float fy3h = vec_extract_fp32_from_shorth(y3);
sum0 = vec_add(sum0, vec_mul(fx0l, fy0l)); sum0 = vec_madd(fx0l, fy0l, sum0);
sum0 = vec_add(sum0, vec_mul(fx0h, fy0h)); sum1 = vec_madd(fx0h, fy0h, sum1);
sum0 = vec_add(sum0, vec_mul(fx1l, fy1l)); sum2 = vec_madd(fx1l, fy1l, sum2);
sum0 = vec_add(sum0, vec_mul(fx1h, fy1h)); sum3 = vec_madd(fx1h, fy1h, sum3);
sum0 = vec_add(sum0, vec_mul(fx2l, fy2l)); sum4 = vec_madd(fx2l, fy2l, sum4);
sum0 = vec_add(sum0, vec_mul(fx2h, fy2h)); sum5 = vec_madd(fx2h, fy2h, sum5);
sum0 = vec_add(sum0, vec_mul(fx3l, fy3l)); sum6 = vec_madd(fx3l, fy3l, sum6);
sum0 = vec_add(sum0, vec_mul(fx3h, fy3h)); sum7 = vec_madd(fx3h, fy3h, sum7);
} }
sum0 = vec_add(sum0, sum1);
sum2 = vec_add(sum2, sum3);
sum4 = vec_add(sum4, sum5);
sum6 = vec_add(sum6, sum7);
sum0 = vec_add(sum0, sum2);
sum4 = vec_add(sum4, sum6);
sum0 = vec_add(sum0, sum4);
sumf = vec_extract(sum0, 0) + vec_extract(sum0, 1) sumf = vec_extract(sum0, 0) + vec_extract(sum0, 1)
+ vec_extract(sum0, 2) + vec_extract(sum0, 3); + vec_extract(sum0, 2) + vec_extract(sum0, 3);
@ -896,17 +913,17 @@ inline static void ggml_vec_mad_f16(const int n, ggml_fp16_t * restrict y, ggml_
// TODO: this is temporary because I cannot fit it in the GGML_SIMD pattern like all other architectures without // TODO: this is temporary because I cannot fit it in the GGML_SIMD pattern like all other architectures without
// being able to test it. hoping someone with access to a POWER9 machine can help out here. // being able to test it. hoping someone with access to a POWER9 machine can help out here.
const int n32 = (n & ~31); const int n32 = (n & ~31);
for (int i = 0; i < n32; i += 32) { for (int i = 0, j = 0; i < n32; i += 32, j += 64) {
// Use vec_xl, not vec_ld, because x is sometimes unaligned! // Use vec_xl, not vec_ld, because x is sometimes unaligned!
vector unsigned short x0 = vec_xl(i * 2 + 0, x); vector unsigned short x0 = vec_xl(j + 0, x);
vector unsigned short x1 = vec_xl(i * 2 + 16, x); vector unsigned short x1 = vec_xl(j + 16, x);
vector unsigned short x2 = vec_xl(i * 2 + 32, x); vector unsigned short x2 = vec_xl(j + 32, x);
vector unsigned short x3 = vec_xl(i * 2 + 48, x); vector unsigned short x3 = vec_xl(j + 48, x);
vector unsigned short y0 = vec_xl(i * 2 + 0, y); vector unsigned short y0 = vec_xl(j + 0, y);
vector unsigned short y1 = vec_xl(i * 2 + 16, y); vector unsigned short y1 = vec_xl(j + 16, y);
vector unsigned short y2 = vec_xl(i * 2 + 32, y); vector unsigned short y2 = vec_xl(j + 32, y);
vector unsigned short y3 = vec_xl(i * 2 + 48, y); vector unsigned short y3 = vec_xl(j + 48, y);
vector float v4 = vec_splats(v); vector float v4 = vec_splats(v);
@ -942,10 +959,10 @@ inline static void ggml_vec_mad_f16(const int n, ggml_fp16_t * restrict y, ggml_
y2 = vec_pack_to_short_fp32(fy2h, fy2l); y2 = vec_pack_to_short_fp32(fy2h, fy2l);
y3 = vec_pack_to_short_fp32(fy3h, fy3l); y3 = vec_pack_to_short_fp32(fy3h, fy3l);
vec_xst(y0, i * 2 + 0, y); vec_xst(y0, j + 0, y);
vec_xst(y1, i * 2 + 16, y); vec_xst(y1, j + 16, y);
vec_xst(y2, i * 2 + 32, y); vec_xst(y2, j + 32, y);
vec_xst(y3, i * 2 + 48, y); vec_xst(y3, j + 48, y);
} }
for (int i = n32; i < n; ++i) { for (int i = n32; i < n; ++i) {

@ -56,7 +56,7 @@ def bytes_to_unicode():
The reversible bpe codes work on unicode strings. The reversible bpe codes work on unicode strings.
This means you need a large # of unicode characters in your vocab if you want to avoid UNKs. This means you need a large # of unicode characters in your vocab if you want to avoid UNKs.
When you're at something like a 10B token dataset you end up needing around 5K for decent coverage. When you're at something like a 10B token dataset you end up needing around 5K for decent coverage.
This is a signficant percentage of your normal, say, 32K bpe vocab. This is a significant percentage of your normal, say, 32K bpe vocab.
To avoid that, we want lookup tables between utf-8 bytes and unicode strings. To avoid that, we want lookup tables between utf-8 bytes and unicode strings.
And avoids mapping to whitespace/control characters the bpe code barfs on. And avoids mapping to whitespace/control characters the bpe code barfs on.
""" """

@ -2497,6 +2497,10 @@ int whisper_n_text_ctx(struct whisper_context * ctx) {
return ctx->model.hparams.n_text_ctx; return ctx->model.hparams.n_text_ctx;
} }
int whisper_n_audio_ctx(struct whisper_context * ctx) {
return ctx->model.hparams.n_audio_ctx;
}
int whisper_is_multilingual(struct whisper_context * ctx) { int whisper_is_multilingual(struct whisper_context * ctx) {
return ctx->vocab.is_multilingual() ? 1 : 0; return ctx->vocab.is_multilingual() ? 1 : 0;
} }
@ -2822,7 +2826,11 @@ int whisper_full(
std::rotate(prompt_past.begin(), prompt_past.end() - params.prompt_n_tokens, prompt_past.end()); std::rotate(prompt_past.begin(), prompt_past.end() - params.prompt_n_tokens, prompt_past.end());
} }
// overwrite audio_ctx // overwrite audio_ctx, max allowed is hparams.n_audio_ctx
if (params.audio_ctx > whisper_n_audio_ctx(ctx)) {
fprintf(stderr, "%s: audio_ctx is larger than the maximum allowed (%d > %d)\n", __func__, params.audio_ctx, whisper_n_audio_ctx(ctx));
return -4;
}
ctx->exp_n_audio_ctx = params.audio_ctx; ctx->exp_n_audio_ctx = params.audio_ctx;
// these tokens determine the task that will be performed // these tokens determine the task that will be performed

@ -177,6 +177,7 @@ extern "C" {
WHISPER_API int whisper_n_len (struct whisper_context * ctx); // mel length WHISPER_API int whisper_n_len (struct whisper_context * ctx); // mel length
WHISPER_API int whisper_n_vocab (struct whisper_context * ctx); WHISPER_API int whisper_n_vocab (struct whisper_context * ctx);
WHISPER_API int whisper_n_text_ctx (struct whisper_context * ctx); WHISPER_API int whisper_n_text_ctx (struct whisper_context * ctx);
WHISPER_API int whisper_n_audio_ctx (struct whisper_context * ctx);
WHISPER_API int whisper_is_multilingual(struct whisper_context * ctx); WHISPER_API int whisper_is_multilingual(struct whisper_context * ctx);
// The probabilities for the next token // The probabilities for the next token

Loading…
Cancel
Save