Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model class is not supporting relative paths to files #4

Closed
guschin opened this issue Mar 22, 2023 · 4 comments
Closed

Model class is not supporting relative paths to files #4

guschin opened this issue Mar 22, 2023 · 4 comments

Comments

@guschin
Copy link

guschin commented Mar 22, 2023

I'm experimenting with your library, and I've noticed that the Model class is not supporting relative paths to files. Here is the traceback.

In [5]: asr_result = model.transcribe("../../audio1470766962.wav")
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[5], line 1
----> 1 asr_result = model.transcribe("../../audio1470766962.wav")

File ~/whisper/lib/python3.10/site-packages/pywhispercpp/model.py:118, in Model.transcribe(self, media, n_processors, new_segment_callback, **params)
    116     media_path = Path(media).absolute()
    117     if not media_path.exists():
--> 118         raise FileNotFoundError(media)
    119     audio = self._load_audio(media_path)
    120 # update params if any

FileNotFoundError: ../../audio1470766962.wav

I assume this is because of the using absolute method from pathlib. If I'm reading the documentation correctly, using resolve method instead of absoulte will resolve (pun intended) the issue 🙂

Here is the example

In [3]: pathlib.Path('../audio1470766962.wav').absolute()
Out[3]: PosixPath('/Users/guschin/whisper/../audio1470766962.wav')

In [4]: pathlib.Path('../audio1470766962.wav').resolve()
Out[4]: PosixPath('/Users/guschin/audio1470766962.wav')

Would you consider this change, please? I can send you a PR.

@absadiki
Copy link
Owner

Yes Sure, PR is more than welcome 😄
Thanks @guschin for pointing that out.

absadiki added a commit that referenced this issue Mar 24, 2023
@absadiki
Copy link
Owner

hi @guschin,
I have resolved the issue by using resolve as you suggested 🙂

Please give it a try and let me know if the problem persists ?

@guschin
Copy link
Author

guschin commented Mar 28, 2023

Yes, now it works as expected! Thanks for the swift response and for the great library you developed 😀

@guschin guschin closed this as completed Mar 28, 2023
@absadiki
Copy link
Owner

You are welcome @guschin
'Glad you find it useful 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants