Add Streaming zipformer (#50)
This commit is contained in:
30
sherpa-onnx/csrc/text-utils.cc
Normal file
30
sherpa-onnx/csrc/text-utils.cc
Normal file
@@ -0,0 +1,30 @@
|
||||
// sherpa-onnx/csrc/text-utils.cc
|
||||
//
|
||||
// Copyright 2009-2011 Saarland University; Microsoft Corporation
|
||||
// Copyright 2023 Xiaomi Corporation
|
||||
|
||||
#include "sherpa-onnx/csrc/text-utils.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// This file is copied/modified from
|
||||
// https://github.com/kaldi-asr/kaldi/blob/master/src/util/text-utils.cc
|
||||
|
||||
namespace sherpa_onnx {
|
||||
|
||||
void SplitStringToVector(const std::string &full, const char *delim,
|
||||
bool omit_empty_strings,
|
||||
std::vector<std::string> *out) {
|
||||
size_t start = 0, found = 0, end = full.size();
|
||||
out->clear();
|
||||
while (found != std::string::npos) {
|
||||
found = full.find_first_of(delim, start);
|
||||
// start != end condition is for when the delimiter is at the end
|
||||
if (!omit_empty_strings || (found != start && start != end))
|
||||
out->push_back(full.substr(start, found - start));
|
||||
start = found + 1;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sherpa_onnx
|
||||
Reference in New Issue
Block a user