mtmd-audio.h 888 B

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