Skip to content

Commit

Permalink
添加环境检测
Browse files Browse the repository at this point in the history
默认关闭中文字幕生成
  • Loading branch information
CuSO4Gem committed May 5, 2024
1 parent 0643666 commit 91f9638
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 11 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
- [工作流程](#工作流程)

# 依赖
(整合包用户可以忽略环境依赖)首先,你需要一张英伟达显卡,因为作者比较懒只做了cuda的兼容。
(整合包用户可以忽略环境依赖,直接运行run.bat即可。如果想直接运行exe,仅需安装ffmpeg并添加环境变量)
首先,你需要一张英伟达显卡,因为作者比较懒只做了cuda的兼容。
安装依赖需要:requirements.txt中的各种依赖,pythorch库,ffmpeg(可选)。本工程Python 3.9.19上验证。另外如果你想体验完整的工作流程,推荐下载一个字幕文件编辑器,尽管本程序用不到,但是在转换视频的工作中,你一定用得到,我使用Aegisub。

1、各种基本库安装
Expand Down
2 changes: 1 addition & 1 deletion example/1.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"TTS": "edge",
"TTS param": "",
"voice connect": true,
"audio zh transcribe": true,
"audio zh transcribe": false,
"audio zh transcribe model": "medium",
"video zh preview": true
}
2 changes: 1 addition & 1 deletion example/2.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"TTS": "edge",
"TTS param": "",
"voice connect": true,
"audio zh transcribe": true,
"audio zh transcribe": false,
"audio zh transcribe model": "medium",
"video zh preview": true
}
2 changes: 1 addition & 1 deletion example/paramDict.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"TTS": "edge",
"TTS param": "",
"voice connect": true,
"audio zh transcribe": true,
"audio zh transcribe": false,
"audio zh transcribe model": "medium",
"video zh preview": true
}
1 change: 1 addition & 0 deletions package.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyinstaller --onefile work_space.py
25 changes: 24 additions & 1 deletion work_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import math
import struct
import tkinter as tk
from tkinter import messagebox
from tkinter import filedialog

PROXY = "127.0.0.1:7890"
Expand Down Expand Up @@ -402,7 +403,6 @@ def srtToVoice(url, srtFileNameAndPath, outputDir):
print("Convert srt to voice successfully")
return True


def srtToVoiceEdge(srtFileNameAndPath, outputDir, charactor = "zh-CN-XiaoyiNeural"):
# create output directory if not exists
if not os.path.exists(outputDir):
Expand Down Expand Up @@ -548,8 +548,31 @@ def voiceConnect(sourceDir, outputAndPath):
combined.export(outputAndPath, format="wav")
return True

def envCheck():
# 检查环境变量中是否包含 ffmpeg
ffmpeg_path = os.environ.get('PATH', '').split(os.pathsep)
ffmpeg_found = any('ffmpeg' in path.lower() for path in ffmpeg_path)
waringMessage = ""

print(ffmpeg_found)
if not ffmpeg_found:
waringMessage += "未安装ffmpeg,请安装ffmpeg并将其所在目录添加到环境变量PATH中。\n"

if waringMessage:
root = tk.Tk()
root.deiconify() # 隐藏主窗口
messagebox.showwarning("环境依赖警告", waringMessage)

root.destroy() # 销毁主窗口
return False
return True


if __name__ == "__main__":

if not envCheck():
exit(-1)

print("Please input the path and name of the parameter file (json format): ")
root = tk.Tk()
root.deiconify() # 打开主窗口
Expand Down
13 changes: 7 additions & 6 deletions 打包检查.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# 打包检查
1. 打包文件名是否正确?
2. faster-whisper_models模型是否有?
3. models的模型是否有?
4. example中的示例配置文件是否内容正确?密钥是否清理干净?
5. Readme.md是否打包了最新的?
6. 运行程序是否正常?
7. 测试的中间文件是否清理干净了?
2. 有没有ffmpeg?
3. faster-whisper_models模型是否有?
4. models的模型是否有?
5. example中的示例配置文件是否内容正确?密钥是否清理干净?
6. Readme.md是否打包了最新的?
7. 运行程序是否正常?
8. 测试的中间文件是否清理干净了?

0 comments on commit 91f9638

Please sign in to comment.