Skip to content

Commit f726113

Browse files
authored
Split download into two functions
1 parent 70b90d2 commit f726113

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

controllable_talknet.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import time
2222
import uuid
2323
from core import extract, vocoder, reconstruct
24-
from core.download import download_from_drive
24+
from core.download import download_from_drive, download_reconst
2525

2626
app = JupyterDash(__name__)
2727
DEVICE = "cuda:0"
@@ -781,6 +781,14 @@ def generate_audio(
781781

782782
# Reconstruction
783783
if "srec" in pitch_options:
784+
load_error = download_reconst(RUN_PATH)
785+
if load_error is not None:
786+
return [
787+
None,
788+
load_error,
789+
playback_hide,
790+
None,
791+
]
784792
new_spect = reconstruct_inst.reconstruct(spect)
785793
if rec_voc is None:
786794
rec_voc = vocoder.HiFiGAN(

core/download.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@ def download_from_drive(model, custom_model, run_path):
5757
if not os.path.exists(sr_path):
5858
raise Exception("Super-res model failed to download!")
5959

60+
return (
61+
None,
62+
os.path.join(run_path, "models", drive_id, "TalkNetSpect.nemo"),
63+
os.path.join(run_path, "models", drive_id, "hifiganmodel"),
64+
)
65+
except Exception as e:
66+
return (str(e), None, None)
67+
68+
69+
def download_reconst(run_path):
70+
try:
71+
d = "https://drive.google.com/uc?id="
72+
6073
# Download VQGAN reconstruction model
6174
rec_path = os.path.join(
6275
run_path,
@@ -83,10 +96,6 @@ def download_from_drive(model, custom_model, run_path):
8396
if not os.path.exists(rec_path):
8497
raise Exception("Reconstruction HiFi-GAN failed to download!")
8598

86-
return (
87-
None,
88-
os.path.join(run_path, "models", drive_id, "TalkNetSpect.nemo"),
89-
os.path.join(run_path, "models", drive_id, "hifiganmodel"),
90-
)
99+
return None
91100
except Exception as e:
92-
return (str(e), None, None)
101+
return str(e)

0 commit comments

Comments
 (0)