Skip to content

Commit

Permalink
Merge pull request #71 from alexlnkp/pr-optimization
Browse files Browse the repository at this point in the history
Optimize various parts of inference/training + requirement fixes
  • Loading branch information
kalomaze committed Aug 1, 2023
2 parents bf0ffdb + 0b2f3fc commit 3b78d58
Show file tree
Hide file tree
Showing 9 changed files with 1,058 additions and 1,840 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# 8/1 Changelog
- Completely rewrote the code for `infer-web.py` to be more optimized.
- Added minor optimizations in `my_utils.py`, as well as a new function to gauge if a file is long enough to train with (0.76s)
- Due to optimization, inferencing seems to be decently faster, while training seems to be marginally faster.
- The launch speed is increased due to lazy importing heavy modules and libraries.
- Requirements.txt builds properly on non-windows again + plus fixed a versioning conflict with protobuf

# 7/28 Changelog:
- Undo SQL change for the sake of stability, uses csv now
- Merging checkpoints bug has been resolved
- Merging checkpoints bug has been resolved.
- Revoked from using **SQL** databases back to **CSV** data storage for less trouble on colab.

# 7/26 Changelog:
- Fixed the cli inferencing traceback.
Expand All @@ -21,7 +28,7 @@
- Unnecessary radios have been replaced with checkboxes.

# 7/22 Changelog:
- Experimental Formant Shift using StftPitchShift(tried using praat with praatio but to no avail)
- Experimental Formant Shift using StftPitchShift (tried using praat with praatio but to no avail)
- Added `Stop Training` button when training, no need to restart RVC every time you want to stop the training of a model!
- Auto-detect Index path for models selected + Auto-detect paths, no more default values like this: `E:\codes\py39\vits_vc_gpu_train\logs\mi-test-1key\total_fea.npy`, We're getting Root Dir and subfolders using
```python
Expand Down Expand Up @@ -272,7 +279,7 @@ You are currently in 'INFER':
arg 12) feature index ratio: 0.78 (0-1)
arg 13) Voiceless Consonant Protection (Less Artifact): 0.33 (Smaller number = more protection. 0.50 means Dont Use.)
Example: mi-test.pth saudio/Sidney.wav myTest.wav logs/mi-test/added_index.index 0 -2 harvest 160 3 0 1 0.95 0.33
Example: mi-test.pth saudio/Sidney.wav myTest.wav logs/mi-test/added_index.index 0 -2 harvest 160 3 0 1 0.95 0.33 0.45 True 8.0 1.2
INFER: <INSERT ARGUMENTS HERE OR COPY AND PASTE THE EXAMPLE>
```
Expand Down
1 change: 1 addition & 0 deletions csvdb/formanting.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
False,8.0,1.2
1 change: 1 addition & 0 deletions csvdb/stop.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
False
43 changes: 29 additions & 14 deletions i18n.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
import locale
import json
import os


def load_language_list(language):
with open(f"./i18n/{language}.json", "r", encoding="utf-8") as f:
language_list = json.load(f)
return language_list
try:
with open(f"./i18n/{language}.json", "r", encoding="utf-8") as f:
return json.load(f)
except FileNotFoundError:
raise FileNotFoundError(
f"Failed to load language file for {language}. Check if the correct .json file exists."
)


class I18nAuto:
"""
A class used for internationalization using JSON language files.
Examples
--------
>>> i18n = I18nAuto('en_US')
>>> i18n.print()
Using Language: en_US
"""
def __init__(self, language=None):
if language in ["Auto", None]:
language = locale.getdefaultlocale()[
0
] # getlocale can't identify the system's language ((None, None))
if not os.path.exists(f"./i18n/{language}.json"):
from locale import getdefaultlocale
language = language or getdefaultlocale()[0]
if not self._language_exists(language):
language = "en_US"
self.language = language
# print("Use Language:", language)

self.language_map = load_language_list(language)
self.language = language

@staticmethod
def _language_exists(language):
from os.path import exists
return exists(f"./i18n/{language}.json")

def __call__(self, key):
"""Returns the translation of the given key if it exists, else returns the key itself."""
return self.language_map.get(key, key)

def print(self):
print("Use Language:", self.language)
"""Prints the language currently in use."""
print(f"Using Language: {self.language}")
Loading

0 comments on commit 3b78d58

Please sign in to comment.