summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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) {