Skip to content

Commit

Permalink
优化英文字幕文本分段处理
Browse files Browse the repository at this point in the history
  • Loading branch information
wxbool committed Dec 10, 2019
1 parent 8656644 commit 27b3061
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions app/aliyun/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func AliyunAudioResultWordHandle(result [] byte , callback func (vresult *Aliyun
for windex , w := range p {
if word.BeginTime >= w.BeginTime && word.EndTime <= w.EndTime {
flag := false
early := false
for t , B := range w.Blocks{
if (blockRune >= B) && B != -1 {
flag = true
Expand All @@ -127,11 +128,26 @@ func AliyunAudioResultWordHandle(result [] byte , callback func (vresult *Aliyun
if t == (len(w.Blocks) - 1) {
thisText = SubString(w.Text , lastBlock , 10000)
} else {
thisText = SubString(w.Text , lastBlock , (B - lastBlock))
//下个词提前结束
if i < len(value)-1 && value[i+1].BeginTime >= w.EndTime{
thisText = SubString(w.Text , lastBlock , 10000)
early = true
} else {
thisText = SubString(w.Text , lastBlock , (B - lastBlock))
}
}

lastBlock = B
w.Blocks[t] = -1
if early == true {
//全部设置为-1
for vt,vb := range w.Blocks{
if vb != -1 {
w.Blocks[vt] = -1;
}
}
} else {
w.Blocks[t] = -1
}

vresult := &AliyunAudioRecognitionResult{
Text:thisText,
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

//应用版本号
const APP_VERSION = "0.1.3"
const APP_VERSION = "0.1.5"

var AppRootDir string
var mw *MyMainWindow
Expand Down

0 comments on commit 27b3061

Please sign in to comment.