Skip to content

Commit

Permalink
发布 Videosrt-0.3.2 版本
Browse files Browse the repository at this point in the history
1.修复个别视频分段处理报错的bug
2.支持设定关闭软件智能分段的功能
3.美化软件界面,优化提示
  • Loading branch information
wxbool committed Sep 1, 2020
1 parent 08635dd commit 6ba2eff
Show file tree
Hide file tree
Showing 8 changed files with 240 additions and 97 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

这是一个可以识别视频语音自动生成字幕SRT文件的开源软件工具。<br />适用于快速、批量的为媒体(视频/音频)生成中/英文字幕、文本文件的业务场景。

0.3.1 版本将会使用以下接口:
0.3.2 版本将会使用以下接口:
- 阿里云 [OSS对象存储](https://www.aliyun.com/product/oss?spm=5176.12825654.eofdhaal5.13.e9392c4aGfj5vj&aly_as=K11FcpO8)
- 阿里云 [录音文件识别](https://ai.aliyun.com/nls/filetrans?spm=5176.12061031.1228726.1.47fe3cb43I34mn)
- 百度翻译开放平台 [翻译API](http://api.fanyi.baidu.com/api/trans/product/index)
Expand All @@ -14,8 +14,12 @@ CLI(命令行)版本:[https://github.com/wxbool/video-srt](https://github.

软件帮助文档/使用教程看这个:[https://www.yuque.com/viggo-t7cdi/videosrt](https://www.yuque.com/viggo-t7cdi/videosrt)

B站Up主自制教程:[https://search.bilibili.com/all?keyword=videosrt](https://search.bilibili.com/all?keyword=videosrt)

线上“字幕生成/字幕翻译”解决方案:[字幕酱(付费)](https://www.zimujiang.com/aff?code=aannv4os)

线上“文字配音/字幕配音/文章转视频”解决方案:[幕言](https://www.mu-yan.com/?videosrt)

<a name="0b884e4f"></a>
## 界面预览

Expand Down Expand Up @@ -46,8 +50,8 @@ CLI(命令行)版本:[https://github.com/wxbool/video-srt](https://github.

<a name="e66a66f1"></a>
##### 下载地址:
- (v0.3.1)(含ffmpeg依赖) [点我下载](http://file.viggo.site/video-srt/0.3.1/video-srt-gui-ffmpeg-0.3.1-x64.zip)
- (v0.3.1)(不含ffmpeg依赖) [点我下载](http://file.viggo.site/video-srt/0.3.1/video-srt-gui-0.3.1-x64.zip)
- (v0.3.2)(含ffmpeg依赖) [点我下载](http://file.viggo.site/video-srt/0.3.2/video-srt-gui-ffmpeg-0.3.2-x64.zip)
- (v0.3.2)(不含ffmpeg依赖) [点我下载](http://file.viggo.site/video-srt/0.3.2/video-srt-gui-0.3.2-x64.zip)
- (v0.2.6)(含ffmpeg依赖) [点我下载](http://file.viggo.site/video-srt/0.2.6/video-srt-gui-ffmpeg-0.2.6-x64.zip)
- (v0.2.6)(不含ffmpeg依赖) [点我下载](http://file.viggo.site/video-srt/0.2.6/video-srt-gui-0.2.6-x64.zip)

Expand Down
37 changes: 29 additions & 8 deletions app/aliyun/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,13 @@ func AliyunAudioResultWordHandle(result [] byte , callback func (vresult *Aliyun
}


var symbol = []string{"?","。",",","!",";","?",".",",","!"}
var symbol = []string{"?","。",",","!",";","、","?",".",",","!"}
//数据集处理
for _ , value := range audioResult {
for _ , data := range value {
// filter
data.Text = FilterText(data.Text)

data.Blocks = GetTextBlock(data.Text)
data.Text = ReplaceStrs(data.Text , symbol , "")

Expand Down Expand Up @@ -125,11 +128,20 @@ func AliyunAudioResultWordHandle(result [] byte , callback func (vresult *Aliyun
if ischinese {
block += word.Word
if tool.CheckChineseNumber(word.Word) && FindSliceIntCount(chineseNumberWordIndexs , i) == 0 {
cl := tool.ChineseNumberToLowercaseLength(word.Word)

if (cl - utf8.RuneCountInString(word.Word)) > 0 {
chineseNumberDiffLength += (cl - utf8.RuneCountInString(word.Word))
cl := tool.ChineseNumberToLowercaseLength(word.Word) - utf8.RuneCountInString(word.Word)
if cl > 0 {
chineseNumberDiffLength += cl
chineseNumberWordIndexs = append(chineseNumberWordIndexs , i)
} else {
//例外
if i != 0 {
newWord := value[i-1].Word + word.Word
cl := tool.ChineseNumberToLowercaseLength(newWord) - utf8.RuneCountInString(newWord)
if cl > 0 {
chineseNumberDiffLength += cl
chineseNumberWordIndexs = append(chineseNumberWordIndexs , i)
}
}
}
}
} else {
Expand Down Expand Up @@ -157,11 +169,11 @@ func AliyunAudioResultWordHandle(result [] byte , callback func (vresult *Aliyun
if ((blockRune >= B) || (blockRune + chineseNumberDiffLength >= B)) && B != -1 {
flag = true

//fmt.Println( w.Blocks )
//fmt.Println(w.Blocks)
//fmt.Println(B , lastBlock , (B - lastBlock) , word.Word)
//fmt.Println(w.Text)
//fmt.Println( block )
//fmt.Println("\n\n\n")
//fmt.Println("\n")

var thisText = ""
//容错机制
Expand Down Expand Up @@ -353,7 +365,7 @@ func IndexRunes(strs string , olds []rune) int {
}

func GetTextBlock(strs string) ([]int) {
var symbol_zhcn = []rune{'?','。',',','!',';','?','.',',','!'}
var symbol_zhcn = []rune{'?','。',',','!',';','、','?','.',',','!'}
//var symbol_en = []rune{'?','.',',','!'}
strsRune := []rune(strs)

Expand Down Expand Up @@ -390,3 +402,12 @@ func SubString(str string , begin int ,length int) (substr string) {
// 返回子串
return string(rs[begin:end])
}


//过滤文本
func FilterText(text string) string {
//去除换行符
re, _ := regexp.Compile("[\n|\r|\r\n]+")
text = re.ReplaceAllString(text, "")
return text
}
1 change: 1 addition & 0 deletions app/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ type AppSetings struct {
OutputLanguage int //输出字幕语言
OutputMainSubtitleInputLanguage bool //双语主字幕(输入语言)

CloseIntelligentBlockSwitch bool //关闭智能分段
CloseNewVersionMessage bool //关闭软件新版本提醒(默认开启)[false开启 true关闭]
CloseAutoDeleteOssTempFile bool //关闭自动删除临时音频文件(默认开启)[false开启 true关闭]
}
Expand Down
14 changes: 14 additions & 0 deletions app/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func(mw *MyMainWindow) RunAppSetingDialog(owner walk.Form , confirmCall func(*Ap
Dialog{
AssignTo: &dlg,
Title: "软件设置",
Font:Font{Family: "微软雅黑", PointSize: 9},
DefaultButton: &acceptPB,
CancelButton: &cancelPB,
DataBinder: DataBinder{
Expand Down Expand Up @@ -82,6 +83,12 @@ func(mw *MyMainWindow) RunAppSetingDialog(owner walk.Form , confirmCall func(*Ap
},


Label{
Text: "关闭软件智能分段处理:",
},
CheckBox{
Checked: Bind("CloseIntelligentBlockSwitch"),
},
Label{
Text: "关闭OSS临时文件清理:",
},
Expand Down Expand Up @@ -153,6 +160,7 @@ func(mw *MyMainWindow) RunSpeechEngineSetingDialog(owner walk.Form , confirmCall
Dialog{
AssignTo: &dlg,
Title: "新建语音引擎",
Font:Font{Family: "微软雅黑", PointSize: 9},
DefaultButton: &acceptPB,
CancelButton: &cancelPB,
DataBinder: DataBinder{
Expand Down Expand Up @@ -295,6 +303,7 @@ func(mw *MyMainWindow) RunBaiduTranslateEngineSetingDialog(owner walk.Form , con
Dialog{
AssignTo: &dlg,
Title: "新建翻译引擎(百度翻译)",
Font:Font{Family: "微软雅黑", PointSize: 9},
DefaultButton: &acceptPB,
CancelButton: &cancelPB,
DataBinder: DataBinder{
Expand Down Expand Up @@ -424,6 +433,7 @@ func(mw *MyMainWindow) RunTengxunyunTranslateEngineSetingDialog(owner walk.Form
Dialog{
AssignTo: &dlg,
Title: "新建翻译引擎(腾讯云)",
Font:Font{Family: "微软雅黑", PointSize: 9},
DefaultButton: &acceptPB,
CancelButton: &cancelPB,
DataBinder: DataBinder{
Expand Down Expand Up @@ -543,6 +553,7 @@ func (mw *MyMainWindow) RunObjectStorageSetingDialog(owner walk.Form) {
Dialog{
AssignTo: &dlg,
Title: "OSS对象存储设置",
Font:Font{Family: "微软雅黑", PointSize: 9},
DefaultButton: &acceptPB,
CancelButton: &cancelPB,
DataBinder: DataBinder{
Expand Down Expand Up @@ -670,6 +681,7 @@ func (mw *MyMainWindow) RunGlobalFilterSetingDialog (owner walk.Form , historyWo
Dialog{
AssignTo: &dlg,
Title: "全局语气词过滤设置",
Font:Font{Family: "微软雅黑", PointSize: 9},
DefaultButton: &acceptPB,
CancelButton: &cancelPB,
DataBinder: DataBinder{
Expand Down Expand Up @@ -837,6 +849,7 @@ func (mw *MyMainWindow) RunDefinedFilterSetingDialog (owner walk.Form , historyR
Dialog{
AssignTo: &dlg,
Title: "自定义过滤设置",
Font:Font{Family: "微软雅黑", PointSize: 9},
DefaultButton: &acceptPB,
CancelButton: &cancelPB,
MinSize: Size{600, 500},
Expand Down Expand Up @@ -955,6 +968,7 @@ func (mw *MyMainWindow) RunNewDefinedFilterRuleDialog (owner walk.Form , copyRow
Dialog{
AssignTo: &dlg,
Title: "新增自定义过滤规则",
Font:Font{Family: "微软雅黑", PointSize: 9},
DefaultButton: &acceptPB,
CancelButton: &cancelPB,
DataBinder: DataBinder{
Expand Down
36 changes: 20 additions & 16 deletions app/tool/chinese_simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,29 @@ func ChineseNumberToLowercaseLength(s string) int {
numberPosi := true
maxBaseNumber := 1

for i:=0; i<zhTextsLens; i++ {
if numberPosi == false {
switch zhTexts[i] {
case "十":
maxBaseNumber = 2
break
case "百":
maxBaseNumber = 3
break
case "千":
maxBaseNumber = 4
break
case "万":
maxBaseNumber = 5
if s == "十" {
maxBaseNumber = 2
} else {
for i:=0; i<zhTextsLens; i++ {
if numberPosi == false {
switch zhTexts[i] {
case "十":
maxBaseNumber = 2
break
case "百":
maxBaseNumber = 3
break
case "千":
maxBaseNumber = 4
break
case "万":
maxBaseNumber = 5
break
}
break
}
break
numberPosi = !numberPosi
}
numberPosi = !numberPosi
}
return maxBaseNumber+cha_t
}
Expand Down
Loading

0 comments on commit 6ba2eff

Please sign in to comment.