diff --git a/README.md b/README.md index f8679b2..ec00dce 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ This script uses argparse to accept command line arguments. The following option | `--use_finetune` | Use fine-tuned model. This will increase accuracy, but will also increase latency. Additional VRAM/RAM usage is required. | | `--no_log` | Makes it so only the last thing translated/transcribed is shown rather log style list. | | `--retry` | Retries translations and transcription if they fail. | +| `--updatebranch` | Check which branch from the repo to check for updates. Default is **master**, choices are **master** and **dev-testing**. To turn off update checks use **disable**. | | `--about` | Shows about the app. | # Things to note! diff --git a/modules/__pycache__/parser_args.cpython-310.pyc b/modules/__pycache__/parser_args.cpython-310.pyc index d334f81..2b5325e 100644 Binary files a/modules/__pycache__/parser_args.cpython-310.pyc and b/modules/__pycache__/parser_args.cpython-310.pyc differ diff --git a/modules/__pycache__/version_checker.cpython-310.pyc b/modules/__pycache__/version_checker.cpython-310.pyc index a952c8d..272c130 100644 Binary files a/modules/__pycache__/version_checker.cpython-310.pyc and b/modules/__pycache__/version_checker.cpython-310.pyc differ diff --git a/modules/parser_args.py b/modules/parser_args.py index 7d7f0a4..2749db3 100644 --- a/modules/parser_args.py +++ b/modules/parser_args.py @@ -55,6 +55,7 @@ def parse_arguments(): parser.add_argument("--auto_language_lock", action='store_true', help="Automatically locks the language based on the detected language after set ammount of transcriptions.") parser.add_argument("--retry", action='store_true', help="Retries the transcription if it fails. May increase output time.") parser.add_argument("--use_finetune", action='store_true', help="Use finetuned model.") + parser.add_argument("--updatebranch", default="master", help="Check which branch from the repo to check for updates. Default is master, choices are master and dev-testing. To turn off update checks use disable.", choices=["master", "dev-testing", "disable"]) parser.add_argument("--about", action='store_true', help="About the project.") args = parser.parse_args() return args diff --git a/modules/version_checker.py b/modules/version_checker.py index 9b13ee6..2337719 100644 --- a/modules/version_checker.py +++ b/modules/version_checker.py @@ -1,5 +1,6 @@ import requests import re +from colorama import Fore, Back, Style, init version = "1.0.9971" ScriptCreator = "cyberofficial" @@ -7,8 +8,8 @@ repo_owner = "cyberofficial" repo_name = "Synthalingua" -def get_remote_version(repo_owner, repo_name, file_path): - url = f"https://raw.githubusercontent.com/{repo_owner}/{repo_name}/master/{file_path}" +def get_remote_version(repo_owner, repo_name, updatebranch, file_path): + url = f"https://raw.githubusercontent.com/{repo_owner}/{repo_name}/{updatebranch}/{file_path}" response = requests.get(url) if response.status_code == 200: @@ -18,25 +19,55 @@ def get_remote_version(repo_owner, repo_name, file_path): remote_version = version_search.group(1) return remote_version else: - print("Error: Version not found in the remote file.") + print(f"{Fore.RED}Error: Version not found in the remote file.{Style.RESET_ALL}") return None else: - print(f"An error occurred. Status code: {response.status_code}") + print(f"{Fore.RED}An error occurred when checking for updates. Status code: {response.status_code}{Style.RESET_ALL}") + print(f"Could not fetch remote version from: {Fore.YELLOW}{url}{Style.RESET_ALL}") + print(f"Please check your internet connection and try again.") + print("\n\n") return None -def check_for_updates(): +def check_for_updates(updatebranch): local_version = version - remote_version = get_remote_version(repo_owner, repo_name, "transcribe_audio.py") + remote_version = get_remote_version(repo_owner, repo_name, updatebranch, "modules/version_checker.py") if remote_version is not None: - if remote_version != local_version: - print(f"Version mismatch. Local version: {local_version}, remote version: {remote_version}") + # Split the version numbers into parts (major, minor, patch) + local_version_parts = [int(part) for part in local_version.split(".")] + remote_version_parts = [int(part) for part in remote_version.split(".")] + + # Compare major versions + if remote_version_parts[0] > local_version_parts[0]: + print(f"Major version mismatch. Local version: {Fore.YELLOW}{local_version}{Style.RESET_ALL}, remote version: {Fore.YELLOW}{remote_version}{Style.RESET_ALL}") print("Consider updating to the latest version.") - print(f"Update available at: " + GitHubRepo) - print("\n\n\n\n\n\n") + print(f"Update available at: {GitHubRepo}") + print("\n\n") + elif remote_version_parts[0] == local_version_parts[0]: + # Compare minor versions + if remote_version_parts[1] > local_version_parts[1]: + print(f"Minor version mismatch. Local version: {Fore.YELLOW}{local_version}{Style.RESET_ALL}, remote version: {Fore.YELLOW}{remote_version}{Style.RESET_ALL}") + print("Consider updating to the latest version.") + print(f"Update available at: {GitHubRepo}") + print("\n\n") + elif remote_version_parts[1] == local_version_parts[1]: + # Compare patch versions + if remote_version_parts[2] > local_version_parts[2]: + print(f"Patch version mismatch. Local version: {Fore.YELLOW}{local_version}{Style.RESET_ALL}, remote version: {Fore.YELLOW}{remote_version}{Style.RESET_ALL}") + print("Consider updating to the latest version.") + print(f"Update available at: {GitHubRepo}") + print("\n\n") + else: + print("You are already using the latest version.") + print(f"Current version: {local_version}") + print("\n\n") + else: + print("You are already using a newer version.") + print(f"Current version: {local_version}") + print("\n\n") else: - print("You are already using the latest version.") + print("You are already using a newer version.") print(f"Current version: {local_version}") - print("\n\n\n\n\n\n") + print("\n\n") -print("Version Checker Module Loaded") \ No newline at end of file +print("Version Checker Module Loaded") diff --git a/transcribe_audio.py b/transcribe_audio.py index c71dd42..cad1b12 100644 --- a/transcribe_audio.py +++ b/transcribe_audio.py @@ -51,13 +51,16 @@ from modules.warnings import print_warning from modules import parser_args from modules.languages import get_valid_languages -print("Modules Loaded\n\n\n\n\n") +print("Modules Loaded\n\n") # Code is semi documented, but if you have any questions, feel free to ask in the Discussions tab. def main(): + args = parser_args.parse_arguments() - check_for_updates() + # if args.updatebranch is set as disable then skip + if args.updatebranch != "disable": + check_for_updates(args.updatebranch) def record_callback(_, audio:sr.AudioData) -> None: data = audio.get_raw_data() @@ -96,9 +99,6 @@ def is_input_device(device_index): return sr.Microphone(sample_rate=16000, device_index=index), "system default" raise ValueError("No valid input devices found.") - - - args = parser_args.parse_arguments() if len(sys.argv) == 1: parser.print_help()