Skip to content

Commit

Permalink
Try to make try except more robust for SQL database
Browse files Browse the repository at this point in the history
  • Loading branch information
kalomaze authored Jul 27, 2023
1 parent 4177571 commit deba775
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions infer-web.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@
from vc_infer_pipeline import VC
from sklearn.cluster import MiniBatchKMeans

tmp = os.path.join(now_dir, "TEMP")
shutil.rmtree(tmp, ignore_errors=True)
shutil.rmtree("%s/runtime/Lib/site-packages/infer_pack" % (now_dir), ignore_errors=True)
shutil.rmtree("%s/runtime/Lib/site-packages/uvr5_pack" % (now_dir), ignore_errors=True)
os.makedirs(tmp, exist_ok=True)
os.makedirs(os.path.join(now_dir, "logs"), exist_ok=True)
os.makedirs(os.path.join(now_dir, "audios"), exist_ok=True)
os.makedirs(os.path.join(now_dir, "datasets"), exist_ok=True)
os.makedirs(os.path.join(now_dir, "weights"), exist_ok=True)
os.environ["TEMP"] = tmp
warnings.filterwarnings("ignore")
torch.manual_seed(114514)

import sqlite3

def clear_sql(signal, frame):
Expand Down Expand Up @@ -82,27 +95,17 @@ def clear_sql(signal, frame):
)
""")

tmp = os.path.join(now_dir, "TEMP")
shutil.rmtree(tmp, ignore_errors=True)
shutil.rmtree("%s/runtime/Lib/site-packages/infer_pack" % (now_dir), ignore_errors=True)
shutil.rmtree("%s/runtime/Lib/site-packages/uvr5_pack" % (now_dir), ignore_errors=True)
os.makedirs(tmp, exist_ok=True)
os.makedirs(os.path.join(now_dir, "logs"), exist_ok=True)
os.makedirs(os.path.join(now_dir, "audios"), exist_ok=True)
os.makedirs(os.path.join(now_dir, "datasets"), exist_ok=True)
os.makedirs(os.path.join(now_dir, "weights"), exist_ok=True)
os.environ["TEMP"] = tmp
warnings.filterwarnings("ignore")
torch.manual_seed(114514)

global DoFormant, Quefrency, Timbre


try:
cursor.execute("SELECT Quefrency, Timbre, DoFormant FROM formant_data")
Quefrency, Timbre, DoFormant = cursor.fetchone()
row = cursor.fetchone()
if row is not None:
Quefrency, Timbre, DoFormant = row
else:
raise ValueError("No data")

except Exception:
except (ValueError, TypeError):
Quefrency = 8.0
Timbre = 1.2
DoFormant = False
Expand Down

0 comments on commit deba775

Please sign in to comment.