Skip to content

Commit

Permalink
Merge branch 'fix' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
CuSO4Gem committed Jul 20, 2024
2 parents 18f9828 + 2403681 commit bacb21c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pyreadline3==3.4.1
PySocks==1.7.1
pysubs2==1.6.1
pytube==15.0.0
pytubefix==6.3.4
pywin32-ctypes==0.2.2
PyYAML==6.0.1
regex==2023.12.25
Expand Down
26 changes: 17 additions & 9 deletions work_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import os
import copy
import json
from pytube import YouTube
from pytube.cli import on_progress
from pytubefix import YouTube
from pytubefix.cli import on_progress
from faster_whisper import WhisperModel
import srt
import re
Expand All @@ -31,7 +31,7 @@
from tools.trans_llm import TranslatorClass
import tenacity
from tools.merge_subtitle import SubtitleMerger
from tools.merge_video_srt import add_subtitles_and_mix_audio
import subprocess

PROXY = "127.0.0.1:7890"
proxies = None
Expand Down Expand Up @@ -82,7 +82,7 @@ def load_param(path):
return paramDict

def download_youtube_video(video_id, fileNameAndPath):
from pytube import YouTube
from pytubefix import YouTube
YouTube(f'https://youtu.be/{video_id}', proxies=proxies).streams.first().download(filename=fileNameAndPath)

def transcribeAudioEn(path, modelName="base.en", language="en",srtFilePathAndName="VIDEO_FILENAME.srt"):
Expand Down Expand Up @@ -625,11 +625,19 @@ def voiceConnect(sourceDir, outputAndPath):

def envCheck():
# 检查环境变量中是否包含 ffmpeg
ffmpeg_path = os.environ.get('PATH', '').split(os.pathsep)
ffmpeg_found = any('ffmpeg' in path.lower() for path in ffmpeg_path)
# 尝试调用ffmpeg命令来检查其是否安装
try:
subprocess.run(["ffmpeg", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
ffmpeg_found = True
except subprocess.CalledProcessError:
# ffmpeg命令存在但执行出错(不太可能发生,除非ffmpeg损坏)
ffmpeg_found = False
except FileNotFoundError:
# ffmpeg命令不存在
ffmpeg_found = False

waringMessage = ""

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

Expand All @@ -640,8 +648,8 @@ def envCheck():

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

else:
return True

if __name__ == "__main__":

Expand Down

0 comments on commit bacb21c

Please sign in to comment.