mirror of
https://github.com/DrewThomasson/ebook2audiobook.git
synced 2026-01-10 06:18:02 -05:00
...
This commit is contained in:
18
app.py
18
app.py
@@ -187,15 +187,15 @@ Tip: to add of silence (1.4 seconds) into your text just use "###" or "[pause]".
|
||||
|
||||
print(f"v{prog_version} {args['script_mode']} mode")
|
||||
|
||||
if args['script_mode'] == NATIVE:
|
||||
check_pkg = check_and_install_requirements(requirements_file)
|
||||
if check_pkg:
|
||||
if not check_dictionary():
|
||||
sys.exit(1)
|
||||
else:
|
||||
error = 'Some packages could not be installed'
|
||||
print(error)
|
||||
sys.exit(1)
|
||||
#if args['script_mode'] == NATIVE:
|
||||
# check_pkg = check_and_install_requirements(requirements_file)
|
||||
# if check_pkg:
|
||||
# if not check_dictionary():
|
||||
# sys.exit(1)
|
||||
# else:
|
||||
# error = 'Some packages could not be installed'
|
||||
# print(error)
|
||||
# sys.exit(1)
|
||||
|
||||
import lib.functions as f
|
||||
f.context = f.SessionContext() if f.context is None else f.context
|
||||
|
||||
11
lib/utils.py
11
lib/utils.py
@@ -231,16 +231,13 @@ def detect_device()->str:
|
||||
# CPU
|
||||
# ============================================================
|
||||
return 'cpu'
|
||||
|
||||
def parse_torch_version(current:str)->Version:
|
||||
return Version(current).base_version
|
||||
|
||||
def check_torch()->bool:
|
||||
try:
|
||||
import torch
|
||||
torch_version = getattr(torch, '__version__', False)
|
||||
if torch_version:
|
||||
torch_version_parsed = parse_torch_version(torch_version)
|
||||
torch_version_parsed = Version(torch_version).base_version
|
||||
backend_specs = {"os": detect_platform_tag(), "arch": detect_arch_tag(), "pyvenv": sys.version_info[:2], "device": detect_device()}
|
||||
print(backend_specs)
|
||||
if backend_specs['device'] not in ['cpu', 'unknown', 'unsupported']:
|
||||
@@ -296,11 +293,7 @@ def check_and_install_requirements(file_path:str)->bool:
|
||||
from tqdm import tqdm
|
||||
except ImportError:
|
||||
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--no-cache-dir', 'packaging', 'tqdm'])
|
||||
from tqdm import tqdm
|
||||
torch_version = ''
|
||||
if check_torch():
|
||||
import torch
|
||||
torch_version = torch.__version__
|
||||
from tqdm import tqdm
|
||||
with open(file_path, 'r') as f:
|
||||
contents = f.read().replace('\r', '\n')
|
||||
packages = [pkg.strip() for pkg in contents.splitlines() if pkg.strip() and re.search(r'[a-zA-Z0-9]', pkg)]
|
||||
|
||||
Reference in New Issue
Block a user