]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
common : pass sample rate to `ffmpeg_decode_audio()`
authorGeorgi Gerganov <redacted>
Sun, 31 May 2026 12:48:05 +0000 (15:48 +0300)
committerGeorgi Gerganov <redacted>
Sun, 31 May 2026 12:49:13 +0000 (15:49 +0300)
examples/common-whisper.cpp
examples/ffmpeg-transcode.cpp

index 8cdd2320c17d5c9016a4268663b366212eda2cd0..c84e6843adc8e1c8c9ccf3877dd2ef629ad242aa 100644 (file)
@@ -36,7 +36,7 @@
 
 #ifdef WHISPER_COMMON_FFMPEG
 // as implemented in ffmpeg-trancode.cpp only embedded in common lib if whisper built with ffmpeg support
-extern bool ffmpeg_decode_audio(const std::string & ifname, std::vector<uint8_t> & wav_data);
+extern bool ffmpeg_decode_audio(const std::string & ifname, std::vector<uint8_t> & wav_data, int out_sample_rate = WHISPER_SAMPLE_RATE);
 #endif
 
 // extract f32 PCM frames from an initialized decoder, downmix to mono and keep the stereo split
index dc57fe745966e53a33dcbea2e012816da83806d7..7657af6982336d1e83a1475a150debfe574d078c 100644 (file)
@@ -1,7 +1,5 @@
 #ifdef WHISPER_COMMON_FFMPEG
 
-#include "whisper.h"
-
 #include <string>
 #include <vector>
 #include <cstdio>
@@ -44,7 +42,7 @@ static size_t wav_header_write(uint8_t * buf, int num_channels, int sample_rate,
     return 44;
 }
 
-bool ffmpeg_decode_audio(const std::string & ifname, std::vector<uint8_t> & wav_data) {
+bool ffmpeg_decode_audio(const std::string & ifname, std::vector<uint8_t> & wav_data, int out_sample_rate) {
     {
         const char * verbose = getenv("WHISPER_COMMON_FFMPEG_VERBOSE");
         if (verbose && strcmp(verbose, "2") == 0) {
@@ -116,7 +114,6 @@ bool ffmpeg_decode_audio(const std::string & ifname, std::vector<uint8_t> & wav_
 
     // Setup resampler: convert to 16-bit signed PCM, mono, 16000 Hz
     const enum AVSampleFormat out_sample_fmt = AV_SAMPLE_FMT_S16;
-    const int out_sample_rate = WHISPER_SAMPLE_RATE;
 
     AVChannelLayout out_ch_layout = AV_CHANNEL_LAYOUT_MONO;