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
27 lines
695 B
Go
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
|
|
}
|