checkvosk.py 873 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
import sys
import subprocess
import pkg_resources

required = {'vosk', 'srt'}
installed = {pkg.key for pkg in pkg_resources.working_set}
missing = required - installed
print ("Missing pachages: ", missing)
if missing and len(sys.argv) > 1 :
10
    # install missing modules
11
    print ("Installing missing packages: ", missing)
12
13
    python = sys.executable
    subprocess.check_call([python, '-m', 'pip', 'install', *missing], stdout=subprocess.DEVNULL)
14
elif len(sys.argv) > 1 :
15
    if sys.argv[1] == 'upgrade':
16
        # update modules
17
        print ("Updating packages: ", required)
18
19
20
21
22
23
        python = sys.executable
        subprocess.check_call([python, '-m', 'pip', 'install', '--upgrade', *required], stdout=subprocess.DEVNULL)
    else:
        # check modules version
        python = sys.executable
        subprocess.check_call([python, '-m', 'pip', 'show', *required])