update
This commit is contained in:
parent
706ed9eeea
commit
d77b377502
3
setup.py
3
setup.py
|
@ -10,10 +10,11 @@ else:
|
||||||
os.environ['CFLAGS'] = '-mavx -mavx2 -mfma -mf16c -O3'
|
os.environ['CFLAGS'] = '-mavx -mavx2 -mfma -mf16c -O3'
|
||||||
os.environ['CXXFLAGS'] = '-mavx -mavx2 -mfma -mf16c -O3'
|
os.environ['CXXFLAGS'] = '-mavx -mavx2 -mfma -mf16c -O3'
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='whispercpp',
|
name='whispercpp',
|
||||||
version='1.0',
|
version='1.0',
|
||||||
description='Python Bindings for whisper.cpp',
|
description='Python bindings for whisper.cpp',
|
||||||
author='Luke Southam',
|
author='Luke Southam',
|
||||||
author_email='luke@devthe.com',
|
author_email='luke@devthe.com',
|
||||||
ext_modules = cythonize("whispercpp.pyx"),
|
ext_modules = cythonize("whispercpp.pyx"),
|
||||||
|
|
|
@ -12,7 +12,7 @@ cimport numpy as cnp
|
||||||
|
|
||||||
cdef int SAMPLE_RATE = 16000
|
cdef int SAMPLE_RATE = 16000
|
||||||
cdef char* TEST_FILE = b'test.wav'
|
cdef char* TEST_FILE = b'test.wav'
|
||||||
cdef char* DEFAULT_MODEL = b'model_ggml_tiny.bin'
|
cdef char* DEFAULT_MODEL = b'tiny'
|
||||||
cdef char* LANGUAGE = b'fr'
|
cdef char* LANGUAGE = b'fr'
|
||||||
|
|
||||||
MODELS = {
|
MODELS = {
|
||||||
|
@ -30,7 +30,7 @@ def download_model(model):
|
||||||
if model_exists(model):
|
if model_exists(model):
|
||||||
return
|
return
|
||||||
|
|
||||||
print('Downloading model...')
|
print(f'Downloading {model}...')
|
||||||
url = MODELS[model]
|
url = MODELS[model]
|
||||||
r = requests.get(url, allow_redirects=True)
|
r = requests.get(url, allow_redirects=True)
|
||||||
with open(model, 'wb') as f:
|
with open(model, 'wb') as f:
|
||||||
|
@ -53,7 +53,7 @@ cdef audio_data load_audio(bytes file, int sr = SAMPLE_RATE):
|
||||||
)
|
)
|
||||||
)[0]
|
)[0]
|
||||||
except:
|
except:
|
||||||
raise RuntimeError('File not found')
|
raise RuntimeError(f"File '{file}' not found")
|
||||||
|
|
||||||
cdef cnp.ndarray[cnp.float32_t, ndim=1, mode="c"] frames = (
|
cdef cnp.ndarray[cnp.float32_t, ndim=1, mode="c"] frames = (
|
||||||
np.frombuffer(out, np.int16)
|
np.frombuffer(out, np.int16)
|
||||||
|
@ -82,7 +82,8 @@ cdef class Whisper:
|
||||||
cdef whisper_context * ctx
|
cdef whisper_context * ctx
|
||||||
cdef whisper_full_params params
|
cdef whisper_full_params params
|
||||||
|
|
||||||
def __init__(self, char* model=DEFAULT_MODEL):
|
def __init__(self, char* model=DEFAULT_MODEL, pb=None):
|
||||||
|
model = b'model_ggml_' + model + b'.bin'
|
||||||
download_model(model)
|
download_model(model)
|
||||||
self.ctx = whisper_init(model)
|
self.ctx = whisper_init(model)
|
||||||
self.params = default_params()
|
self.params = default_params()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user