Update whispercpp.pyx
This commit is contained in:
		
							parent
							
								
									a021ae79da
								
							
						
					
					
						commit
						1e49c6627d
					
				|  | @ -7,6 +7,9 @@ import ffmpeg | |||
| import numpy as np | ||||
| import requests | ||||
| import os | ||||
| from pathlib import Path | ||||
| 
 | ||||
| MODELS_DIR = Path('~/ggml-models').expanduser() | ||||
| 
 | ||||
| 
 | ||||
| cimport numpy as cnp | ||||
|  | @ -35,7 +38,7 @@ def download_model(model): | |||
|     print(f'Downloading {model}...') | ||||
|     url = MODELS[model.decode()] | ||||
|     r = requests.get(url, allow_redirects=True) | ||||
|     with open(model, 'wb') as f: | ||||
|     with open(MODELS_DIR / model, 'wb') as f: | ||||
|         f.write(r.content) | ||||
| 
 | ||||
| 
 | ||||
|  | @ -88,7 +91,7 @@ cdef class Whisper: | |||
|     def __init__(self, model=DEFAULT_MODEL, pb=None): | ||||
|         model_fullname = f'model_ggml_{model}.bin'.encode('utf8') | ||||
|         download_model(model_fullname) | ||||
|         cdef bytes model_b = model_fullname | ||||
|         cdef bytes model_b = MODELS_DIR / model_fullname | ||||
|         self.ctx = whisper_init(model_b) | ||||
|         self.params = default_params() | ||||
|         whisper_print_system_info() | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue