Fix building (#1343)
This commit is contained in:
@@ -91,7 +91,7 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineModelConfig {
|
||||
/// if non-null, loading the tokens from the buffered string directly in
|
||||
/// prioriy
|
||||
const char *tokens_buf;
|
||||
/// byte size excluding the tailing '\0'
|
||||
/// byte size excluding the trailing '\0'
|
||||
int32_t tokens_buf_size;
|
||||
} SherpaOnnxOnlineModelConfig;
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "sherpa-onnx/csrc/offline-stream.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
@@ -245,7 +247,7 @@ class OfflineStream::Impl {
|
||||
for (int32_t i = 0; i != n; ++i) {
|
||||
float x = p[i];
|
||||
x = (x > amin) ? x : amin;
|
||||
x = std::log10f(x) * multiplier;
|
||||
x = log10f(x) * multiplier;
|
||||
|
||||
max_x = (x > max_x) ? x : max_x;
|
||||
p[i] = x;
|
||||
|
||||
@@ -372,7 +372,8 @@ class OnlineRecognizerTransducerImpl : public OnlineRecognizerImpl {
|
||||
// segment is incremented only when the last
|
||||
// result is not empty, contains non-blanks and longer than context_size)
|
||||
const auto &r = s->GetResult();
|
||||
if (!r.tokens.empty() && r.tokens.back() != 0 && r.tokens.size() > context_size) {
|
||||
if (!r.tokens.empty() && r.tokens.back() != 0 &&
|
||||
r.tokens.size() > context_size) {
|
||||
s->GetCurrentSegment() += 1;
|
||||
}
|
||||
}
|
||||
@@ -392,7 +393,8 @@ class OnlineRecognizerTransducerImpl : public OnlineRecognizerImpl {
|
||||
// if last result is not empty, then
|
||||
// preserve last tokens as the context for next result
|
||||
if (static_cast<int32_t>(last_result.tokens.size()) > context_size) {
|
||||
std::vector<int64_t> context(last_result.tokens.end() - context_size, last_result.tokens.end());
|
||||
std::vector<int64_t> context(last_result.tokens.end() - context_size,
|
||||
last_result.tokens.end());
|
||||
|
||||
Hypotheses context_hyp({{context, 0}});
|
||||
r.hyps = std::move(context_hyp);
|
||||
|
||||
@@ -145,6 +145,8 @@ type
|
||||
ModelType: AnsiString;
|
||||
ModelingUnit: AnsiString;
|
||||
BpeVocab: AnsiString;
|
||||
TokensBuf: AnsiString;
|
||||
TokensBufSize: Integer;
|
||||
function ToString: AnsiString;
|
||||
class operator Initialize({$IFDEF FPC}var{$ELSE}out{$ENDIF} Dest: TSherpaOnnxOnlineModelConfig);
|
||||
end;
|
||||
@@ -178,6 +180,8 @@ type
|
||||
RuleFsts: AnsiString;
|
||||
RuleFars: AnsiString;
|
||||
BlankPenalty: Single;
|
||||
HotwordsBuf: AnsiString;
|
||||
HotwordsBufSize: Integer;
|
||||
function ToString: AnsiString;
|
||||
class operator Initialize({$IFDEF FPC}var{$ELSE}out{$ENDIF} Dest: TSherpaOnnxOnlineRecognizerConfig);
|
||||
end;
|
||||
@@ -490,6 +494,8 @@ type
|
||||
ModelType: PAnsiChar;
|
||||
ModelingUnit: PAnsiChar;
|
||||
BpeVocab: PAnsiChar;
|
||||
TokensBuf: PAnsiChar;
|
||||
TokensBufSize: cint32;
|
||||
end;
|
||||
SherpaOnnxFeatureConfig = record
|
||||
SampleRate: cint32;
|
||||
@@ -514,6 +520,8 @@ type
|
||||
RuleFsts: PAnsiChar;
|
||||
RuleFars: PAnsiChar;
|
||||
BlankPenalty: cfloat;
|
||||
HotwordsBuf: PAnsiChar;
|
||||
HotwordsBufSize: cint32;
|
||||
end;
|
||||
|
||||
PSherpaOnnxOnlineRecognizerConfig = ^SherpaOnnxOnlineRecognizerConfig;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "sherpa-onnx/python/csrc/online-punctuation.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "sherpa-onnx/csrc/online-punctuation.h"
|
||||
|
||||
namespace sherpa_onnx {
|
||||
@@ -12,9 +14,11 @@ static void PybindOnlinePunctuationModelConfig(py::module *m) {
|
||||
using PyClass = OnlinePunctuationModelConfig;
|
||||
py::class_<PyClass>(*m, "OnlinePunctuationModelConfig")
|
||||
.def(py::init<>())
|
||||
.def(py::init<const std::string &, const std::string &, int32_t, bool, const std::string &>(),
|
||||
py::arg("cnn_bilstm"), py::arg("bpe_vocab"), py::arg("num_threads") = 1,
|
||||
py::arg("debug") = false, py::arg("provider") = "cpu")
|
||||
.def(py::init<const std::string &, const std::string &, int32_t, bool,
|
||||
const std::string &>(),
|
||||
py::arg("cnn_bilstm"), py::arg("bpe_vocab"),
|
||||
py::arg("num_threads") = 1, py::arg("debug") = false,
|
||||
py::arg("provider") = "cpu")
|
||||
.def_readwrite("cnn_bilstm", &PyClass::cnn_bilstm)
|
||||
.def_readwrite("bpe_vocab", &PyClass::bpe_vocab)
|
||||
.def_readwrite("num_threads", &PyClass::num_threads)
|
||||
@@ -30,7 +34,8 @@ static void PybindOnlinePunctuationConfig(py::module *m) {
|
||||
|
||||
py::class_<PyClass>(*m, "OnlinePunctuationConfig")
|
||||
.def(py::init<>())
|
||||
.def(py::init<const OnlinePunctuationModelConfig &>(), py::arg("model_config"))
|
||||
.def(py::init<const OnlinePunctuationModelConfig &>(),
|
||||
py::arg("model_config"))
|
||||
.def_readwrite("model_config", &PyClass::model)
|
||||
.def("validate", &PyClass::Validate)
|
||||
.def("__str__", &PyClass::ToString);
|
||||
@@ -43,8 +48,8 @@ void PybindOnlinePunctuation(py::module *m) {
|
||||
py::class_<PyClass>(*m, "OnlinePunctuation")
|
||||
.def(py::init<const OnlinePunctuationConfig &>(), py::arg("config"),
|
||||
py::call_guard<py::gil_scoped_release>())
|
||||
.def("add_punctuation_with_case", &PyClass::AddPunctuationWithCase, py::arg("text"),
|
||||
py::call_guard<py::gil_scoped_release>());
|
||||
.def("add_punctuation_with_case", &PyClass::AddPunctuationWithCase,
|
||||
py::arg("text"), py::call_guard<py::gil_scoped_release>());
|
||||
}
|
||||
|
||||
} // namespace sherpa_onnx
|
||||
|
||||
Reference in New Issue
Block a user