Enha: remove special tokens from whisper resp

This commit is contained in:
Grail Finder
2025-05-18 15:28:34 +03:00
parent 441225ede8
commit 2e5755c28a

View File

@@ -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) {