Skip to content

Commit

Permalink
fix style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Sep 13, 2024
1 parent 67b3d63 commit c627a43
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion sherpa-onnx/c-api/c-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 4 additions & 2 deletions sherpa-onnx/csrc/online-recognizer-transducer-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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);
Expand Down
17 changes: 11 additions & 6 deletions sherpa-onnx/python/csrc/online-punctuation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "sherpa-onnx/python/csrc/online-punctuation.h"

#include <string>

#include "sherpa-onnx/csrc/online-punctuation.h"

namespace sherpa_onnx {
Expand All @@ -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)
Expand All @@ -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);
Expand All @@ -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

0 comments on commit c627a43

Please sign in to comment.