Add Android demo for real-time ASR with non-streaming ASR models. (#2214)

This commit is contained in:
Fangjun Kuang
2025-05-14 19:10:44 +08:00
committed by GitHub
parent 116977b5d4
commit 2e9e0b4e9e
60 changed files with 1651 additions and 8 deletions

View File

@@ -707,4 +707,20 @@ bool EndsWith(const std::string &haystack, const std::string &needle) {
return std::equal(needle.rbegin(), needle.rend(), haystack.rbegin());
}
std::vector<std::string> SplitString(const std::string &s, int32_t chunk_size) {
std::vector<std::string> ans;
if (chunk_size < 1 || chunk_size > s.size()) {
ans.push_back(s);
} else {
int32_t n = static_cast<int32_t>(s.size());
int32_t i = 0;
while (i < n) {
int32_t end = std::min(i + chunk_size, n);
ans.push_back(s.substr(i, end - i));
i = end;
}
}
return ans;
}
} // namespace sherpa_onnx