autocut icon indicating copy to clipboard operation
autocut copied to clipboard

Roadmap

Open mli opened this issue 2 years ago • 23 comments

这是 TODO 列表。欢迎有兴趣的同学来报名贡献:

  • [ ] 加速whisper的CPU推理。目前whisper在CPU上推理性能堪忧。尝试优化代码实现、quantization,使用很快的后端(例如 onnx )
  • [ ] 允许在markdown里编辑字幕,包括将一句话分成两句,或者讲句话并成一句,然后转成 srt
  • [ ] 加入测试代码
  • [ ] 加 CI,测试windows,linux,macos下的运行
  • [ ] 生成 Final Cut Pro XML (.fcpxml) https://github.com/mli/autocut/issues/45

mli avatar Nov 11 '22 17:11 mli

先来占个坑,目前正在做

  • [ ] 基于streamlit实现gui

chenqianhe avatar Nov 12 '22 04:11 chenqianhe

  • [ ] 基于streamlit实现gui

这个不错。提几个需求:想要个video panel,audio panel 显示声音(很方便看到是不是停顿太多),一个可以编辑的字幕panel。光标换到某一行时能同步(2x速)播放视频和声音。能在audio panel移动来微调字幕的时间搓。多少有点像一个视频编辑器,但还是想以文本字幕为主panel。

mli avatar Nov 12 '22 05:11 mli

  • [ ] 基于streamlit实现gui

这个不错。提几个需求:想要个video panel,audio panel 显示声音(很方便看到是不是停顿太多),一个可以编辑的字幕panel。光标换到某一行时能同步(2x速)播放视频和声音。能在audio panel移动来微调字幕的时间搓。多少有点像一个视频编辑器,但还是想以文本字幕为主panel。

目前计划是先把字幕生成;字幕筛选,剪切视频做出来。后续再加编辑功能。video panel,audio panel都问题不大。现在主要是被ffmpeg卡住了,视频上传是直接拿到了bytes,我不想保存本地再用ffmpeg读取;想直接使用bytes,但是目前有点问题;我再开个issue看看有没有人能帮忙解决

chenqianhe avatar Nov 12 '22 05:11 chenqianhe

@chenqianhe @zcf0508 wenet同学提到这个产品,我没用过,但看上去挺不错。UI的设计可以考虑参考他们 https://www.descript.com/

mli avatar Nov 15 '22 05:11 mli

使用 Dynamic Quantization 加速测试

https://github.com/MiscellaneousStuff/openai-whisper-cpu/blob/main/script/custom_whisper.py

代码

https://github.com/zcf0508/autocut/commit/0de0b4db22777e062942cfd8024ecc909f1f8b87

self.quantized_model = torch.quantization.quantize_dynamic(
    self.whisper_model, {torch.nn.Linear}, dtype=torch.qint8
)

whisper.transcribe(
  self.quantized_model if self.args.device == 'cpu'
          else self.whisper_model,
  ...)

测试结果

测试使用 Intel i7-8700 @3.2GHz ,代码基于 https://github.com/mli/autocut/commit/69b6a3936762108ddd82ae15ee1e706fa8ab71cc 修改

whisper-model 参数使用默认 small

测试一

测试视频: 02:09 长度、4.91 M 的一个 mp4 文件

次数 whisper_model quantized_model
1 56.8s 59.2s
2 56.8s 58.2s
3 60s 59s
4 62s 59.2s
5 57.8s 58.2s

测试二

测试视频: 07:16 长度、15.2 M 的一个 mp4 文件

次数 whisper_model quantized_model
1 216s 213.3s
2 214.3s 216.5s
3 213.9s 213.5s
4 217.6s 217.2s
5 212.5s 214.5s

zcf0508 avatar Nov 16 '22 03:11 zcf0508

使用 Dynamic Quantization 加速测试

出乎意料的没有加速。感觉要么是CPU对int8支持不好,要么是加速库没有装好?

mli avatar Nov 16 '22 03:11 mli

https://github.com/chidiwilliams/stable-ts 这个库支持按字生成时间戳,可以参考一下

zcf0508 avatar Nov 17 '22 02:11 zcf0508

https://github.com/chidiwilliams/stable-ts 这个库支持按字生成时间戳,可以参考一下

按字生成确实不错,但是之后字合并成句子又麻烦了,也不能直接按字数合并。不过是个不错的库

chenqianhe avatar Nov 17 '22 07:11 chenqianhe

我领这个吧 加 CI,测试windows,linux,macos下的运行

目前完成

  • [x] linux -> ubuntu
  • [ ] windows
  • [ ] macos 目前有一个 test 跑不了

yihong0618 avatar Nov 17 '22 08:11 yihong0618

我领这个吧 加 CI,测试windows,linux,macos下的运行

目前完成

  • [x] linux -> ubuntu
  • [ ] windows
  • [ ] macos 目前有一个 test 跑不了

哪个test有问题呢?目前test是我这边写的

chenqianhe avatar Nov 17 '22 08:11 chenqianhe

