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.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
add origin language subtitle one line max word param
wuliencb1e74abdd03
diff --git a/internal/dto/subtitle_task.go b/internal/dto/subtitle_task.goindex abf5ee87..96daae8e 100644--- a/internal/dto/subtitle_task.go+++ b/internal/dto/subtitle_task.go@@ -1,18 +1,19 @@package dtotype StartVideoSubtitleTaskReq struct {- AppId uint32 `json:"app_id"`- Url string `json:"url"`- OriginLanguage string `json:"origin_lang"`- TargetLang string `json:"target_lang"`- Bilingual uint8 `json:"bilingual"`- TranslationSubtitlePos uint8 `json:"translation_subtitle_pos"`- ModalFilter uint8 `json:"modal_filter"`- Tts uint8 `json:"tts"`- TtsVoiceCode uint8 `json:"tts_voice_code"`- TtsVoiceCloneSrcFileUrl string `json:"tts_voice_clone_src_file_url"`- Replace []string `json:"replace"`- Language string `json:"language"`+ AppId uint32 `json:"app_id"`+ Url string `json:"url"`+ OriginLanguage string `json:"origin_lang"`+ TargetLang string `json:"target_lang"`+ Bilingual uint8 `json:"bilingual"`+ TranslationSubtitlePos uint8 `json:"translation_subtitle_pos"`+ ModalFilter uint8 `json:"modal_filter"`+ Tts uint8 `json:"tts"`+ TtsVoiceCode uint8 `json:"tts_voice_code"`+ TtsVoiceCloneSrcFileUrl string `json:"tts_voice_clone_src_file_url"`+ Replace []string `json:"replace"`+ Language string `json:"language"`+ OriginLanguageWordOneLine int `json:"origin_language_word_one_line"`}type StartVideoSubtitleTaskResData struct {diff --git a/internal/service/subtitle_service.go b/internal/service/subtitle_service.goindex 5f67ef20..29efdeb5 100644--- a/internal/service/subtitle_service.go+++ b/internal/service/subtitle_service.go@@ -111,18 +111,19 @@ func (s Service) StartSubtitleTask(req dto.StartVideoSubtitleTaskReq) (*dto.Star}stepParam := types.SubtitleTaskStepParam{- TaskId: taskId,- TaskBasePath: taskBasePath,- Link: req.Url,- SubtitleResultType: resultType,- EnableModalFilter: req.ModalFilter == types.SubtitleTaskModalFilterYes,- EnableTts: req.Tts == types.SubtitleTaskTtsYes,- TtsVoiceCode: ttsVoiceCode,- VoiceCloneAudioUrl: voiceCloneAudioUrl,- ReplaceWordsMap: replaceWordsMap,- OriginLanguage: types.StandardLanguageName(req.OriginLanguage),- TargetLanguage: types.StandardLanguageName(req.TargetLang),- UserUILanguage: types.StandardLanguageName(req.Language),+ TaskId: taskId,+ TaskBasePath: taskBasePath,+ Link: req.Url,+ SubtitleResultType: resultType,+ EnableModalFilter: req.ModalFilter == types.SubtitleTaskModalFilterYes,+ EnableTts: req.Tts == types.SubtitleTaskTtsYes,+ TtsVoiceCode: ttsVoiceCode,+ VoiceCloneAudioUrl: voiceCloneAudioUrl,+ ReplaceWordsMap: replaceWordsMap,+ OriginLanguage: types.StandardLanguageName(req.OriginLanguage),+ TargetLanguage: types.StandardLanguageName(req.TargetLang),+ UserUILanguage: types.StandardLanguageName(req.Language),+ OriginLanguageWordOneLine: req.OriginLanguageWordOneLine,}go func() {defer func() {@@ -498,7 +499,7 @@ func (s Service) audioToSrt(ctx context.Context, stepParam *types.SubtitleTaskStstorage.SubtitleTasks[stepParam.TaskId].ProcessPct = processPct// 生成时间戳- err = s.generateTimestamps(stepParam.TaskId, stepParam.TaskBasePath, stepParam.OriginLanguage, stepParam.SubtitleResultType, audioFile)+ err = s.generateTimestamps(stepParam.TaskId, stepParam.TaskBasePath, stepParam.OriginLanguage, stepParam.SubtitleResultType, audioFile, stepParam.OriginLanguageWordOneLine)if err != nil {log.GetLogger().Error("audioToSubtitle.audioToSrt.generateTimestamps err", zap.Any("stepParam", stepParam), zap.Error(err))return err@@ -927,7 +928,8 @@ func jumpFindMaxIncreasingSubArray(words []types.Word) (int, int) {return startIdx, endIdx}-func (s Service) generateTimestamps(taskId, basePath string, originLanguage types.StandardLanguageName, resultType types.SubtitleResultType, audioFile *types.SmallAudio) error {+func (s Service) generateTimestamps(taskId, basePath string, originLanguage types.StandardLanguageName,+ resultType types.SubtitleResultType, audioFile *types.SmallAudio, originLanguageWordOneLine int) error {// 获取原始无时间戳字幕内容srtBlocks, err := util.ParseSrtNoTsToSrtBlock(audioFile.SrtNoTsFile)if err != nil {@@ -955,7 +957,7 @@ func (s Service) generateTimestamps(taskId, basePath string, originLanguage typeoriginSentence stringstartWord types.WordendWord types.Word- shortSentenceWordNum int = 12 //控制单行英文的字数+ shortSentenceWordNum int = originLanguageWordOneLine //控制单行英文的字数)if len(sentenceWords) <= shortSentenceWordNum {diff --git a/internal/types/subtitle_task.go b/internal/types/subtitle_task.goindex 241d0de7..ce40ce1d 100644--- a/internal/types/subtitle_task.go+++ b/internal/types/subtitle_task.go@@ -234,6 +234,7 @@ type SubtitleTaskStepParam struct {SubtitleInfos []SubtitleFileInfoTtsSourceFilePath stringTtsResultFilePath string+ OriginLanguageWordOneLine int // 源语言字幕一行显示多少个字}type SrtSentence struct {