eschmidbauer commited on
Commit
66a3eb1
·
unverified ·
1 Parent(s): bce6859

server : add inference path to make OAI API compatible (#2270)

Browse files
Files changed (1) hide show
  1. examples/server/server.cpp +5 -2
examples/server/server.cpp CHANGED
@@ -34,6 +34,7 @@ struct server_params
34
  std::string hostname = "127.0.0.1";
35
  std::string public_path = "examples/server/public";
36
  std::string request_path = "";
 
37
 
38
  int32_t port = 8080;
39
  int32_t read_timeout = 600;
@@ -132,6 +133,7 @@ void whisper_print_usage(int /*argc*/, char ** argv, const whisper_params & para
132
  fprintf(stderr, " --port PORT, [%-7d] Port number for the server\n", sparams.port);
133
  fprintf(stderr, " --public PATH, [%-7s] Path to the public folder\n", sparams.public_path.c_str());
134
  fprintf(stderr, " --request-path PATH, [%-7s] Request path for all requests\n", sparams.request_path.c_str());
 
135
  fprintf(stderr, " --convert, [%-7s] Convert audio to WAV, requires ffmpeg on the server", sparams.ffmpeg_converter ? "true" : "false");
136
  fprintf(stderr, "\n");
137
  }
@@ -182,6 +184,7 @@ bool whisper_params_parse(int argc, char ** argv, whisper_params & params, serve
182
  else if ( arg == "--host") { sparams.hostname = argv[++i]; }
183
  else if ( arg == "--public") { sparams.public_path = argv[++i]; }
184
  else if ( arg == "--request-path") { sparams.request_path = argv[++i]; }
 
185
  else if ( arg == "--convert") { sparams.ffmpeg_converter = true; }
186
  else {
187
  fprintf(stderr, "error: unknown argument: %s\n", arg.c_str());
@@ -644,10 +647,10 @@ int main(int argc, char ** argv) {
644
  return false;
645
  });
646
 
647
- svr.Options(sparams.request_path + "/inference", [&](const Request &, Response &){
648
  });
649
 
650
- svr.Post(sparams.request_path + "/inference", [&](const Request &req, Response &res){
651
  // acquire whisper model mutex lock
652
  std::lock_guard<std::mutex> lock(whisper_mutex);
653
 
 
34
  std::string hostname = "127.0.0.1";
35
  std::string public_path = "examples/server/public";
36
  std::string request_path = "";
37
+ std::string inference_path = "/inference";
38
 
39
  int32_t port = 8080;
40
  int32_t read_timeout = 600;
 
133
  fprintf(stderr, " --port PORT, [%-7d] Port number for the server\n", sparams.port);
134
  fprintf(stderr, " --public PATH, [%-7s] Path to the public folder\n", sparams.public_path.c_str());
135
  fprintf(stderr, " --request-path PATH, [%-7s] Request path for all requests\n", sparams.request_path.c_str());
136
+ fprintf(stderr, " --inference-path PATH, [%-7s] Inference path for all requests\n", sparams.inference_path.c_str());
137
  fprintf(stderr, " --convert, [%-7s] Convert audio to WAV, requires ffmpeg on the server", sparams.ffmpeg_converter ? "true" : "false");
138
  fprintf(stderr, "\n");
139
  }
 
184
  else if ( arg == "--host") { sparams.hostname = argv[++i]; }
185
  else if ( arg == "--public") { sparams.public_path = argv[++i]; }
186
  else if ( arg == "--request-path") { sparams.request_path = argv[++i]; }
187
+ else if ( arg == "--inference-path") { sparams.inference_path = argv[++i]; }
188
  else if ( arg == "--convert") { sparams.ffmpeg_converter = true; }
189
  else {
190
  fprintf(stderr, "error: unknown argument: %s\n", arg.c_str());
 
647
  return false;
648
  });
649
 
650
+ svr.Options(sparams.request_path + sparams.inference_path, [&](const Request &, Response &){
651
  });
652
 
653
+ svr.Post(sparams.request_path + sparams.inference_path, [&](const Request &req, Response &res){
654
  // acquire whisper model mutex lock
655
  std::lock_guard<std::mutex> lock(whisper_mutex);
656