Fix Flashlight multiplatform build
This commit is contained in:
parent
391036643c
commit
a61180aeae
@ -407,13 +407,12 @@ FlashlightDecoderState::intermediate(bool prune)
|
|||||||
valid_words.push_back(w);
|
valid_words.push_back(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FlashlightOutput ret {
|
FlashlightOutput ret;
|
||||||
.aggregate_score = result.score,
|
ret.aggregate_score = result.score;
|
||||||
.acoustic_model_score = result.amScore,
|
ret.acoustic_model_score = result.amScore;
|
||||||
.language_model_score = result.lmScore,
|
ret.language_model_score = result.lmScore;
|
||||||
.words = lm_tokens_.mapIndicesToEntries(valid_words), // how does this interact with token-based decoding?
|
ret.words = lm_tokens_.mapIndicesToEntries(valid_words); // how does this interact with token-based decoding
|
||||||
.tokens = result.tokens
|
ret.tokens = result.tokens;
|
||||||
};
|
|
||||||
if (prune) {
|
if (prune) {
|
||||||
decoder_impl_->prune();
|
decoder_impl_->prune();
|
||||||
}
|
}
|
||||||
@ -433,13 +432,13 @@ FlashlightDecoderState::decode(size_t num_results)
|
|||||||
valid_words.push_back(w);
|
valid_words.push_back(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret.push_back({
|
FlashlightOutput out;
|
||||||
.aggregate_score = result.score,
|
out.aggregate_score = result.score;
|
||||||
.acoustic_model_score = result.amScore,
|
out.acoustic_model_score = result.amScore;
|
||||||
.language_model_score = result.lmScore,
|
out.language_model_score = result.lmScore;
|
||||||
.words = lm_tokens_.mapIndicesToEntries(valid_words), // how does this interact with token-based decoding?
|
out.words = lm_tokens_.mapIndicesToEntries(valid_words); // how does this interact with token-based decoding
|
||||||
.tokens = result.tokens
|
out.tokens = result.tokens;
|
||||||
});
|
ret.push_back(out);
|
||||||
}
|
}
|
||||||
decoder_impl_.reset(nullptr);
|
decoder_impl_.reset(nullptr);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
#define NOMINMAX
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#define R_OK 4 /* Read permission. */
|
#define R_OK 4 /* Read permission. */
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cerrno>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "flashlight/lib/common/System.h"
|
#include "flashlight/lib/common/System.h"
|
||||||
|
|
||||||
#include <glob.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <array>
|
#include <array>
|
||||||
@ -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<std::string> 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) {
|
bool fileExists(const std::string& path) {
|
||||||
std::ifstream fs(path, std::ifstream::in);
|
std::ifstream fs(path, std::ifstream::in);
|
||||||
return fs.good();
|
return fs.good();
|
||||||
@ -170,28 +130,6 @@ std::string getEnvVar(
|
|||||||
return val ? std::string(val) : dflt;
|
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<char, 80> 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<char, 80> buf;
|
|
||||||
strftime(buf.data(), buf.size(), "%X", tstruct);
|
|
||||||
return std::string(buf.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getTmpPath(const std::string& filename) {
|
std::string getTmpPath(const std::string& filename) {
|
||||||
std::string tmpDir = "/tmp";
|
std::string tmpDir = "/tmp";
|
||||||
auto getTmpDir = [&tmpDir](const std::string& env) {
|
auto getTmpDir = [&tmpDir](const std::string& env) {
|
||||||
@ -217,17 +155,6 @@ std::vector<std::string> getFileContent(const std::string& file) {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> fileGlob(const std::string& pat) {
|
|
||||||
glob_t result;
|
|
||||||
glob(pat.c_str(), GLOB_TILDE, nullptr, &result);
|
|
||||||
std::vector<std::string> 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 createInputStream(const std::string& filename) {
|
||||||
std::ifstream file(filename);
|
std::ifstream file(filename);
|
||||||
if (!file.is_open()) {
|
if (!file.is_open()) {
|
||||||
|
@ -31,24 +31,14 @@ std::string basename(const std::string& path);
|
|||||||
|
|
||||||
bool dirExists(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);
|
bool fileExists(const std::string& path);
|
||||||
|
|
||||||
std::string getEnvVar(const std::string& key, const std::string& dflt = "");
|
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::string getTmpPath(const std::string& filename);
|
||||||
|
|
||||||
std::vector<std::string> getFileContent(const std::string& file);
|
std::vector<std::string> getFileContent(const std::string& file);
|
||||||
|
|
||||||
std::vector<std::string> fileGlob(const std::string& pat);
|
|
||||||
|
|
||||||
std::ifstream createInputStream(const std::string& filename);
|
std::ifstream createInputStream(const std::string& filename);
|
||||||
|
|
||||||
std::ofstream createOutputStream(
|
std::ofstream createOutputStream(
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "flashlight/lib/text/decoder/Trie.h"
|
#include "flashlight/lib/text/decoder/Trie.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user