Skip to content

Commit

Permalink
Merge pull request #158 from deiteris/settings-fix
Browse files Browse the repository at this point in the history
Show which pretrain file failed to download on error
  • Loading branch information
deiteris authored Jul 30, 2024
2 parents d212a9a + bd8b5f9 commit 1050680
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- [Running the voice changer](#running-the-voice-changer-1)
- [Running on Colab/Kaggle](#running-on-colabkaggle)
- [Troubleshooting](#troubleshooting)
- [Exceptions.WeightDownloadException: 'Failed to download weight.'](#exceptionsweightdownloadexception-failed-to-download-weight)
- [Exceptions.PretrainDownloadException: 'Failed to download weight.'](#exceptionspretraindownloadexception-failed-to-download-weight)
- [Audio devices are not displayed](#audio-devices-are-not-displayed)
- [No sound after start](#no-sound-after-start)
- [Hearing non-converted voice](#hearing-non-converted-voice)
Expand Down Expand Up @@ -239,13 +239,13 @@ Refer to corresponding [Colab](https://github.com/deiteris/voice-changer/blob/ma
> [!TIP]
> When any issue with the voice changer occurs, check the command line window (the one that opens during the start) for errors.
### Exceptions.WeightDownloadException: 'Failed to download weight.'
### Exceptions.PretrainDownloadException: 'Failed to download weight.'

Either the remote files have changed or your files were corrupted. The error will show which files are affected above the error:

```
[Voice Changer] 'pretrain/content_vec_500.onnx failed to pass hash verification check. Got 1931e237626b80d65ae44cbacd4a5197, expected ab288ca5b540a4a15909a40edf875d1e'
[Voice Changer] 'pretrain/rmvpe.onnx failed to pass hash verification check. Got 65030149d579a65f15aa7e85769c32f1, expected b6979bf69503f8ec48c135000028a7b0'
[WeightDownloader] 'pretrain/content_vec_500.onnx failed to pass hash verification check. Got 1931e237626b80d65ae44cbacd4a5197, expected ab288ca5b540a4a15909a40edf875d1e'
[WeightDownloader] 'pretrain/rmvpe.onnx failed to pass hash verification check. Got 65030149d579a65f15aa7e85769c32f1, expected b6979bf69503f8ec48c135000028a7b0'
```

Find and delete the mentioned files from the voice changer folder and restart the voice changer. Deleted files will be re-downloaded.
Expand Down
4 changes: 2 additions & 2 deletions server/Exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ def __str__(self):
return repr("Voice Changer is not selected.")


class WeightDownloadException(Exception):
class PretrainDownloadException(Exception):
def __str__(self):
return repr("Failed to download weight.")
return repr("Failed to download pretrain models.")

class DownloadVerificationException(Exception):
def __init__(self, filename: str, got_hash: str, expected_hash: str) -> None:
Expand Down
7 changes: 4 additions & 3 deletions server/downloader/WeightDownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from downloader.Downloader import download
import logging
from settings import ServerSettings
from Exceptions import WeightDownloadException
from Exceptions import PretrainDownloadException

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -79,11 +79,12 @@ async def downloadWeight(params: ServerSettings):
for file in files_to_download:
tasks.append(asyncio.ensure_future(download(file)))
fail = False
for res in await asyncio.gather(*tasks, return_exceptions=True):
for i, res in enumerate(await asyncio.gather(*tasks, return_exceptions=True)):
if isinstance(res, Exception):
logger.error(f'Failed to download or verify {files_to_download[i]["saveTo"]}')
fail = True
logger.exception(res)
if fail:
raise WeightDownloadException()
raise PretrainDownloadException()

logger.info('All weights are loaded!')

0 comments on commit 1050680

Please sign in to comment.