Skip to content

Commit

Permalink
remove std cout
Browse files Browse the repository at this point in the history
  • Loading branch information
deguodedongxi committed Dec 19, 2024
1 parent e7d4e17 commit 941df64
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions src/cpp/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,34 +138,34 @@ int main(int argc, char *argv[])
try {
RunConfig runConfig;
// // Log Body
std::cout << "Request body: " << req.body << std::endl;
// std::cout << "Request body: " << req.body << std::endl;
parseArgsFromJson(json::parse(req.body), runConfig);

#ifdef _WIN32
// Required on Windows to show IPA symbols
SetConsoleOutputCP(CP_UTF8);
#endif

std::cout << "Model Path: " << runConfig.modelPath << std::endl;
std::cout << "Sentence: " << runConfig.sentence << std::endl;
std::cout << "Output Path: " << runConfig.outputPath.value().string() << std::endl;
std::cout << "Use CUDA: " << runConfig.useCuda << std::endl;
// std::cout << "Model Path: " << runConfig.modelPath << std::endl;
// std::cout << "Sentence: " << runConfig.sentence << std::endl;
// std::cout << "Output Path: " << runConfig.outputPath.value().string() << std::endl;
// std::cout << "Use CUDA: " << runConfig.useCuda << std::endl;

if (modelPath != runConfig.modelPath.string())
{
auto startTime = chrono::steady_clock::now();
modelPath = runConfig.modelPath.string();
std::cout << "Loading voice from " << runConfig.modelPath.string() << " (config=" << runConfig.modelConfigPath.string() << ")" << std::endl;
// std::cout << "Loading voice from " << runConfig.modelPath.string() << " (config=" << runConfig.modelConfigPath.string() << ")" << std::endl;
piper::loadVoice(piperConfig, runConfig.modelPath.string(),
runConfig.modelConfigPath.string(), voice, runConfig.speakerId,
runConfig.useCuda);
auto endTime = chrono::steady_clock::now();
std::cout << "Loaded onnx model in " << std::chrono::duration<double>(endTime - startTime).count() << " second(s)" << std::endl;
}
else
{
std::cout << "Model already loaded" << std::endl;
// std::cout << "Loaded onnx model in " << std::chrono::duration<double>(endTime - startTime).count() << " second(s)" << std::endl;
}
// else
// {
// std::cout << "Model already loaded" << std::endl;
// }

// Get the path to the piper executable so we can locate espeak-ng-data, etc.
// next to it.
Expand Down Expand Up @@ -313,7 +313,8 @@ int main(int argc, char *argv[])
});

// Start the server on port 8080
std::cout << "Server is running on http://localhost:" << initConfig.port.value() << std::endl;
spdlog::info("Server is running on http://localhost:{}", initConfig.port.value());
// std::cout << "Server is running on http://localhost:" << initConfig.port.value() << std::endl;
server.listen("0.0.0.0", stoi(initConfig.port.value()));

return 0;
Expand Down Expand Up @@ -380,9 +381,9 @@ void parseArgsFromJson(const json &inputJson, RunConfig &runConfig)
std::cout << "Model path does not exist: " << runConfig.modelPath.string() << std::endl;
throw std::runtime_error("Model path does not exist: " + runConfig.modelPath.string());
}
else {
std::cout << "Model path exists: " << runConfig.modelPath.string() << std::endl;
}
// else {
// std::cout << "Model path exists: " << runConfig.modelPath.string() << std::endl;
// }

if (inputJson.contains("modelConfigPath"))
{
Expand All @@ -398,9 +399,9 @@ void parseArgsFromJson(const json &inputJson, RunConfig &runConfig)
std::cout << "Model config path does not exist: " << runConfig.modelConfigPath.string() << std::endl;
throw std::runtime_error("Model config path does not exist: " + runConfig.modelConfigPath.string());
}
else {
std::cout << "Model config path exists: " << runConfig.modelConfigPath.string() << std::endl;
}
// else {
// std::cout << "Model config path exists: " << runConfig.modelConfigPath.string() << std::endl;
// }

if (inputJson.contains("output_file"))
{
Expand Down Expand Up @@ -445,9 +446,9 @@ void parseArgsFromJson(const json &inputJson, RunConfig &runConfig)
std::cout << "Output path does not exist: " << runConfig.outputPath.value().string() << std::endl;
throw std::runtime_error("Output path does not exist: " + runConfig.outputPath.value().string());
}
else {
std::cout << "Output path exists: " << runConfig.outputPath.value().string() << std::endl;
}
// else {
// std::cout << "Output path exists: " << runConfig.outputPath.value().string() << std::endl;
// }



Expand Down

0 comments on commit 941df64

Please sign in to comment.