Closed to-aoki closed 10 months ago
Hello @to-aoki,
Did it work for normal str path ? Would you like me to add support for a Path object ?
@abdeladim-s Thank you for your reply.
It doesn't work with normal str path. I think it would be a convert the passed to cpp with a pathlib.Path object to primitive str.
self.model_path = str(Path(model).absolute())
Yes I understand, thanks @to-aoki for pointing that out.
we just need to set the model attribute as is (it should already be str
without the need to use the Path object).
Could you please give it a try now ? change the source code and test it if it works ?
@abdeladim-s Thank you for fixing! I tried with the following command and source.
$ pip install git+https://github.com/abdeladim-s/pywhispercpp
$ cat sample.py
from pywhispercpp.model import Model
model = Model('/home/taoki/.local/share/pywhispercpp/models/ggml-large.bin')
segments = model.transcribe('jfk.wav', speed_up=True)
for segment in segments:
print(segment.text)
$ python sample.py
[2023-09-04 10:06:55,314] {model.py:221} INFO - Initializing the model ...
whisper_init_from_file_no_state: loading model from '/home/taoki/.local/share/pywhispercpp/models/ggml-large.bin'
whisper_model_load: loading model
:
[2023-09-04 10:07:52,549] {model.py:133} INFO - Inference time: 54.856 s
And so my fellow Americans, ask not what your country can do for you, ask what you can do for your country.
It looks perfect now. I have pushed a new version to PYPI.
Thanks again @to-aoki for reporting the issue. Let me know if you need any further help.
Hello.
It cannot be initialized from any path as shown below.
The following error will be output.
I think can initialize it by setting the Path object to str. https://github.com/abdeladim-s/pywhispercpp/blob/main/pywhispercpp/model.py#L83