Skip to content

Commit 3520d10

Browse files
linziyilinziyi
authored andcommitted
Support python inference on windows with prebuilt-lib
1 parent 5ed0149 commit 3520d10

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

include/ten_vad.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,33 @@ def __init__(self, hop_size: int = 256, threshold: float = 0.5):
4040
"./ten_vad_library/libten_vad"
4141
)
4242
self.vad_library = CDLL(pip_path)
43+
elif platform.system().upper() == 'WINDOWS':
44+
if platform.machine().upper() in ['X64', 'X86_64', 'AMD64']:
45+
git_path = os.path.join(
46+
os.path.dirname(os.path.relpath(__file__)),
47+
"../lib/Windows/x64/ten_vad.dll"
48+
)
49+
if os.path.exists(git_path):
50+
self.vad_library = CDLL(git_path)
51+
else:
52+
pip_path = os.path.join(
53+
os.path.dirname(os.path.relpath(__file__)),
54+
"./ten_vad_library/ten_vad.dll"
55+
)
56+
self.vad_library = CDLL(pip_path)
57+
else:
58+
git_path = os.path.join(
59+
os.path.dirname(os.path.relpath(__file__)),
60+
"../lib/Windows/x86/ten_vad.dll"
61+
)
62+
if os.path.exists(git_path):
63+
self.vad_library = CDLL(git_path)
64+
else:
65+
pip_path = os.path.join(
66+
os.path.dirname(os.path.relpath(__file__)),
67+
"./ten_vad_library/ten_vad.dll"
68+
)
69+
self.vad_library = CDLL(pip_path)
4370
else:
4471
raise NotImplementedError(f"Unsupported platform: {platform.system()} {platform.machine()}")
4572
self.vad_handler = c_void_p(0)

setup.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ def run(self):
2121
shutil.copy("lib/macOS/ten_vad.framework/Versions/A/ten_vad",
2222
os.path.join(target_dir, "libten_vad"))
2323
print(f"macOS library installed to: {target_dir}")
24+
elif platform.system().upper() == 'WINDOWS':
25+
if platform.machine().upper() in ['X64', 'X86_64', 'AMD64']:
26+
shutil.copy("lib/Windows/x64/ten_vad.dll",
27+
os.path.join(target_dir, "ten_vad.dll"))
28+
print(f"Windows x64 library installed to: {target_dir}")
29+
else:
30+
shutil.copy("lib/Windows/x86/ten_vad.dll",
31+
os.path.join(target_dir, "ten_vad.dll"))
32+
print(f"Windows x86 library installed to: {target_dir}")
2433
else:
2534
raise NotImplementedError(f"Unsupported platform: {platform.system()} {platform.machine()}")
2635

0 commit comments

Comments
 (0)