]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
main : set stdin to binary mode on Windows (#2025)
authorRotem Dan <redacted>
Tue, 9 Apr 2024 15:33:32 +0000 (18:33 +0300)
committerGitHub <redacted>
Tue, 9 Apr 2024 15:33:32 +0000 (18:33 +0300)
examples/common.cpp

index 9ab162a5b3cbb099d7275b74f3387fd85c87b3d6..fad9a7c20096fd18685a26b4a6c00150abac852c 100644 (file)
 #pragma warning(disable: 4244 4267) // possible loss of data
 #endif
 
+#ifdef _WIN32
+#include <fcntl.h>
+#include <io.h>
+#endif
+
 // Function to check if the next argument exists
 std::string get_next_arg(int& i, int argc, char** argv, const std::string& flag, gpt_params& params) {
     if (i + 1 < argc && argv[i + 1][0] != '-') {
@@ -636,6 +641,10 @@ bool read_wav(const std::string & fname, std::vector<float>& pcmf32, std::vector
 
     if (fname == "-") {
         {
+            #ifdef _WIN32
+            _setmode(_fileno(stdin), _O_BINARY);
+            #endif
+
             uint8_t buf[1024];
             while (true)
             {