Skip to content

Commit

Permalink
fix: bugs and update
Browse files Browse the repository at this point in the history
  • Loading branch information
jianchang512 committed Apr 25, 2024
1 parent c4d9021 commit 4d87c42
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 127 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
>
> 允许保留背景伴奏音乐等(基于uvr5)
>
> 支持的语言:中文简繁、英语、韩语、日语、俄语、法语、德语、意大利语、西班牙语、葡萄牙语、越南语、泰国语、阿拉伯语、土耳其语、匈牙利语、印度语
> 支持的语言:中文简繁、英语、韩语、日语、俄语、法语、德语、意大利语、西班牙语、葡萄牙语、越南语、泰国语、阿拉伯语、土耳其语、匈牙利语、印度语、乌克兰语、哈萨克语、印尼语、马来语


Expand All @@ -33,8 +33,6 @@

【音频、视频格式转换】各种格式之间的相互转换

【人声背景乐分离】将视频中的人声和背景音乐分别分离出来,生成2个音频文件

【下载油管视频】可从youtube上下载视频

----
Expand All @@ -50,12 +48,11 @@ https://github.com/jianchang512/pyvideotrans/assets/3378335/3811217a-26c8-4084-b

1. 解压到英文路径下,并且路径中不含有空格。解压后双击 sp.exe (若遇到权限问题可右键使用管理员权限打开)

3. 未做免杀,杀软可能误报,可忽略或使用源码部署
3. 使用pyinstaller打包,未做免杀和数字签名,杀软可能报毒,请加入信任名单或使用源码部署

4. 注意:必须解压后使用,不可直接压缩包内双击使用,也不可解压后移动sp.exe文件到其他位置



# 源码部署/MacOS Linux系统可源码部署

1. 安装好 python 3.10 环境,安装好 git
Expand Down
4 changes: 2 additions & 2 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.55",
"version_num": 11055
"version": "1.58",
"version_num": 11058
}
4 changes: 2 additions & 2 deletions videotrans/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-

VERSION="v1.57"
VERSION_NUM=11057
VERSION="v1.58"
VERSION_NUM=11058
6 changes: 5 additions & 1 deletion videotrans/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@
"ar":"Arabic",
"tr":"Turkish",
"hi":"Hindi",
"hu": "Hungarian"
"hu": "Hungarian",
"uk": "Ukrainian",
"id": "Indonesian",
"ms": "Malay",
"kk": "Kazakh"
}
}
6 changes: 5 additions & 1 deletion videotrans/language/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@
"ar" : "Árabe ",
"tr" : "Turquía ",
"hi" : "Hindi",
"hu": "Hungarian"
"hu": "Hungarian",
"uk": "Ukrainian",
"id": "Indonesian",
"ms": "Malay",
"kk": "Kazakh"
}
}
6 changes: 5 additions & 1 deletion videotrans/language/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@
"ar":"阿拉伯语",
"tr":"土耳其语",
"hi":"印度语",
"hu": "匈牙利语"
"hu": "匈牙利语",
"uk": "乌克兰语",
"id": "印度尼西亚",
"ms": "马来语",
"kk": "哈萨克语"
}
}
3 changes: 2 additions & 1 deletion videotrans/mainwin/secwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1305,8 +1305,9 @@ def update_data(self, json_data):
elif d['type'] == 'show_djs':
self.set_process_btn_text(d['text'], d['btnkey'])
elif d['type'] == 'check_soft_update':
print(d)
if not self.usetype:
self.usetype = QPushButton("")
self.usetype = QPushButton()
self.usetype.setStyleSheet('color:#ffff00;border:0')
self.usetype.setCursor(QtCore.Qt.PointingHandCursor)
self.usetype.clicked.connect(lambda: self.open_url('download'))
Expand Down
8 changes: 4 additions & 4 deletions videotrans/mainwin/spwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ def initUI(self):

