This commit is contained in:
2026-07-28 13:35:02 +08:00
parent 472d1a6521
commit 211d810091
3 changed files with 17 additions and 18 deletions
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -53,10 +53,10 @@ func writeShotFields(b *strings.Builder, s Shot) {
fmt.Fprintf(b, "事件:%s\n", s.Event)
}
if s.Dialogue != "" {
fmt.Fprintf(b, "台词:%s\n", s.Dialogue)
fmt.Fprintf(b, "台词:%s(角色开口说)\n", s.Dialogue)
}
if s.Narration != "" {
fmt.Fprintf(b, "画外音:%s\n", s.Narration)
fmt.Fprintf(b, "画外音:%s(角色不开口,仅播放旁白配音)\n", s.Narration)
}
if s.AmbientSound != "" {
fmt.Fprintf(b, "环境音:%s\n", s.AmbientSound)
+15 -16
View File
@@ -247,9 +247,6 @@ func (s *episodeService) GenerateScript(ctx context.Context, dramaId int64, epis
fastCharPerSecond := g.Cfg().MustGet(ctx, "speech.fastCharPerSecond", 6).Int()
slowCharPerSecond := g.Cfg().MustGet(ctx, "speech.slowCharPerSecond", 3).Int()
// 在发送给AI前,截断超出朗读预算的剧情描述,避免AI生成时长不足的镜头
description = truncateDescriptionForDuration(description, int(d.EpisodeDuration), charPerSecond)
systemPrompt := PromptService.GetScriptGenerationPrompt(ctx)
userInput := s.buildScriptGenUserInput(ctx, d, episodeTitle, description, genCtx, refTemplate, videoModel)
@@ -750,24 +747,26 @@ func createPendingTasks(ctx context.Context, dramaId, epId int64, script string,
// ============ 直接为各分段创建生成任务(script 按模型配置的 API 请求体格式构建)============
segDurs := calcSegDurs(d.EpisodeDuration, modelCfg)
segStartTimes := make([]int, len(segDurs))
for i := 1; i < len(segDurs); i++ {
segStartTimes[i] = segStartTimes[i-1] + segDurs[i-1]
}
// 按镜头数量均分到各分段(避免时间窗口切分导致的空段或信息不全)
totalShots := len(allShots)
numSegs := len(segDurs)
base := totalShots / numSegs
extra := totalShots % numSegs
shotIdx := 0
for segIdx, segDur := range segDurs {
segEndTime := segStartTimes[segIdx] + segDur
var segShots []domain.Shot
for _, sh := range allShots {
shStart := parseMMSSToSeconds(sh.StartTime)
if shStart < segStartTimes[segIdx] || shStart >= segEndTime {
continue
}
segShots = append(segShots, sh)
count := base
if segIdx < extra {
count++
}
end := shotIdx + count
if end > totalShots {
end = totalShots
}
taskGroups = append(taskGroups, _taskGroup{
promptText: domain.ShotsToPromptText(segShots),
promptText: domain.ShotsToPromptText(allShots[shotIdx:end]),
dur: segDur,
})
shotIdx = end
}
} else {
// 纯文本脚本:按 calcSegDurs 拆段 + splitScriptForSegment 切分(保留原逻辑)