我领这个吧 加 CI,测试windows,linux,macos下的运行 目前完成

  • [x] linux -> ubuntu
  • [ ] windows
  • [ ] macos 目前有一个 test 跑不了

哪个test有问题呢?目前test是我这边写的

我的test都是在mac上写的,应该不会跑不了;可以一起看下

chenqianhe avatar Nov 17 '22 08:11 chenqianhe

我领这个吧 加 CI,测试windows,linux,macos下的运行 目前完成

  • [x] linux -> ubuntu
  • [ ] windows
  • [ ] macos 目前有一个 test 跑不了

哪个test有问题呢?目前test是我这边写的

我的test都是在mac上写的,应该不会跑不了;可以一起看下

报这个错 环境 mac m1 16 promax python 3.10 https://github.com/mli/autocut/pull/42

yihong0618 avatar Nov 17 '22 09:11 yihong0618

我领这个吧 加 CI,测试windows,linux,macos下的运行 目前完成

  • [x] linux -> ubuntu
  • [ ] windows
  • [ ] macos 目前有一个 test 跑不了

哪个test有问题呢?目前test是我这边写的

我的test都是在mac上写的,应该不会跑不了;可以一起看下

报这个错 环境 mac m1 16 promax python 3.10 #42

应该是环境问题了;低版本py会有吗?我用的是M2 Air

chenqianhe avatar Nov 17 '22 09:11 chenqianhe

加 CI,测试windows,linux,macos下的运行 Done. check: https://github.com/mli/autocut/pull/48

yihong0618 avatar Nov 20 '22 15:11 yihong0618

加速whisper的CPU推理。目前whisper在CPU上推理性能堪忧。尝试优化代码实现、https://github.com/openai/whisper/discussions/454,使用很快的后端(例如 https://github.com/openai/whisper/discussions/134 )

我可以试试

yihong0618 avatar Nov 20 '22 15:11 yihong0618

@mli @yihong0618 FYI, check this C++ implementation whisper.cpp for CPU inference.

aaronzs avatar Nov 21 '22 09:11 aaronzs

@mli @yihong0618 FYI, check this C++ implementation whisper.cpp for CPU inference.

yes I noticed that, but there's no python binding for now, we need some hack

yihong0618 avatar Nov 21 '22 09:11 yihong0618

@mli @yihong0618 FYI, check this C++ implementation whisper.cpp for CPU inference.

tried, not good. cpu: Intel(R) Xeon(R) CPU E5-2640 v4 @ 2.40GHz

maltoze avatar Nov 22 '22 09:11 maltoze

多进程测试

测试环境

基于 https://github.com/mli/autocut/commit/ec82c7ae84d5e91df1233de8628e954d6d3d74a7 进行修改,使用 multiprocessing 进行加速。由于本机没有 GPU ,以下测试仅使用 CPU ,仅供参考。 测试使用 Intel i7-8700 @3.2GHz,测试视频长度 04:32 ,大小 7.28 MB 。vad 参数分段为 21,进程池大小使用 4。 相关 pr https://github.com/mli/autocut/pull/58

测试结果

默认 多进程
1 249.8s 198.9s
2 247.8s 185.7s
3 254.6s 208.3s
4 248.7s 173.5s
5 242.2s 202.5s

测试过程中观察 CPU 占用,默认情况下 CPU 利用率最高为96% ,12个逻辑核心只要2个核心为满负荷运行,而在多进程下 CPU 使用率为 100%,12个逻辑核心全部跑满。

疑惑

在 https://github.com/openai/whisper/discussions/432#discussioncomment-4011750 帖子中提到,whisper 已经使用了全部 CPU 核心,所以不确定在单个进程下没有完全占用 CPU 是不是有意为之。

zcf0508 avatar Nov 29 '22 09:11 zcf0508

CTranslate2实现了whisper加速推理,并且有python bindings。文档链接

BrightXiaoHan avatar Dec 01 '22 09:12 BrightXiaoHan

@BrightXiaoHan 谢谢,我学习一下

yihong0618 avatar Dec 01 '22 13:12 yihong0618

@chenqianhe @zcf0508 wenet同学提到这个产品,我没用过,但看上去挺不错。UI的设计可以考虑参考他们 https://www.descript.com/

说到descript这个产品,我试用了一下。我感觉除了它本身的一些feature外,还有一个比较好的点是:它在句子的识别和分割上,做得比较好。 因为不管是自己的识别的语音,还是类似Youtube那种自动生成的字幕,都是不带句子分割的。我调研过几款句子识别及分割的模型和工具,在没有标点和大小写的情况下,效果都不是很好。 我能想到的方式,一个是句法分析,另一个就是通过词之间的时间间隔来分割(看了一下代码,咱们的autocut好像也做过一些这方面的优化和处理)“伪句”。但descript,做得很好。

咱们autocut对这块儿有什么想法?会进一步优化吗?

yinheng-gh avatar Dec 08 '22 03:12 yinheng-gh

https://github.com/m-bain/whisperX

这个项目也还挺有意思的

zcf0508 avatar Dec 19 '22 13:12 zcf0508