# 底部状态栏
self.statusLabel = QPushButton(config.transobj["Open Documents"])

self.statusLabel.setStyleSheet("background-color:#455364;color:#ffff00")
self.statusLabel.setCursor(QtCore.Qt.PointingHandCursor)
# self.statusLabel.setStyleSheet("background-color:#455364;color:#ffff00")

self.statusBar.addWidget(self.statusLabel)

self.rightbottom = QPushButton(config.transobj['juanzhu'])
self.rightbottom.setStyleSheet("background-color:#455364;color:#ffffff;border:0")
# self.rightbottom.setStyleSheet("background-color:#455364;color:#ffffff;border:0")
self.rightbottom.setCursor(QtCore.Qt.PointingHandCursor)

self.container = QToolBar()
Expand Down Expand Up @@ -344,7 +344,6 @@ def bind_action(self):
self.action_fanyi.triggered.connect(lambda: self.util.open_toolbox(6, False))

self.action_clearcache.triggered.connect(self.util.clearcache)
self.action_separate.triggered.connect(self.subform.open_separate)
# 禁止随意移动sp.exe
if not Path(config.rootdir+'/videotrans').exists() or not Path(config.rootdir+ '/models').exists():
QMessageBox.critical(self, config.transobj['anerror'], config.transobj['sp.exeerror'])
Expand All @@ -358,6 +357,7 @@ def bind_action(self):
self.rightbottom.clicked.connect(self.util.about)
# 日志
if not shutil.which("ffmpeg") or not shutil.which("ffprobe"):
QMessageBox.critical(self, config.transobj['anerror'], config.transobj['installffmpeg'])
self.startbtn.setText(config.transobj['installffmpeg'])
self.startbtn.setDisabled(True)
self.startbtn.setStyleSheet("""color:#ff0000""")
Expand Down
64 changes: 0 additions & 64 deletions videotrans/mainwin/subform.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from PySide6.QtCore import QThread, Signal
from PySide6.QtGui import Qt
from videotrans.configure import config
from videotrans.task.separate_worker import SeparateWorker
from videotrans.util import tools


Expand Down Expand Up @@ -85,70 +84,7 @@ def save(role):
self.main.w.set_ok.clicked.connect(lambda: self.main.w.close())
self.main.w.show()

def open_separate(self):
def get_file():
fname, _ = QtWidgets.QFileDialog.getOpenFileName(self.main.sepw, "Select audio or video", config.last_opendir,
"files(*.wav *.mp3 *.aac *.m4a *.flac *.mp4 *.mov *.mkv)")
if fname:
self.main.sepw.fromfile.setText(fname.replace('file:///', '').replace('\\', '/'))

def update(d):
# 更新
if d == 'succeed':
self.main.sepw.set.setText(config.transobj['Separate End/Restart'])
self.main.sepw.fromfile.setText('')
elif d == 'end':
self.main.sepw.set.setText(config.transobj['Start Separate'])
else:
QtWidgets.QMessageBox.critical(self.main.sepw, config.transobj['anerror'], d)

def start():
if config.separate_status == 'ing':
config.separate_status = 'stop'
self.main.sepw.set.setText(config.transobj['Start Separate'])
return
# 开始处理分离,判断是否选择了源文件
file = self.main.sepw.fromfile.text()
if not tools.vail_file(file):
QtWidgets.QMessageBox.critical(self.main.sepw, config.transobj['anerror'],
config.transobj['must select audio or video file'])
return
self.main.sepw.set.setText(config.transobj['Start Separate...'])
basename = os.path.basename(file)
# 判断名称是否正常
rs, newfile, base = tools.rename_move(file, is_dir=False)
if rs:
file = newfile
basename = base
# 创建文件夹
out = os.path.join(outdir, basename).replace('\\', '/')
os.makedirs(out, exist_ok=True)
self.main.sepw.url.setText(out)
# 开始分离
config.separate_status = 'ing'
self.main.sepw.task = SeparateWorker(parent=self.main.sepw, out=out, file=file, basename=basename)
self.main.sepw.task.finish_event.connect(update)
self.main.sepw.task.start()

