-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy path__main__.py
More file actions
39 lines (29 loc) · 1.06 KB
/
__main__.py
File metadata and controls
39 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import sys
import sysconfig
def find_whisper_bin() -> str:
"""Return the whisper binary path."""
whisper_exe = "whisper-cpp" + sysconfig.get_config_var("EXE")
path = os.path.join(sysconfig.get_path("scripts"), whisper_exe)
if os.path.isfile(path):
return path
if sys.version_info >= (3, 10):
user_scheme = sysconfig.get_preferred_scheme("user")
elif os.name == "nt":
user_scheme = "nt_user"
elif sys.platform == "darwin" and sys._framework:
user_scheme = "osx_framework_user"
else:
user_scheme = "posix_user"
path = os.path.join(sysconfig.get_path("scripts", scheme=user_scheme), whisper_exe)
if os.path.isfile(path):
return path
raise FileNotFoundError(path)
if __name__ == "__main__":
whisper = os.fsdecode(find_whisper_bin())
if sys.platform == "win32":
import subprocess
completed_process = subprocess.run([whisper, *sys.argv[1:]])
sys.exit(completed_process.returncode)
else:
os.execvp(whisper, [whisper, *sys.argv[1:]])