Skip to content

fix building & UTF8 output with MSVC + SDL2 #2826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/command/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
#include <thread>
#include <vector>
#include <map>
#include <chrono>

#if defined(_WIN32)
#define NOMINMAX
#include <windows.h>
#endif

// command-line parameters
struct whisper_params {
Expand Down Expand Up @@ -679,6 +685,10 @@ static int process_general_transcription(struct whisper_context * ctx, audio_asy
}

int main(int argc, char ** argv) {
#if defined(_WIN32)
SetConsoleOutputCP(CP_UTF8);
#endif

whisper_params params;

if (whisper_params_parse(argc, argv, params) == false) {
Expand Down
1 change: 1 addition & 0 deletions examples/lsp/lsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <vector>
#include <deque>
#include <set>
#include <chrono>

using json = nlohmann::json;

Expand Down
1 change: 1 addition & 0 deletions examples/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <vector>
#include <cstring>
#include <sstream>
#include <chrono>

#if defined(_MSC_VER)
#pragma warning(disable: 4244 4267) // possible loss of data
Expand Down
12 changes: 12 additions & 0 deletions examples/stream/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
#include <thread>
#include <vector>
#include <fstream>
#include <chrono>

#if defined(_WIN32)
#define NOMINMAX
#include <windows.h>
#endif

// command-line parameters
struct whisper_params {
Expand Down Expand Up @@ -113,6 +118,10 @@ void whisper_print_usage(int /*argc*/, char ** argv, const whisper_params & para
}

int main(int argc, char ** argv) {
#if defined(_WIN32)
SetConsoleOutputCP(CP_UTF8);
#endif

whisper_params params;

if (whisper_params_parse(argc, argv, params) == false) {
Expand Down Expand Up @@ -157,6 +166,7 @@ int main(int argc, char ** argv) {
cparams.use_gpu = params.use_gpu;
cparams.flash_attn = params.flash_attn;

fprintf(stderr, "whisper_init_from_file_with_params ...\n");
struct whisper_context * ctx = whisper_init_from_file_with_params(params.model.c_str(), cparams);

std::vector<float> pcmf32 (n_samples_30s, 0.0f);
Expand All @@ -166,6 +176,8 @@ int main(int argc, char ** argv) {
std::vector<whisper_token> prompt_tokens;

// print some info about the processing
fprintf(stderr, "whisper_init_from_file_with_params ok\n");

{
fprintf(stderr, "\n");
if (!whisper_is_multilingual(ctx)) {
Expand Down
10 changes: 10 additions & 0 deletions examples/talk-llama/talk-llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#include <vector>
#include <regex>
#include <sstream>
#include <chrono>

#if defined(_WIN32)
#define NOMINMAX
#include <windows.h>
#endif

static std::vector<llama_token> llama_tokenize(struct llama_context * ctx, const std::string & text, bool add_bos) {
const llama_model * model = llama_get_model(ctx);
Expand Down Expand Up @@ -272,6 +278,10 @@ The transcript only includes text, it does not include markup like HTML and Mark
{0}{4})";

int main(int argc, char ** argv) {
#if defined(_WIN32)
SetConsoleOutputCP(CP_UTF8);
#endif

whisper_params params;

if (whisper_params_parse(argc, argv, params) == false) {
Expand Down
1 change: 1 addition & 0 deletions examples/wchess/libwchess/WChess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "grammar-parser.h"
#include "common.h"
#include <thread>
#include <chrono>

WChess::WChess(whisper_context * ctx,
const whisper_full_params & wparams,
Expand Down
Loading