from videotrans.component import SeparateForm
try:
if self.main.sepw is not None:
self.main.sepw.show()
return
self.main.sepw = SeparateForm()
self.main.sepw.set.setText(config.transobj['Start Separate'])
outdir = os.path.join(config.homedir, 'separate').replace('\\', '/')
if not os.path.exists(outdir):
os.makedirs(outdir, exist_ok=True)
# 创建事件过滤器实例并将其安装到 lineEdit 上
self.main.sepw.url.setText(outdir)

self.main.sepw.selectfile.clicked.connect(get_file)

self.main.sepw.set.clicked.connect(start)
self.main.sepw.show()
except:
pass

def open_youtube(self):
def download():
Expand Down
2 changes: 1 addition & 1 deletion videotrans/set.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ crf=13
;List of model names #################################
;可供选择的chatGPT模型,以英文逗号分隔
;Available chatGPT models, separated by English commas
chatgpt_model=gpt-3.5-turbo,gpt-4,gpt-4-turbo-preview,qwen,moonshot-v1-8k
chatgpt_model=gpt-3.5-turbo,gpt-4,gpt-4-turbo-preview,qwen,moonshot-v1-8k,deepseek-chat


;################声画字幕对齐相关#################################
Expand Down
2 changes: 1 addition & 1 deletion videotrans/task/check_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get(self):
d=res.json()
if d['version_num']>videotrans.VERSION_NUM:
msg = f"{transobj['newversion']}:{d['version']}"
set_process(msg,"check_soft_update")
set_process(msg,type="check_soft_update")
except Exception as e:
pass
return False
Expand Down
4 changes: 2 additions & 2 deletions videotrans/task/logs_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def run(self):
return
try:
obj = queue_logs.get(True, 0.5)
if config.current_status!='ing':
continue
if "type" not in obj:
obj['type'] = 'logs'
if config.current_status!='ing' and obj['type'] in ['logs','error','stop','end','succeed']:
continue
self.post_logs.emit(json.dumps(obj))
except Exception as e:
pass
54 changes: 49 additions & 5 deletions videotrans/translator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"ZH", # deepl deeplx通道
"zh", # 腾讯通道
"zh", # OTT通道
"zh-Hans",
"Simplified Chinese"
"zh-Hans",# 微软翻译
"Simplified Chinese" #AI翻译
],
"zh-tw": [
"zh-tw",
Expand Down Expand Up @@ -203,15 +203,59 @@
"No",
"hu",
"Hungarian language"
]
],
"uk":[
"uk",
"ukr",
"ukr",#百度
"No",#deepl
"No",#腾讯
"No",#ott
"uk",#微软
"Ukrainian language"
],
"id":[
"id",
"ind",
"id",
"No",
"id",
"No",
"id",
"Indonesian language"
],
"ms":[
"ms",
"may",
"may",
"No",
"ms",
"No",
"ms",
"Malay language"
],
"kk":[
"kk",
"kaz",
"No",
"No",
"No",
"No",
"kk",
"Kazakh language"
],
}


# 根据界面显示的语言名称,比如“简体中文、English” 获取语言代码,比如 zh-cn en 等, 如果是cli,则直接是语言代码
def get_code(*, show_text=None):
if show_text == '-':
if not show_text or show_text == '-' :
return None
return config.langlist[show_text] if show_text in config.langlist else config.rev_langlist[show_text]
if show_text in LANG_CODE:
return show_text
if show_text in config.rev_langlist:
return config.rev_langlist[show_text]
return None


# 根据显示的语言和翻译通道,获取该翻译通道要求的源语言代码和目标语言代码
Expand Down
Loading

0 comments on commit 4d87c42

Please sign in to comment.