PotPlayer播放器创建有声字幕以及实时字幕翻译

环境

  • Windows 11 家庭中文版
  • PotPlayer 241216

步骤

注意:本文中有多个视频截图,虽然是同一时间点,但每次修改了PotPlayer播放器配置后,实际上可能需要重启播放器。使用同一时间点只是为了方便比较。

准备

下载、安装PotPlayer的最新版本。测试播放功能,确认其工作正常:

在这里插入图片描述

注意:本例中,视频本身已经包含了中英文字幕(非单独的字幕文件)。不过没关系,我们忽略它,一会儿将会把生成的字幕置于视频的顶部,以示区别。

注意:PotPlayer 241211版本添加使用Whisper从语音生成字幕的功能,请检查一下PotPlayer版本,如果不够新,需要升级一下:

在这里插入图片描述

创建有声字幕

在PotPlayer上单击右键,选择“字幕” -> “创建有声字幕” -> “创建有声字幕…”:

在这里插入图片描述

在弹出的对话框里:

  • 转换引擎:选择“Whisper-Faster”,点击“下载”按钮,下载引擎。
  • 型号:选择“small”,其它选项还有tiny、medium、large等,模型越大越精确,但是计算成本也越高。注意右边的“下载”按钮是灰色的。
  • 勾选“播放开始时自动生成”。

在这里插入图片描述

最后,点击“开始”按钮:

在这里插入图片描述

由于本地还没有模型( C:\Users\Administrator\AppData\Roaming\PotPlayerMini64\Model\faster-whisper-small ),所以它会尝试从网络下载,但是由于众所周知的原因,连接不上Hugging Face Hub,最后会报错如下:

