Browse Source

调整细节

Signed-off-by: allan716 <[email protected]>
allan716 3 years ago
parent
commit
63d9b7ac52

+ 1 - 0
.gitignore

@@ -58,3 +58,4 @@
 /internal/pkg/sub_timeline_fixer/*.html
 /**/CSF-SubFixCache
 /CSF-DebugThings
+/internal/pkg/sub_timeline_fixer/CSF-DebugThings

+ 12 - 0
.idea/runConfigurations/_template__of_Go_Test.xml

@@ -0,0 +1,12 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test">
+    <module name="ChineseSubFinder" />
+    <working_directory value="$PROJECT_DIR$" />
+    <kind value="PACKAGE" />
+    <package value="github.com/allanpk716/ChineseSubFinder" />
+    <directory value="$PROJECT_DIR$" />
+    <filePath value="$PROJECT_DIR$" />
+    <framework value="gotest" />
+    <method v="2" />
+  </configuration>
+</component>

+ 2 - 2
internal/logic/sub_supplier/shooter/shooter_test.go

@@ -7,11 +7,11 @@ import (
 
 func TestNewSupplier(t *testing.T) {
 	//movie1 := "X:\\电影\\The Devil All the Time (2020)\\The Devil All the Time (2020) WEBDL-1080p.mkv"
-	//movie1 := "X:\\电影\\龙猫 (1988)\\龙猫 (1988) 1080p DTS.mkv"
+	movie1 := "X:\\电影\\龙猫 (1988)\\龙猫 (1988) 1080p DTS.mkv"
 	//movie1 := "X:\\电影\\消失爱人 (2016)\\消失爱人 (2016) 720p AAC.rmvb"
 	//movie1 := "X:\\电影\\机动战士Z高达:星之继承者 (2005)\\机动战士Z高达:星之继承者 (2005) 1080p TrueHD.mkv"
 	//movie1 := "X:\\连续剧\\The Bad Batch\\Season 1\\The Bad Batch - S01E01 - Aftermath WEBDL-1080p.mkv"
-	movie1 := "X:\\电影\\An Invisible Sign (2010)\\An Invisible Sign (2010) 720p AAC.mp4"
+	//movie1 := "X:\\电影\\An Invisible Sign (2010)\\An Invisible Sign (2010) 720p AAC.mp4"
 	shooter := NewSupplier(types.ReqParam{Topic: 3})
 	outList, err := shooter.getSubListFromFile(movie1)
 	if err != nil {

+ 9 - 5
internal/pkg/sub_helper/sub_helper.go

@@ -530,20 +530,24 @@ func GetVADInfoFeatureFromSubNew(fileInfo *subparser.FileInfo, SkipFrontAndEndPe
 		if changerStartIndex < 0 {
 			continue
 		}
-		changerEndIndex := changeVADEndIndex - int(subStartTimeFloor10ms) - 1
+		changerEndIndex := changeVADEndIndex - int(subStartTimeFloor10ms)
 		if changerEndIndex < 0 {
 			continue
 		}
-		// TODO 还需要改,有问题
 		// 如果上一个对白的最后一个 OffsetIndex 连接着当前这一句的索引的 VAD 信息 active 是 true 就设置为 false
 		if lastDialogueIndex == changerStartIndex {
-			if lastDialogueIndex-1 >= 0 && subVADs[lastDialogueIndex-1].Active == true {
-				subVADs[lastDialogueIndex-1].Active = false
+			for i := 1; i <= 10; i++ {
+				if lastDialogueIndex-i >= 0 && subVADs[lastDialogueIndex-i].Active == true {
+					subVADs[lastDialogueIndex-i].Active = false
+				}
 			}
 		}
 		// 开始根据当前这句话进行 VAD 信息的设置
 		// 调整之前做好的整体 VAD 的信息,符合 VAD active = true
-		for i := changerStartIndex; i < changerEndIndex; i++ {
+		if changerEndIndex >= vadLen {
+			changerEndIndex = vadLen - 1
+		}
+		for i := changerStartIndex; i <= changerEndIndex; i++ {
 			subVADs[i].Active = true
 		}
 		lastDialogueIndex = changerEndIndex

+ 18 - 13
internal/pkg/sub_timeline_fixer/fixer_test.go

@@ -763,31 +763,36 @@ func TestGetOffsetTimeV2_BaseAudio(t *testing.T) {
 			}
 
 			println("-------New--------")
-			got, got1, sd, err := timelineFixer.GetOffsetTimeV2(nil, srcUnitNew, audioVADInfos)
+			bok, offsetTime, sd, err := timelineFixer.GetOffsetTimeV2(nil, srcUnitNew, audioVADInfos)
 			if (err != nil) != tt.wantErr {
 				t.Errorf("GetOffsetTimeV2() error = %v, wantErr %v", err, tt.wantErr)
 				return
 			}
 
-			debug_view.SaveDebugChartBase(audioVADInfos, tt.name+" audioVADInfos", "audioVADInfos")
-			debug_view.SaveDebugChart(*srcUnitNew, tt.name+" srcUnitNew", "srcUnitNew")
-			if got != tt.want {
-				t.Errorf("GetOffsetTimeV2() got = %v, want %v", got, tt.want)
+			//debug_view.SaveDebugChartBase(audioVADInfos, tt.name+" audioVADInfos", "audioVADInfos")
+			//debug_view.SaveDebugChart(*srcUnitNew, tt.name+" srcUnitNew", "srcUnitNew")
+			if bok != tt.want {
+				t.Errorf("GetOffsetTimeV2() bok = %v, want %v", bok, tt.want)
+			}
+
+			if sd > timelineFixer.FixerConfig.V2_MaxStartTimeDiffSD {
+
 			}
-			if got1 > -0.2 && got1 < 0.2 && tt.want1 == 0 {
+
+			if offsetTime > -0.2 && offsetTime < 0.2 && tt.want1 == 0 {
 				// 如果 offset time > -0.2 且 < 0.2 则认为无需调整时间轴,为0
-			} else if got1 > tt.want1-0.1 && got1 < tt.want1+0.1 {
+			} else if offsetTime > tt.want1-0.1 && offsetTime < tt.want1+0.1 {
 				// 在一个正负范围内都可以接受
 			} else {
-				t.Errorf("GetOffsetTimeV2() got = %v, want %v", got1, tt.want1)
+				t.Errorf("GetOffsetTimeV2() bok = %v, want %v", offsetTime, tt.want1)
 			}
 
-			_, err = timelineFixer.FixSubTimeline(infoSrc, got1, tt.args.subFilePath+FixMask+infoSrc.Ext)
-			if err != nil {
-				t.Fatal(err)
-			}
+			//_, err = timelineFixer.FixSubTimeline(infoSrc, offsetTime, tt.args.subFilePath+FixMask+infoSrc.Ext)
+			//if err != nil {
+			//	t.Fatal(err)
+			//}
 
-			println(fmt.Sprintf("GetOffsetTimeV2: %vs SD:%v", got1, sd))
+			println(fmt.Sprintf("GetOffsetTimeV2: %vs SD:%v", offsetTime, sd))
 		})
 	}
 }