Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Sakamoto Shiina
2024-01-07 05:58:27 +09:00
3 changed files with 22 additions and 12 deletions

View File

@@ -16,5 +16,5 @@ rmdir /s /q %local_path%%folder_tmp%
if %restart% == True ( if %restart% == True (
START "" %local_path%%exe_name% START "" %local_path%%exe_name%
) )
pause
del /f "%~dp0%~nx0" del /f "%~dp0%~nx0"

View File

@@ -660,7 +660,7 @@ class Config:
def init_config(self): def init_config(self):
# Read Only # Read Only
self._VERSION = "2.0.1" self._VERSION = "2.0.2"
self._ENABLE_SPEAKER2CHATBOX = False # Speaker2Chatbox self._ENABLE_SPEAKER2CHATBOX = False # Speaker2Chatbox
self._LOCAL_PATH = os_path.dirname(sys.argv[0]) self._LOCAL_PATH = os_path.dirname(sys.argv[0])
self._PATH_CONFIG = os_path.join(self._LOCAL_PATH, "config.json") self._PATH_CONFIG = os_path.join(self._LOCAL_PATH, "config.json")

View File

@@ -1,8 +1,8 @@
import tempfile
from zipfile import ZipFile from zipfile import ZipFile
from subprocess import Popen from subprocess import Popen
from os import makedirs as os_makedirs from os import makedirs as os_makedirs
from os import path as os_path from os import path as os_path
from os import remove as os_remove
from shutil import copyfile from shutil import copyfile
from datetime import datetime from datetime import datetime
from logging import getLogger, FileHandler, Formatter, INFO from logging import getLogger, FileHandler, Formatter, INFO
@@ -12,6 +12,8 @@ from threading import Thread, Event
from requests import get as requests_get from requests import get as requests_get
import webbrowser import webbrowser
from tqdm import tqdm
from typing import Callable
from flashtext import KeywordProcessor from flashtext import KeywordProcessor
from models.translation.translation_translator import Translator from models.translation.translation_translator import Translator
from models.transcription.transcription_utils import getInputDevices, getDefaultOutputDevice from models.transcription.transcription_utils import getInputDevices, getDefaultOutputDevice
@@ -265,7 +267,7 @@ class Model:
return update_flag return update_flag
@staticmethod @staticmethod
def updateSoftware(restart:bool=True): def updateSoftware(restart:bool=True, func=None):
filename = 'VRCT.zip' filename = 'VRCT.zip'
program_name = 'VRCT.exe' program_name = 'VRCT.exe'
folder_name = '_internal' folder_name = '_internal'
@@ -277,14 +279,22 @@ class Model:
res = requests_get(config.GITHUB_URL) res = requests_get(config.GITHUB_URL)
assets = res.json()['assets'] assets = res.json()['assets']
url = [i["browser_download_url"] for i in assets if i["name"] == filename][0] url = [i["browser_download_url"] for i in assets if i["name"] == filename][0]
res = requests_get(url, stream=True) with tempfile.TemporaryDirectory() as tmp_path:
os_makedirs(os_path.join(current_directory, tmp_directory_name), exist_ok=True) res = requests_get(url, stream=True)
with open(os_path.join(current_directory, tmp_directory_name, filename), 'wb') as file: file_size = int(res.headers.get('content-length', 0))
for chunk in res.iter_content(chunk_size=1024): pbar = tqdm(total=file_size, unit="B", unit_scale=True)
file.write(chunk) total_chunk = 0
with ZipFile(os_path.join(current_directory, tmp_directory_name, filename)) as zf: with open(os_path.join(tmp_path, filename), 'wb') as file:
zf.extractall(os_path.join(current_directory, tmp_directory_name)) for chunk in res.iter_content(chunk_size=1024*5):
os_remove(os_path.join(current_directory, tmp_directory_name, filename)) file.write(chunk)
pbar.update(len(chunk))
if isinstance(func, Callable):
total_chunk += len(chunk)
func(total_chunk/file_size)
pbar.close()
with ZipFile(os_path.join(tmp_path, filename)) as zf:
zf.extractall(os_path.join(current_directory, tmp_directory_name))
copyfile(os_path.join(current_directory, folder_name, "batch", batch_name), os_path.join(current_directory, batch_name)) copyfile(os_path.join(current_directory, folder_name, "batch", batch_name), os_path.join(current_directory, batch_name))
command = [os_path.join(current_directory, batch_name), program_name, folder_name, tmp_directory_name, str(restart)] command = [os_path.join(current_directory, batch_name), program_name, folder_name, tmp_directory_name, str(restart)]
Popen(command, cwd=current_directory) Popen(command, cwd=current_directory)