Merge pull request #9 from rlrs/main
Fixed wheel builds and model downloads
This commit is contained in:
		
						commit
						e2581c8aad
					
				
							
								
								
									
										17
									
								
								setup.py
								
								
								
								
							
							
						
						
									
										17
									
								
								setup.py
								
								
								
								
							|  | @ -1,15 +1,27 @@ | |||
| from distutils.core import setup | ||||
| from distutils.extension import Extension | ||||
| from Cython.Build import cythonize | ||||
| import numpy, os, sys | ||||
| 
 | ||||
| if sys.platform == 'darwin': | ||||
|     os.environ['CFLAGS']   = '-DGGML_USE_ACCELERATE -O3 -std=c11' | ||||
|     os.environ['CFLAGS']   = '-DGGML_USE_ACCELERATE -O3 -std=gnu11' | ||||
|     os.environ['CXXFLAGS'] = '-DGGML_USE_ACCELERATE -O3 -std=c++11' | ||||
|     os.environ['LDFLAGS']  = '-framework Accelerate' | ||||
| else: | ||||
|     os.environ['CFLAGS']   = '-mavx -mavx2 -mfma -mf16c -O3 -std=c11' | ||||
|     os.environ['CFLAGS']   = '-mavx -mavx2 -mfma -mf16c -O3 -std=gnu11' | ||||
|     os.environ['CXXFLAGS'] = '-mavx -mavx2 -mfma -mf16c -O3 -std=c++11' | ||||
| 
 | ||||
| ext_modules = [ | ||||
|     Extension( | ||||
|         name="whispercpp", | ||||
|         sources=["whispercpp.pyx", "whisper.cpp/whisper.cpp"], | ||||
|         language="c++", | ||||
|         extra_compile_args=["-std=c++11"], | ||||
|    ) | ||||
| ] | ||||
| ext_modules = cythonize(ext_modules) | ||||
| 
 | ||||
| whisper_clib = ('whisper_clib', {'sources': ['whisper.cpp/ggml.c']}) | ||||
| 
 | ||||
| setup( | ||||
|     name='whispercpp', | ||||
|  | @ -17,6 +29,7 @@ setup( | |||
|     description='Python bindings for whisper.cpp', | ||||
|     author='Luke Southam', | ||||
|     author_email='luke@devthe.com', | ||||
|     libraries=[whisper_clib], | ||||
|     ext_modules = cythonize("whispercpp.pyx"), | ||||
|     include_dirs = ['./whisper.cpp/', numpy.get_include()], | ||||
|     install_requires=[ | ||||
|  |  | |||
|  | @ -1,7 +1,5 @@ | |||
| #!python | ||||
| # cython: language_level=3 | ||||
| # distutils: language = c++ | ||||
| # distutils: sources= ./whisper.cpp/whisper.cpp ./whisper.cpp/ggml.c | ||||
| 
 | ||||
| import ffmpeg | ||||
| import numpy as np | ||||
|  | @ -9,7 +7,7 @@ import requests | |||
| import os | ||||
| from pathlib import Path | ||||
| 
 | ||||
| MODELS_DIR = str(Path('~/ggml-models').expanduser()) | ||||
| MODELS_DIR = str(Path('~/.ggml-models').expanduser()) | ||||
| print("Saving models to:", MODELS_DIR) | ||||
| 
 | ||||
| 
 | ||||
|  | @ -39,6 +37,7 @@ def download_model(model): | |||
|     print(f'Downloading {model}...') | ||||
|     url = MODELS[model] | ||||
|     r = requests.get(url, allow_redirects=True) | ||||
|     os.makedirs(MODELS_DIR, exist_ok=True) | ||||
|     with open(Path(MODELS_DIR).joinpath(model), 'wb') as f: | ||||
|         f.write(r.content) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue