CoolFace
Apppublic

kwau/sovits-isla

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
setup.py68 linesDownload Raw Back to root
1import os2import re3import socket4import subprocess5import sys6 7import psutil8 9 10def check_ffmpeg_path():11    cwd = os.getcwd()12    ffmpeg_path = os.path.join(cwd, "ffmpeg", "bin", "ffmpeg.exe")13    ffprobe_path = os.path.join(cwd, "ffmpeg", "bin", "ffprobe.exe")14    return os.path.isfile(ffmpeg_path) and os.path.isfile(ffprobe_path)15 16def get_default_browser():17    browser = ""18    try:19        cmd = r'reg query HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice /v ProgId'20        output = subprocess.check_output(cmd, shell=True).decode()21        browser = output.split()[-1].split('\\')[-1]22    except Exception as e:23        print(f"Error: {e}")24        browser = "Unknown"25    return browser26 27def get_hostname():28    try:29        hostname = socket.gethostname()30        return hostname31    except socket.error as e:32        print("Error: ", e)33 34def get_pagefile_size():35    try:36        pagefile = psutil.swap_memory().total37    except UnboundLocalError:38        pagefile = 039    except RuntimeError:40        pagefile = None41    return pagefile42    43    44def main():45    allowed_pattern = re.compile(r'^[a-zA-Z0-9_@#$%^&()_+\-=\s\.]*$')46    hostname = get_hostname()47    pagefile = get_pagefile_size()48    default_browser = get_default_browser() 49    if check_ffmpeg_path():50        print("FFmpeg already installed, skipping...")51    else:52        try:53            sys.exit(0)54        finally:55            print("未找到FFmpeg,整合包可能不完整,请重新下载")56    if pagefile is None:57        print("WARNING | 系统未开启性能计数器,无法获取当前虚拟内存状态,确保虚拟内存大于30G后可忽略此警告")58    elif pagefile < 31457280000: # 30 GiB59        print("WARNING | 虚拟内存不足30GB,可能会导致使用问题,请将虚拟内存设置为至少30G")60    if "chrome" not in default_browser.lower() and "edge" not in default_browser.lower() and "firefox" not in default_browser.lower():61        print("WARNING | 默认浏览器不符合要求,可能会影响使用,请更换为Chrome或Edge浏览器")62    if not allowed_pattern.match(hostname):63        print("WARNING | 计算机主机名中含有非西文字符,启动Tensorboard时可能出错,请在计算机设置中修改")64 65    os.system("workenv\python.exe app.py")66            67if __name__ == "__main__":68    main()