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.

subtitle fix

wulien68eda3d9e9f8
diff --git a/internal/service/audio2subtitle.go b/internal/service/audio2subtitle.go
index 7c5ff702..74ca4e20 100644
--- a/internal/service/audio2subtitle.go
+++ b/internal/service/audio2subtitle.go
@@ -5,8 +5,6 @@ import (
"context"
"errors"
"fmt"
- "go.uber.org/zap"
- "golang.org/x/sync/errgroup"
"krillin-ai/config"
"krillin-ai/internal/storage"
"krillin-ai/internal/types"
@@ -17,6 +15,9 @@ import (
"path/filepath"
"strings"
"sync"
+
+ "go.uber.org/zap"
+ "golang.org/x/sync/errgroup"
)
func (s Service) audioToSubtitle(ctx context.Context, stepParam *types.SubtitleTaskStepParam) error {
@@ -656,8 +657,9 @@ func (s Service) generateTimestamps(taskId, basePath string, originLanguage type
}
i := 1
+ nextStart := true
for _, word := range sentenceWords {
- if i == 1 || i%(originLanguageWordOneLine+1) == 0 {
+ if nextStart {
startWord = word
if startWord.Start < endWord.End {
startWord.Start = endWord.End
@@ -669,6 +671,7 @@ func (s Service) generateTimestamps(taskId, basePath string, originLanguage type
endWord = startWord
originSentence += word.Text + " "
i++
+ nextStart = false
continue
}
@@ -688,6 +691,7 @@ func (s Service) generateTimestamps(taskId, basePath string, originLanguage type
OriginLanguageSentence: originSentence,
})
originSentence = ""
+ nextStart = true
}
i++
}