2024-06-04 08:32:23 +02:00
|
|
|
#pragma once
|
|
|
|
#include "ggml-backend.h"
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
struct whisper_mel {
|
2024-06-06 15:20:46 +02:00
|
|
|
int n_len_org = 0;
|
2024-06-04 08:32:23 +02:00
|
|
|
|
2024-06-06 15:20:46 +02:00
|
|
|
ggml_context * ctx = nullptr;
|
2024-06-06 17:51:36 +02:00
|
|
|
ggml_tensor * tensor = nullptr;
|
2024-06-06 15:20:46 +02:00
|
|
|
ggml_backend_buffer_t buffer = nullptr;
|
2024-06-06 17:51:36 +02:00
|
|
|
};
|
2024-06-06 15:20:46 +02:00
|
|
|
|
2024-06-06 17:51:36 +02:00
|
|
|
void whisper_mel_init(whisper_mel & mel, ggml_backend_t backend, int n_len, int n_len_org, int n_mel);
|
2024-06-06 15:20:46 +02:00
|
|
|
|
2024-06-06 17:51:36 +02:00
|
|
|
void whisper_mel_free(whisper_mel & mel);
|
2024-06-04 08:32:23 +02:00
|
|
|
|
|
|
|
struct whisper_filters {
|
|
|
|
int32_t n_mel;
|
|
|
|
int32_t n_fft;
|
|
|
|
|
|
|
|
std::vector<float> data;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct whisper_span {
|
|
|
|
T * data;
|
|
|
|
int len;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct whisper_mel_calc {
|
|
|
|
virtual ~whisper_mel_calc();
|
2024-06-10 20:51:32 +02:00
|
|
|
virtual whisper_mel calculate(whisper_span<const float> samples, int n_threads) = 0;
|
2024-06-04 08:32:23 +02:00
|
|
|
static whisper_span<const float> hann_window();
|
|
|
|
};
|