diff --git a/backend/go/whisper/gowhisper.go b/backend/go/whisper/gowhisper.go index bf7cb7a45..56d794f0f 100644 --- a/backend/go/whisper/gowhisper.go +++ b/backend/go/whisper/gowhisper.go @@ -139,7 +139,10 @@ func (w *Whisper) AudioTranscription(opts *pb.TranscriptRequest) (pb.TranscriptR // segment start/end conversion factor taken from https://github.com/ggml-org/whisper.cpp/blob/master/examples/cli/cli.cpp#L895 s := CppGetSegmentStart(i) * (10000000) t := CppGetSegmentEnd(i) * (10000000) - txt := strings.Clone(CppGetSegmentText(i)) + // whisper.cpp can emit bytes that aren't valid UTF-8 (e.g. a multibyte + // codepoint split across token boundaries); protobuf string fields + // reject those at marshal time. Scrub before the value escapes cgo. + txt := strings.ToValidUTF8(strings.Clone(CppGetSegmentText(i)), "�") tokens := make([]int32, CppNTokens(i)) if opts.Diarize && CppGetSegmentSpeakerTurnNext(i) {