Mozer / wav2lip_extension

21 stars 5 forks source link

problem with paths on Linux #2

Closed ostr00000 closed 6 months ago

ostr00000 commented 6 months ago

OS: Linux (Ubuntu 23.10)

I have problem with this code: https://github.com/Mozer/wav2lip/blob/28a36d58c1497b1ccc2c23286343ab7777e03cce/wav2lip_module.py#L233 https://github.com/Mozer/wav2lip/blob/28a36d58c1497b1ccc2c23286343ab7777e03cce/server_wav2lip.py#L74 https://github.com/Mozer/wav2lip/blob/28a36d58c1497b1ccc2c23286343ab7777e03cce/server_wav2lip.py#L76 (It is possible that there may be more error like this)

It looks like there is used a windows specific path, because the model is successfully downloaded to [...]/SillyTavern-extras/modules/wav2lip\checkpoints/wav2lip.pth. I propose to wrap this in os.path.join. And pass each of the arguments separately to this function (this is variadic function, so it accepts any number of arguments).

I would also suggest to use pathlib module instead of os.path - this is less error-prone, and have more readable interface (this is my opinion only).

Mozer commented 6 months ago

What error message is it showing? It can't find the path? Is it because the wrong slash in the path?

ostr00000 commented 6 months ago

In code, I have referenced, there is no Python error. The error shows later when this file is going to be accessed. This is because of incorrectly computed path.

The char \ is used inside string. This works on Windows - the char is interpreted as a folder separator. But on Linux this is a totally valid filename, so there is created a folder with name wav2lip\checkpoints.

https://docs.python.org/3/library/os.html?highlight=os.sep#os.sep

Mozer commented 6 months ago

I updated https://github.com/Mozer/wav2lip, removed those back slashes and wrapped in os.path.join. Please check if it works now, maybe I missed something.

ostr00000 commented 6 months ago

I have reviewed these changes and it looks good. I believe that trailing "" (empty string) is not necessary, because flask function send-from-directory do not care about it (it is actually passed again to os.path.join), but let it stay for now.