Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

fix: timestamp incorrect when use fasterwhisper

沈浩cc6cfbcab660
diff --git a/pkg/fasterwhisper/transcription.go b/pkg/fasterwhisper/transcription.go
index 6e0288cf..b7640cf8 100644
--- a/pkg/fasterwhisper/transcription.go
+++ b/pkg/fasterwhisper/transcription.go
@@ -53,7 +53,7 @@ func (c *FastwhisperProcessor) Transcription(audioFile, language, workDir string
for _, word := range segment.Words {
transcripotionData.Words = append(transcripotionData.Words, types.Word{
Num: num,
- Text: strings.TrimSpace(word.Word),
+ Text: util.CleanPunction(strings.TrimSpace(word.Word)),
Start: word.Start,
End: word.End,
})
diff --git a/pkg/util/base.go b/pkg/util/base.go
index b69dcd34..45f1c294 100644
--- a/pkg/util/base.go
+++ b/pkg/util/base.go
@@ -13,6 +13,7 @@ import (
"regexp"
"strconv"
"strings"
+ "unicode"
)
var strWithUpperLowerNum = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789")
@@ -124,3 +125,9 @@ func ChangeFileExtension(path string, newExt string) string {
ext := filepath.Ext(path)
return path[:len(path)-len(ext)] + newExt
}
+
+func CleanPunction(word string) string {
+ return strings.TrimFunc(word, func(r rune) bool {
+ return unicode.IsPunct(r)
+ })
+}