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: panic when audio has no words

沈浩75b75f6c1b15
diff --git a/internal/service/audio2subtitle.go b/internal/service/audio2subtitle.go
index 13785e4d..9d9bb160 100644
--- a/internal/service/audio2subtitle.go
+++ b/internal/service/audio2subtitle.go
@@ -628,6 +628,9 @@ func jumpFindMaxIncreasingSubArray(words []types.Word) (int, int, []types.Word)
func (s Service) generateTimestamps(taskId, basePath string, originLanguage types.StandardLanguageCode,
resultType types.SubtitleResultType, audioFile *types.SmallAudio, originLanguageWordOneLine int) error {
// 判断有没有文本
+ if len(audioFile.TranscriptionData.Words) == 0 {
+ return nil
+ }
srtNoTsFile, err := os.Open(audioFile.SrtNoTsFile)
if err != nil {
log.GetLogger().Error("audioToSubtitle generateTimestamps open SrtNoTsFile error", zap.String("taskId", taskId), zap.Error(err))