当前位置:网站首页>剪映+json解析将视频中的声音转换成文本
剪映+json解析将视频中的声音转换成文本
2022-07-06 14:29:00 【fangye945a】
前言
有时候我们想将一段视频中的音频转换成文本,最简单最笨的方法就是通过人耳去听,然后通过打字打出来。但这种方法无疑是十分费劲的。机智的小伙伴肯定都知道我们可以借助语音识别工具来做这件事,但是比较现实的一点就是,很多识别软件不是要收费,就是识别准确率比较低。那么我们有什么办法可以既不花钱又准确的将视频中的音频转换成文本呢?
解决方法
有剪辑经验的小伙伴一定知道,剪映这款软件的字幕识别功能,其背后有字节跳动的语音识别技术支撑,对普通话的识别准确率是杠杠的。但是有一点是,他识别的字幕是分段的,要将它们一条条复制出来组成完整的文本,其工作量也不少。
那么,下面介绍一个简单的办法:
具体操作步骤
- 1.下载windows版本的剪映
- 2.导入视频
- 3.识别字幕(导入视频后,点击文本->智能字幕->开始识别即可)

- 4.等待一段时间后(时间长短与视频文件大小有关),就会自动生成字幕了。
- 5.生成字幕后,关闭剪映,会自动保存为草稿。此时再打开剪映,右上角会出现草稿参数的方框,在方框中我们可以找到草稿保存的路径。

- 6.在windows资源管理器中打开保存位置,可以看到如下文件。

- 7.根据英文名称不难找出,draft_content.json 中就是我们草稿内容,刚刚生成的字幕文本也保存在这个json文件中。
- 8.既然是json文件,下一步自然就是json解析了,我们将字幕内容从这个文件中提取出来即可。
- 9.分析json文件,找出要解析的字段, 简化后的json结构如下:
{"materials":{"texts":[{"content":"<font id=\"\" path=\"D:/Program Files/JianyingPro/3.0.5.8542/Resources/Font/SystemFont/zh-hans.ttf\"><color=(1.000000, 1.000000, 1.000000, 1.000000)><size=5.000000>同学们好</size></color></font>"}]}}
而我们需要的字幕内容,被三个xml元素标签包裹。
- 10.我们先通过json解析获取到content字段的内容,然后通过字符串处理的方法剔除xml标签,获取最终文本字幕内容。
如下是我写的一个简单的python脚本,可以方便快捷的处理剪映这个包含字幕的json文件:
import json
if __name__ == '__main__':
with open("draft_content.json", "r", encoding='utf-8') as f:
json_str = f.read()
json_content = json.loads(json_str)
texts_data = json_content["materials"]["texts"]
for text_data in texts_data:
content = text_data["content"]
content = content[:-22]
result = content.split("><size=")[1].split(">")[1]
print(result)
- 11.直接将脚本与json文件放置在同一目录下,执行python脚本即可得到需要的字幕内容。

我们还可以通过重定向符号,直接将输出的内容生成文件
python3 parse_jianyin.py >> output.txt

边栏推荐
- HDR image reconstruction from a single exposure using deep CNN reading notes
- GPS from getting started to giving up (XX), antenna offset
- GPS从入门到放弃(十七) 、对流层延时
- A Mexican airliner bound for the United States was struck by lightning after taking off and then returned safely
- Crawler obtains real estate data
- Powerful domestic API management tool
- VIP case introduction and in-depth analysis of brokerage XX system node exceptions
- 【sciter】: 基于 sciter 封装通知栏组件
- Seata聚合 AT、TCC、SAGA 、 XA事务模式打造一站式的分布式事务解决方案
- Research and investment strategy report of China's VOCs catalyst industry (2022 Edition)
猜你喜欢

【sciter】: 基于 sciter 封装通知栏组件
![[Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation](/img/2b/15b3d831bba6aa772ad83f3ac91d23.png)
[Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation

墨西哥一架飞往美国的客机起飞后遭雷击 随后安全返航

微信红包封面小程序源码-后台独立版-带测评积分功能源码

GPS from entry to abandonment (XIV), ionospheric delay

【10点公开课】:视频质量评价基础与实践

Assembly and interface technology experiment 5-8259 interrupt experiment

LeetCode刷题(十一)——顺序刷题51至55

Chapter 4: talk about class loader again

重磅新闻 | Softing FG-200获得中国3C防爆认证 为客户现场测试提供安全保障
随机推荐
Management background --2 Classification list
Kohana 数据库
Force deduction question 500, keyboard line, JS implementation
[线性代数] 1.3 n阶行列式
MariaDb数据库管理系统的学习(一)安装示意图
Data storage (1)
Xiaoman network model & http1-http2 & browser cache
0 basic learning C language - digital tube
微信红包封面小程序源码-后台独立版-带测评积分功能源码
GPS from entry to abandonment (XIV), ionospheric delay
Chapter 3: detailed explanation of class loading process (class life cycle)
GPS du début à l'abandon (XIII), surveillance autonome de l'intégrité du récepteur (raim)
Unity3d minigame-unity-webgl-transform插件转换微信小游戏报错To use dlopen, you need to use Emscripten‘s...问题
Memorabilia of domestic database in June 2022 - ink Sky Wheel
China 1,4-cyclohexanedimethanol (CHDM) industry research and investment decision-making report (2022 Edition)
Lora sync word settings
中国VOCs催化剂行业研究与投资战略报告(2022版)
GPS从入门到放弃(十七) 、对流层延时
Barcodex (ActiveX print control) v5.3.0.80 free version
CCNA Cisco network EIGRP protocol