From: Georgi Gerganov Date: Sun, 25 Jun 2023 11:19:47 +0000 (+0300) Subject: whisper : sync latest whisper.cpp X-Git-Tag: upstream/0.0.1642~1386 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=d591c5fdc126339eecce718ace0a4b3200cf0e46;p=pkg%2Fggml%2Fsources%2Fggml whisper : sync latest whisper.cpp --- diff --git a/examples/whisper/main.cpp b/examples/whisper/main.cpp index 1083512f..07a7591f 100644 --- a/examples/whisper/main.cpp +++ b/examples/whisper/main.cpp @@ -693,6 +693,7 @@ int main(int argc, char ** argv) { whisper_params params; if (whisper_params_parse(argc, argv, params) == false) { + whisper_print_usage(argc, argv, params); return 1; } diff --git a/examples/whisper/whisper.cpp b/examples/whisper/whisper.cpp index 89f36bfd..65c57f7d 100644 --- a/examples/whisper/whisper.cpp +++ b/examples/whisper/whisper.cpp @@ -2856,6 +2856,12 @@ void whisper_free(struct whisper_context * ctx) { } } +void whisper_free_params(struct whisper_full_params * params) { + if (params) { + delete params; + } +} + int whisper_pcm_to_mel_with_state(struct whisper_context * ctx, struct whisper_state * state, const float * samples, int n_samples, int n_threads) { if (!log_mel_spectrogram(*state, samples, n_samples, WHISPER_SAMPLE_RATE, WHISPER_N_FFT, WHISPER_HOP_LENGTH, WHISPER_N_MEL, n_threads, ctx->model.filters, false, state->mel)) { fprintf(stderr, "%s: failed to compute mel spectrogram\n", __func__); @@ -3289,6 +3295,14 @@ const char * whisper_print_system_info(void) { //////////////////////////////////////////////////////////////////////////// +struct whisper_full_params * whisper_full_default_params_by_ref(enum whisper_sampling_strategy strategy) { + struct whisper_full_params params = whisper_full_default_params(strategy); + + struct whisper_full_params* result = new whisper_full_params(); + *result = params; + return result; +} + struct whisper_full_params whisper_full_default_params(enum whisper_sampling_strategy strategy) { struct whisper_full_params result = { /*.strategy =*/ strategy, diff --git a/examples/whisper/whisper.h b/examples/whisper/whisper.h index 2d5b3eb9..e983c7d4 100644 --- a/examples/whisper/whisper.h +++ b/examples/whisper/whisper.h @@ -113,6 +113,7 @@ extern "C" { // Frees all allocated memory WHISPER_API void whisper_free (struct whisper_context * ctx); WHISPER_API void whisper_free_state(struct whisper_state * state); + WHISPER_API void whisper_free_params(struct whisper_full_params * params); // Convert RAW PCM audio to log mel spectrogram. // The resulting spectrogram is stored inside the default state of the provided whisper context. @@ -409,6 +410,8 @@ extern "C" { void * logits_filter_callback_user_data; }; + // NOTE: this function allocates memory, and it is the responsibility of the caller to free the pointer - see whisper_free_params() + WHISPER_API struct whisper_full_params * whisper_full_default_params_by_ref(enum whisper_sampling_strategy strategy); WHISPER_API struct whisper_full_params whisper_full_default_params(enum whisper_sampling_strategy strategy); // Run the entire model: PCM -> log mel spectrogram -> encoder -> decoder -> text