| 1 | #pragma once |
| 2 | |
| 3 | #include "ggml.h" |
| 4 | |
| 5 | #include <cstdint> |
| 6 | #include <vector> |
| 7 | #include <string> |
| 8 | |
| 9 | #define WHISPER_ASSERT GGML_ASSERT |
| 10 | |
| 11 | #define WHISPER_SAMPLE_RATE 16000 |
| 12 | #define WHISPER_N_FFT 400 |
| 13 | #define WHISPER_HOP_LENGTH 160 |
| 14 | #define WHISPER_CHUNK_SIZE 30 |
| 15 | |
| 16 | #define COMMON_SAMPLE_RATE 16000 |
| 17 | |
| 18 | namespace whisper_preprocessor { |
| 19 | |
| 20 | struct whisper_mel { |
| 21 | int n_len; |
| 22 | int n_len_org; |
| 23 | int n_mel; |
| 24 | |
| 25 | std::vector<float> data; |
| 26 | }; |
| 27 | |
| 28 | struct whisper_filters { |
| 29 | int32_t n_mel; |
| 30 | int32_t n_fft; |
| 31 | |
| 32 | std::vector<float> data; |
| 33 | }; |
| 34 | |
| 35 | bool preprocess_audio( |
| 36 | const float * samples, |
| 37 | size_t n_samples, |
| 38 | const whisper_filters & filters, |
| 39 | std::vector<whisper_mel> & output); |
| 40 | |
| 41 | } // namespace whisper_preprocessor |
| 42 | |
| 43 | namespace whisper_precalc_filters { |
| 44 | |
| 45 | whisper_preprocessor::whisper_filters get_128_bins(); |
| 46 | |
| 47 | } // namespace whisper_precalc_filters |
| 48 | |