Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Force whisper to not transcribe punctuations (#1771)

Ozan Armağan002b188b5681
diff --git a/bazel/whisper.patch b/bazel/whisper.patch
index 78e6d669..93ed9add 100644
--- a/bazel/whisper.patch
+++ b/bazel/whisper.patch
@@ -220,7 +220,7 @@ index 64f4e45..85fb039 100644
GGML_API bool ggml_is_numa(void); // true if init detected that system has >1 NUMA node
diff --git a/whisper.cpp b/whisper.cpp
-index f6ba822..5279268 100644
+index f6ba822..485c013 100644
--- a/whisper.cpp
+++ b/whisper.cpp
@@ -10,6 +10,7 @@
@@ -245,3 +245,12 @@ index f6ba822..5279268 100644
backend_gpu = ggml_backend_cuda_init(0);
if (!backend_gpu) {
WHISPER_LOG_ERROR("%s: ggml_backend_cuda_init() failed\n", __func__);
+@@ -4483,7 +4488,7 @@ static const std::vector<std::string> non_speech_tokens = {
+ "\"", "#", "(", ")", "*", "+", "/", ":", ";", "<", "=", ">", "@", "[", "\\", "]", "^",
+ "_", "`", "{", "|", "}", "~", "「", "」", "『", "』", "<<", ">>", "<<<", ">>>", "--",
+ "---", "-(", "-[", "('", "(\"", "((", "))", "(((", ")))", "[[", "]]", "{{", "}}", "♪♪",
+- "♪♪♪","♩", "♪", "♫", "♬", "♭", "♮", "♯"
++ "♪♪♪","♩", "♪", "♫", "♬", "♭", "♮", "♯", "!", ".", ",", "?", "!", "¡", "¿", "‼", "⁉",
+ };
+
+ // process the logits for the selected decoder
diff --git a/src/aq_model.cpp b/src/aq_model.cpp
index 58798d58..0eb5c7b9 100644
--- a/src/aq_model.cpp
+++ b/src/aq_model.cpp
@@ -88,6 +88,7 @@ Option<std::string> WhisperModel::transcribe(const std::string& audio_base64) {
ss << whisper_full_get_segment_text(ctx, i);
}
- return Option<std::string>(ss.str());
+ std::string result = ss.str();
+ return Option<std::string>(StringUtils::trim(result));
}
diff --git a/test/collection_vector_search_test.cpp b/test/collection_vector_search_test.cpp
index 45a893be..cea2f0cb 100644
--- a/test/collection_vector_search_test.cpp
+++ b/test/collection_vector_search_test.cpp
@@ -4058,7 +4058,7 @@ TEST_F(CollectionVectorTest, TestVoiceQuery) {
ASSERT_TRUE(results.ok());
auto results_json = results.get();
- ASSERT_EQ(" Smartphone.", results_json["request_params"]["voice_query"]["transcribed_query"].get<std::string>());
+ ASSERT_EQ("Smartphone", results_json["request_params"]["voice_query"]["transcribed_query"].get<std::string>());
ASSERT_EQ(1, results_json["hits"].size());
ASSERT_EQ("1", results_json["hits"][0]["document"]["id"].get<std::string>());
}