声音提取
开始转换
Model not found at: C:\Users\Administrator\AppData\Roaming\PotPlayerMini64\Model\faster-whisper-small
Attempting to download:
An error occured while synchronizing the model Systran/faster-whisper-small from the Hugging Face Hub:
(MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/Systran/faster-whisper-small/revision/main (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002821E8B4940>: Failed to establish a new connection: [WinError 10060] �������ӷ���һ��ʱ���û����ȷ�𸴻����ӵ�����û�з�Ӧ�����ӳ���ʧ�ܡ�'))"), '(Request ID: 6112a113-c800-410e-adf4-ce88f97914d0)')
Trying to load the model directly from the local cache, if it exists.
Traceback (most recent call last):
 File "urllib3\connection.py", line 203, in _new_conn
 File "urllib3\util\connection.py", line 85, in create_connection
 File "urllib3\util\connection.py", line 73, in create_connection
TimeoutError: [WinError 10060] �������ӷ���һ��ʱ���û����ȷ�𸴻����ӵ�����û�з�Ӧ�����ӳ���ʧ�ܡ�
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
 File "urllib3\connectionpool.py", line 790, in urlopen
 File "urllib3\connectionpool.py", line 491, in _make_request
 File "urllib3\connectionpool.py", line 467, in _make_request
 File "urllib3\connectionpool.py", line 1092, in _validate_conn
 File "urllib3\connection.py", line 611, in connect
 File "urllib3\connection.py", line 218, in _new_conn
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x000002821E8B4940>: Failed to establish a new connection: [WinError 10060] �������ӷ���һ��ʱ���û����ȷ�𸴻����ӵ�����û�з�Ӧ�����ӳ���ʧ�ܡ�
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
 File "requests\adapters.py", line 486, in send
 File "urllib3\connectionpool.py", line 844, in urlopen
 File "urllib3\util\retry.py", line 515, in increment
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/Systran/faster-whisper-small/revision/main (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002821E8B4940>: Failed to establish a new connection: [WinError 10060] �������ӷ���һ��ʱ���û����ȷ�𸴻����ӵ�����û�з�Ӧ�����ӳ���ʧ�ܡ�'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
 File "faster_whisper\utils.py", line 227, in download_model
 File "huggingface_hub\utils\_validators.py", line 118, in _inner_fn
 File "huggingface_hub\_snapshot_download.py", line 187, in snapshot_download
 File "huggingface_hub\utils\_validators.py", line 118, in _inner_fn
 File "huggingface_hub\hf_api.py", line 2112, in repo_info
 File "huggingface_hub\utils\_validators.py", line 118, in _inner_fn
 File "huggingface_hub\hf_api.py", line 1921, in model_info
 File "requests\sessions.py", line 600, in get
 File "requests\sessions.py", line 587, in request
 File "requests\sessions.py", line 701, in send
 File "huggingface_hub\utils\_http.py", line 63, in send
 File "requests\adapters.py", line 519, in send
requests.exceptions.ConnectionError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/Systran/faster-whisper-small/revision/main (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002821E8B4940>: Failed to establish a new connection: [WinError 10060] �������ӷ���һ��ʱ���û����ȷ�𸴻����ӵ�����û�з�Ӧ�����ӳ���ʧ�ܡ�'))"), '(Request ID: 6112a113-c800-410e-adf4-ce88f97914d0)')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
 File "D:\whisper-fast\__main__.py", line 1600, in <module>
 File "D:\whisper-fast\__main__.py", line 1254, in cli
 File "faster_whisper\utils.py", line 243, in download_model
 File "huggingface_hub\utils\_validators.py", line 118, in _inner_fn
 File "huggingface_hub\_snapshot_download.py", line 170, in snapshot_download
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\windows\\system32\\.cache\\hub\\models--Systran--faster-whisper-small\\refs\\main'
[35432] Failed to execute script '__main__' due to unhandled exception!
转换完成

解决办法是自己手工下载: https://huggingface.co/guillaumekln/faster-whisper-small

在这里插入图片描述
把下载的 faster-whisper-small 文件夹复制到前面报错信息里所提到的目录: C:\Users\Administrator\AppData\Roaming\PotPlayerMini64\Model\faster-whisper-small (需要自己创建 Model 目录)

在这里插入图片描述

再次尝试生成:

在这里插入图片描述

这次终于成功了。不过生成的字幕默认是在视频底部,而底部本来就有字幕,所以可把生成字幕的位置改为顶部:

在这里插入图片描述

OK,现在就可以看到生成的字幕了:

在这里插入图片描述

实时字幕翻译

本例中,视频里说的是英语,所以生成的字幕也是英文的。要想显示中文字幕,就需要把生成的英文字幕翻译成中文。

在PotPlayer上单击右键,选择“字幕” -> “实时字幕翻译”,勾选“总是使用”和“上面显示翻译”,可见,在原来的字幕上方显示出了翻译后的字幕,不过实际并没有翻译,两排字幕都是英文的:

在这里插入图片描述

点击“实时字幕翻译设置”,弹出对话框:

在这里插入图片描述

如图可见,可以用Bing、Google等引擎来翻译字幕。不过不管用哪种方式,貌似都需要设置API key。本例使用百度翻译引擎。

(注意:对话框里有一个“打开文件夹”按钮,该文件夹就是存放翻译引擎的位置。一会儿需要把下载的百度引擎文件复制到这里。)

首先要下载百度翻译引擎。打开github: https://github.com/fjqingyou/PotPlayer_Subtitle_Translate_Baidu

在这里插入图片描述

注:这个readme文件一定要看一下。

下载 SubtitleTranslate - baidu.asSubtitleTranslate - baidu.ico 两个文件,并复制到前面对话框中“打开文件夹”的位置(本例中为: C:\Program Files\DAUM\PotPlayer\Extension\Subtitle\Translate ):

在这里插入图片描述

重启PotPlayer,再次打开“实时字幕翻译”对话框,可见列表里出现了百度翻译。把翻译引擎选择为“百度翻译”:

在这里插入图片描述

最后,还需要在帐户设置里填写API key。

注:如果API key设置有问题,字幕会报错( error: 52003, error_msg=UNAUTHORIZED USER ):

在这里插入图片描述

获取API key的方法:打开百度翻译开放平台: http://api.fanyi.baidu.com/

点击“在线翻译” -> “通用文本翻译” -> “查看详情”按钮:

在这里插入图片描述

按照提示,注册成为百度翻译开发者。注意有“标准版”(每月5万字符)和“高级版”(每月100万字符)两个选项。既然都是免费的,当然选择“高级版”了。注册过程略,具体步骤可以参考文末的“参考”部分链接。

最后,在“总览”页面,就可以获取APP ID和密钥了:

在这里插入图片描述

点击“帐户设置”按钮,输入App ID和密钥:

在这里插入图片描述

最后,测试一下翻译引擎。删除测试框里的中文,只保留英文,然后点击“测试”按钮。

如果API key工作正常,弹出的对话框里会显示翻译后的中文:

在这里插入图片描述

如果API key有问题,则会报错如下:

在这里插入图片描述

确保API key工作正常。现在,中文翻译字幕就会显示出来了。

在这里插入图片描述

参考

  • https://www.bilibili.com/video/BV1V46VYPEGm/
  • https://www.bilibili.com/video/BV1MZ421W7G3/
  • https://huggingface.co/guillaumekln/faster-whisper-small
  • https://github.com/fjqingyou/PotPlayer_Subtitle_Translate_Baidu
  • http://api.fanyi.baidu.com/
  • https://github.com/SYSTRAN/faster-whisper
  • https://github.com/ycyy/faster-whisper-webui
### PotPlayer WebDAV 修改文件夹报错解决方案 在使用 PotPlayer 通过 WebDAV 进行文件管理时,可能会遇到无法修改文件夹或报错的问题。此类问题通常与权限设置、WebDAV 配置或网络环境相关[^1]。以下是可能的解决方法: #### 1. 检查 WebDAV 权限配置 确保 WebDAV 服务器端为客户端提供了足够的权限。例如,在 Caddy 中配置 WebDAV 功能时,需要明确指定允许的操作类型。以下是一个示例配置: ```caddyfile http://your-domain.com { root * /path/to/webdav/folder file_server dav { allow all } } ``` 上述代码中,`allow all` 表示允许所有操作(包括创建、删除和修改文件夹)。如果权限不足,可能会导致 PotPlayer 在尝试修改文件夹时失败[^1]。 #### 2. 确认路径正确性 确保 PotPlayer 连接的 WebDAV 路径是正确的,并且服务器端能够解析该路径。可以通过浏览器访问 WebDAV URL 测试连接是否正常。如果路径错误或不可达,PotPlayer 可能会返回错误信息。 #### 3. 检查防火墙与端口 WebDAV 服务通常运行在特定端口上(如 80 或 443)。确保服务器防火墙未阻止这些端口的访问。此外,如果使用了反向代理(如 Caddy),需要确认代理配置是否正确。例如: ```caddyfile http://your-domain.com { reverse_proxy * 127.0.0.1:8080 { header_up Host {host} header_up X-Real-IP {remote} } } ``` #### 4. 更新 PotPlayer 版本 某些版本的 PotPlayer 可能存在兼容性问题,建议升级到最新版本以获得更好的支持。此外,还可以尝试其他支持 WebDAV 的播放器进行对比测试,排除软件本身的问题。 #### 5. 日志排查 启用 Caddy 或 WebDAV 服务器的日志功能,记录客户端请求及错误信息。通过分析日志可以定位具体问题。例如,在 Caddy 中添加日志配置: ```caddyfile log { output file /path/to/logfile.log level DEBUG } ``` #### 6. 网络环境检查 如果 WebDAV 服务部署在局域网内,确保 PotPlayer 所在设备能够正常访问服务器地址。如果涉及公网访问,需确认域名解析和 NAT 穿透配置是否正确。 --- ### 示例代码:Caddy WebDAV 配置 以下是一个完整的 Caddy 配置示例,支持 WebDAV 功能并允许文件夹修改: ```caddyfile http://your-domain.com { encode gzip root * /path/to/webdav/folder file_server dav { allow all } log { output file /var/log/caddy-webdav.log level DEBUG } } ``` ---
评论 24
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值