jianchang512 / pyvideotrans

Translate the video from one language to another and add dubbing. 将视频从一种语言翻译为另一种语言,并支持api调用
https://pyvideotrans.com
GNU General Public License v3.0
10.33k stars 1.15k forks source link

【功能请求】对已有字幕进行配音 增加仅导出json #77

Closed photkey closed 10 months ago

photkey commented 10 months ago

因为凭感觉指定的rate 经常是差强人意,要反复的改几次 从中来选择一个较好的值,所以想到这个功能,是不是可以把tts的rate设置的更好一些。

导入SRT:

1
00:05:00,400 --> 00:05:15,300
If you want to use the edge-tts command, you can simply run it with the following command:

2
00:05:16,400 --> 00:05:25,300
Note the above requires the installation of the mpv command line player.

导出JSON:

[
  {
    "id": "1",
    "text": "If you want to use the edge-tts command, you can simply run it with the following command:",
    "start_time": "00:05:00.400",
    "end_time": "00:05:15.300",
    "tts_duration": 3.200, // 默认TTS语速,朗读这段文本的实际时长
  },
  {
    "id": "2",
    "text": "Note the above requires the installation of the mpv command line player.",
    "start_time": "00:05:16.400",
    "end_time": "00:05:25.300",
    "tts_duration": 5.100
  }
]

当启用这个选项时,仅导出JSON即可,不需要把所有语音合成到一起。 可以通过这个JSON文件里面所有的tts_duration,来选择一个tts最合适的rate值,然后再次运行软件 指定tts为这个rate。

jianchang512 commented 10 months ago

可以增加一个json输出到目标文件夹

或者高级设置里有配音自动加速,可以选中试试

photkey commented 10 months ago

配音自动加速是会导致非常明显的忽慢忽快,我想不如设置一个比较快一点的语速,这样起码语速是一致的,听起来可能还会舒服一点。 因为 强制配音加速强制视频慢速 只能二选一,那我就用通过导出JSON计算出的这个rate+强制视频慢速,也相当于这两个功能都用到了吧。

通过JSON计算出一个比较合理的rate值,我想的是 计算出每一段字幕的rate,然后选出能覆盖80%-90%的那个rate值(做为下次运行时的rate参数值),剩下10%-20%的部分 就是通过强制视频慢速对齐时间。这个思路可行吗,有没有更好的办法?

q247574452 commented 10 months ago

现在好像会导出一个json文件 但是看不懂咋用,哈哈