Whisper: improve model output
Change-Id: Ib14eacdae0241cd326e45396ee2f49b0bab367bc
diff --git a/lib/common.cpp b/lib/common.cpp
index fdd37ea..c9534b1 100644
--- a/lib/common.cpp
+++ b/lib/common.cpp
@@ -25,6 +25,8 @@
#include <stdexcept>
#endif // WIN32
+#include <cstring>
+
namespace string_utils {
#ifdef WIN32
@@ -92,6 +94,18 @@
ffmpegScapeStringInline(ret);
return ret;
}
+
+std::vector<std::string>
+getWords(const std::string& text, const std::string& splits)
+{
+ std::vector<std::string> words;
+ auto token = std::strtok (const_cast<char*>(text.c_str()), const_cast<char*>(splits.c_str()));
+ while (token != NULL) {
+ words.emplace_back(token);
+ token = std::strtok (NULL, const_cast<char*>(splits.c_str()));
+ }
+ return words;
+}
} // namespace string_utils
namespace file_utils {