summaryrefslogtreecommitdiff
path: root/extra/stt.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2025-05-18 15:28:34 +0300
committerGrail Finder <wohilas@gmail.com>2025-05-18 15:28:34 +0300
commit2e5755c28a86c525041cb952764425ad82411ec7 (patch)
tree4177f7f92cd53a4ac849e3673c109aad1b6df05e /extra/stt.go
parent441225ede8ef959058de4933e83870eb30a55ecf (diff)
Enha: remove special tokens from whisper resp
Diffstat (limited to 'extra/stt.go')
-rw-r--r--extra/stt.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/extra/stt.go b/extra/stt.go
index 3e6e032..950f7a9 100644
--- a/extra/stt.go
+++ b/extra/stt.go
@@ -9,11 +9,14 @@ import (
"log/slog"
"mime/multipart"
"net/http"
+ "regexp"
"strings"
"github.com/gordonklaus/portaudio"
)
+var specialRE = regexp.MustCompile(`\[.*?\]`)
+
type STT interface {
StartRecording() error
StopRecording() (string, error)
@@ -99,7 +102,9 @@ func (stt *WhisperSTT) StopRecording() (string, error) {
stt.logger.Error("fn: StopRecording", "error", err)
return "", err
}
- return strings.TrimRight(string(responseTextBytes), "\n"), nil
+ resptext := strings.TrimRight(string(responseTextBytes), "\n")
+ // in case there are special tokens like [_BEG_]
+ return specialRE.ReplaceAllString(resptext, ""), nil
}
func (stt *WhisperSTT) writeWavHeader(w io.Writer, dataSize int) {