前言:前几天看到一篇《用Python解决女朋友看电影没字幕的需求》,觉得很有意思。但是有道的识别没有做过,找了下其他的接口,发现讯飞的识别比较准确。就做了这个小程序。
讯飞接口:https://console.xfyun.cn/services/lfasr
申请api和SK。
免费时长:新用户可识别的视频时长能达到5个小时。用多少算多少。一个月的有效期。
下载调用示例demo:https://www.xfyun.cn/doc/asr/lfasr/API.html#%E8%B0%83%E7%94%A8%E7%A4%BA%E4%BE%8B
下载demo就可以直接利用其接口生产识别文件,不用自己去写识别程序了。
主要程序:
1、窗体文件
class PyWinDesign:
def __init__(self, 启动窗口):
self.启动窗口 = 启动窗口
self.appid=""
self.secret_key=""
self.video_path=""
self.finish_video_path=""
self.start_time=""
self.end_time=""
self.videoclip=""
self.out_video_path=""
self.srt_files_path=""
self.sum_video_path=""
self.启动窗口 = 启动窗口
self.启动窗口.title ('视频字幕识别和合成')
self.启动窗口.resizable (width=False, height=False)
screenwidth = self.启动窗口.winfo_screenwidth ()
screenheight = self.启动窗口.winfo_screenheight ()
size = '%dx%d+%d+%d' % (644, 400, (screenwidth - 644) / 2, (screenheight - 400) / 2)
self.启动窗口.geometry (size)
self.标签1_标题 = tk.StringVar ()
self.标签1_标题.set ('讯飞接口:')
self.标签1 = tk.Label (self.启动窗口, textvariable=self.标签1_标题, anchor=tk.W)
self.标签1.place (x=19, y=22, width=68, height=31)
self.标签2_标题 = tk.StringVar ()
self.标签2_标题.set ('Appid:')
self.标签2 = tk.Label (self.启动窗口, textvariable=self.标签2_标题)
self.标签2.place (x=20, y=71, width=64, height=28)
self.编辑框1_内容 = tk.StringVar ()
self.编辑框1_内容.set ('')
self.编辑框1 = ttk.Entry (self.启动窗口, textvariable=self.编辑框1_内容, justify=tk.LEFT)
self.编辑框1.place (x=98, y=71, width=141, height=32)
self.标签3_标题 = tk.StringVar ()
self.标签3_标题.set ('Secret_key:')
self.标签3 = tk.Label (self.启动窗口, textvariable=self.标签3_标题)
self.标签3.place (x=21, y=106, width=67, height=