40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
import os
|
|
import sys
|
|
|
|
ROOT = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
_nvidia = os.path.join(ROOT, 'venv', 'lib',
|
|
f'python{sys.version_info.major}.{sys.version_info.minor}',
|
|
'site-packages', 'nvidia')
|
|
_extra_ld = ':'.join(os.path.join(_nvidia, d, 'lib')
|
|
for d in ('cublas', 'cudnn', 'cuda_nvrtc')
|
|
if os.path.isdir(os.path.join(_nvidia, d, 'lib')))
|
|
|
|
if _extra_ld:
|
|
existing = os.environ.get('LD_LIBRARY_PATH', '')
|
|
_first = _extra_ld.split(':')[0]
|
|
if _first not in existing:
|
|
os.environ['LD_LIBRARY_PATH'] = _extra_ld + ':' + existing
|
|
os.execv(sys.executable, [sys.executable] + sys.argv)
|
|
|
|
sys.path.insert(0, ROOT)
|
|
|
|
ENV = os.path.expanduser("~/.local/share/speech-to-text/speech-to-text.env")
|
|
try:
|
|
with open(ENV) as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
if not line or line.startswith('#'):
|
|
continue
|
|
if '=' in line:
|
|
k, v = line.split('=', 1)
|
|
os.environ[k] = v
|
|
except FileNotFoundError:
|
|
pass
|
|
|
|
from lib.server import run_server
|
|
|
|
if __name__ == "__main__":
|
|
run_server()
|