]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
whisper : sync latest whisper.cpp
authorGeorgi Gerganov <redacted>
Sun, 25 Jun 2023 11:19:47 +0000 (14:19 +0300)
committerGeorgi Gerganov <redacted>
Sun, 25 Jun 2023 11:19:47 +0000 (14:19 +0300)
examples/whisper/main.cpp
examples/whisper/whisper.cpp
examples/whisper/whisper.h

index 1083512fc97032068318b3387d693e96376e6233..07a7591fe2151dc3c3b649c545c8f01b504aa288 100644 (file)
@@ -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;
     }
 
index 89f36bfd0d0bdb6f3bb75b24256379dbfe8fd263..65c57f7d0d5d5ead4688c9f91afa94cfb2e29f7d 100644 (file)
@@ -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,
index 2d5b3eb98579811e86e531d8bbab9b2d75403d9e..e983c7d4fa323f65ac9912e1e53982367cf2a8ea 100644 (file)
@@ -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