Fixed bad config when creating language model from dialog
This commit is contained in:
parent
ea3e88fd62
commit
9cfe577612
|
@ -172,12 +172,12 @@ void createLanguageModelFile(const vector<string>& words, path filePath) {
|
|||
file << "\\end\\" << endl;
|
||||
}
|
||||
|
||||
lambda_unique_ptr<ngram_model_t> createLanguageModel(const vector<string>& words, logmath_t& logMath) {
|
||||
lambda_unique_ptr<ngram_model_t> createLanguageModel(const vector<string>& words, ps_decoder_t& decoder) {
|
||||
path tempFilePath = getTempFilePath();
|
||||
createLanguageModelFile(words, tempFilePath);
|
||||
auto deleteTempFile = gsl::finally([&]() { boost::filesystem::remove(tempFilePath); });
|
||||
|
||||
return lambda_unique_ptr<ngram_model_t>(
|
||||
ngram_model_read(nullptr, tempFilePath.string().c_str(), NGRAM_ARPA, &logMath),
|
||||
ngram_model_read(decoder.config, tempFilePath.string().c_str(), NGRAM_ARPA, decoder.lmath),
|
||||
[](ngram_model_t* lm) { ngram_model_free(lm); });
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#pragma once
|
||||
#include <sphinxbase/ngram_model.h>
|
||||
#include <vector>
|
||||
#include "tools.h"
|
||||
|
||||
lambda_unique_ptr<ngram_model_t> createLanguageModel(const std::vector<std::string>& words, logmath_t& logMath);
|
||||
extern "C" {
|
||||
#include <pocketsphinx.h>
|
||||
#include <ngram_search.h>
|
||||
}
|
||||
|
||||
lambda_unique_ptr<ngram_model_t> createLanguageModel(const std::vector<std::string>& words, ps_decoder_t& decoder);
|
||||
|
|
|
@ -267,7 +267,7 @@ lambda_unique_ptr<ps_decoder_t> createDecoder(optional<u32string> dialog) {
|
|||
vector<string> words = tokenizeText(*dialog, [&](const string& word) { return dictionaryContains(*decoder->dict, word); });
|
||||
words.insert(words.begin(), "<s>");
|
||||
words.push_back("</s>");
|
||||
languageModel = createLanguageModel(words, *decoder->lmath);
|
||||
languageModel = createLanguageModel(words, *decoder);
|
||||
|
||||
// Add any dialog-specific words to the dictionary
|
||||
addMissingDictionaryWords(words, *decoder);
|
||||
|
|
Loading…
Reference in New Issue