diff --git a/native_client/ctcdecode/ctc_beam_search_decoder.cpp b/native_client/ctcdecode/ctc_beam_search_decoder.cpp index af029b9d..179ec467 100644 --- a/native_client/ctcdecode/ctc_beam_search_decoder.cpp +++ b/native_client/ctcdecode/ctc_beam_search_decoder.cpp @@ -407,13 +407,12 @@ FlashlightDecoderState::intermediate(bool prune) valid_words.push_back(w); } } - FlashlightOutput ret { - .aggregate_score = result.score, - .acoustic_model_score = result.amScore, - .language_model_score = result.lmScore, - .words = lm_tokens_.mapIndicesToEntries(valid_words), // how does this interact with token-based decoding? - .tokens = result.tokens - }; + FlashlightOutput ret; + ret.aggregate_score = result.score; + ret.acoustic_model_score = result.amScore; + ret.language_model_score = result.lmScore; + ret.words = lm_tokens_.mapIndicesToEntries(valid_words); // how does this interact with token-based decoding + ret.tokens = result.tokens; if (prune) { decoder_impl_->prune(); } @@ -433,13 +432,13 @@ FlashlightDecoderState::decode(size_t num_results) valid_words.push_back(w); } } - ret.push_back({ - .aggregate_score = result.score, - .acoustic_model_score = result.amScore, - .language_model_score = result.lmScore, - .words = lm_tokens_.mapIndicesToEntries(valid_words), // how does this interact with token-based decoding? - .tokens = result.tokens - }); + FlashlightOutput out; + out.aggregate_score = result.score; + out.acoustic_model_score = result.amScore; + out.language_model_score = result.lmScore; + out.words = lm_tokens_.mapIndicesToEntries(valid_words); // how does this interact with token-based decoding + out.tokens = result.tokens; + ret.push_back(out); } decoder_impl_.reset(nullptr); return ret; diff --git a/native_client/ctcdecode/scorer.cpp b/native_client/ctcdecode/scorer.cpp index d5ca6cbc..34ad90fb 100644 --- a/native_client/ctcdecode/scorer.cpp +++ b/native_client/ctcdecode/scorer.cpp @@ -1,6 +1,7 @@ #ifdef _MSC_VER #include #include + #define NOMINMAX #include #define R_OK 4 /* Read permission. */ diff --git a/native_client/ctcdecode/third_party/flashlight/flashlight/lib/common/String.h b/native_client/ctcdecode/third_party/flashlight/flashlight/lib/common/String.h index 492c710a..9ce89949 100644 --- a/native_client/ctcdecode/third_party/flashlight/flashlight/lib/common/String.h +++ b/native_client/ctcdecode/third_party/flashlight/flashlight/lib/common/String.h @@ -8,6 +8,7 @@ #pragma once #include +#include #include #include #include diff --git a/native_client/ctcdecode/third_party/flashlight/flashlight/lib/common/System.cpp b/native_client/ctcdecode/third_party/flashlight/flashlight/lib/common/System.cpp index fd89ac58..1afd13ac 100644 --- a/native_client/ctcdecode/third_party/flashlight/flashlight/lib/common/System.cpp +++ b/native_client/ctcdecode/third_party/flashlight/flashlight/lib/common/System.cpp @@ -7,7 +7,6 @@ #include "flashlight/lib/common/System.h" -#include #include #include #include @@ -119,45 +118,6 @@ bool dirExists(const std::string& path) { } } -void dirCreate(const std::string& path) { - if (dirExists(path)) { - return; - } - mode_t nMode = 0755; - int nError = 0; -#ifdef _WIN32 - nError = _mkdir(path.c_str()); -#else - nError = mkdir(path.c_str(), nMode); -#endif - if (nError != 0) { - throw std::runtime_error( - std::string() + "Unable to create directory - " + path); - } -} - -void dirCreateRecursive(const std::string& path) { - if (dirExists(path)) { - return; - } - std::vector dirsOnPath = getDirsOnPath(path); - std::string pathFromStart; - if (path[0] == pathSeperator()[0]) { - pathFromStart = pathSeperator(); - } - for (std::string& dir : dirsOnPath) { - if (pathFromStart.empty()) { - pathFromStart = dir; - } else { - pathFromStart = pathsConcat(pathFromStart, dir); - } - - if (!dirExists(pathFromStart)) { - dirCreate(pathFromStart); - } - } -} - bool fileExists(const std::string& path) { std::ifstream fs(path, std::ifstream::in); return fs.good(); @@ -170,28 +130,6 @@ std::string getEnvVar( return val ? std::string(val) : dflt; } -std::string getCurrentDate() { - time_t now = time(nullptr); - struct tm tmbuf; - struct tm* tstruct; - tstruct = localtime_r(&now, &tmbuf); - - std::array buf; - strftime(buf.data(), buf.size(), "%Y-%m-%d", tstruct); - return std::string(buf.data()); -} - -std::string getCurrentTime() { - time_t now = time(nullptr); - struct tm tmbuf; - struct tm* tstruct; - tstruct = localtime_r(&now, &tmbuf); - - std::array buf; - strftime(buf.data(), buf.size(), "%X", tstruct); - return std::string(buf.data()); -} - std::string getTmpPath(const std::string& filename) { std::string tmpDir = "/tmp"; auto getTmpDir = [&tmpDir](const std::string& env) { @@ -217,17 +155,6 @@ std::vector getFileContent(const std::string& file) { return data; } -std::vector fileGlob(const std::string& pat) { - glob_t result; - glob(pat.c_str(), GLOB_TILDE, nullptr, &result); - std::vector ret; - for (unsigned int i = 0; i < result.gl_pathc; ++i) { - ret.push_back(std::string(result.gl_pathv[i])); - } - globfree(&result); - return ret; -} - std::ifstream createInputStream(const std::string& filename) { std::ifstream file(filename); if (!file.is_open()) { diff --git a/native_client/ctcdecode/third_party/flashlight/flashlight/lib/common/System.h b/native_client/ctcdecode/third_party/flashlight/flashlight/lib/common/System.h index c63ed1bb..761c9173 100644 --- a/native_client/ctcdecode/third_party/flashlight/flashlight/lib/common/System.h +++ b/native_client/ctcdecode/third_party/flashlight/flashlight/lib/common/System.h @@ -31,24 +31,14 @@ std::string basename(const std::string& path); bool dirExists(const std::string& path); -void dirCreate(const std::string& path); - -void dirCreateRecursive(const std::string& path); - bool fileExists(const std::string& path); std::string getEnvVar(const std::string& key, const std::string& dflt = ""); -std::string getCurrentDate(); - -std::string getCurrentTime(); - std::string getTmpPath(const std::string& filename); std::vector getFileContent(const std::string& file); -std::vector fileGlob(const std::string& pat); - std::ifstream createInputStream(const std::string& filename); std::ofstream createOutputStream( diff --git a/native_client/ctcdecode/third_party/flashlight/flashlight/lib/text/decoder/Trie.cpp b/native_client/ctcdecode/third_party/flashlight/flashlight/lib/text/decoder/Trie.cpp index df037e1b..2779a5b4 100644 --- a/native_client/ctcdecode/third_party/flashlight/flashlight/lib/text/decoder/Trie.cpp +++ b/native_client/ctcdecode/third_party/flashlight/flashlight/lib/text/decoder/Trie.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "flashlight/lib/text/decoder/Trie.h"