go-whisper-api/api/garbage.go
admin b5c083e06f
Some checks failed
CodeQL / Analyze (go) (push) Successful in 6m28s
Docker Image / build-docker (push) Failing after 13m26s
Lint and Testing / lint (push) Successful in 11m17s
Lint and Testing / test (push) Successful in 11m17s
Lint and Testing / golangci (push) Successful in 2m40s
first commit
2026-06-04 18:10:52 +07:00

27 lines
695 B
Go

package api
import (
"go-whisper-api/garbage"
"go-whisper-api/whisper"
)
func applyGarbage(r whisper.TranscriptResult, patterns []string) whisper.TranscriptResult {
if len(patterns) == 0 {
return r
}
r.Text = garbage.FilterText(r.Text, patterns)
if len(r.Words) == 0 {
return r
}
gw := make([]garbage.Word, len(r.Words))
for i, w := range r.Words {
gw[i] = garbage.Word{Word: w.Word, Start: w.Start, Stop: w.Stop}
}
gw = garbage.FilterWords(gw, patterns)
r.Words = make([]whisper.Word, len(gw))
for i, w := range gw {
r.Words[i] = whisper.Word{Word: w.Word, Start: w.Start, Stop: w.Stop}
}
return r
}