diff --git a/controllable_talknet.py b/controllable_talknet.py index ddfb687..4a5aa01 100644 --- a/controllable_talknet.py +++ b/controllable_talknet.py @@ -24,7 +24,7 @@ from core.download import download_from_drive, download_reconst app = JupyterDash(__name__) -DEVICE = "cuda:0" +DEVICE = "cuda" if torch.cuda.is_available() else "cpu" CPU_PITCH = False RUN_PATH = os.path.dirname(os.path.realpath(__file__)) if RUN_PATH == "/content": diff --git a/core/extract.py b/core/extract.py index 09bb16a..266aa1a 100644 --- a/core/extract.py +++ b/core/extract.py @@ -397,6 +397,7 @@ def _torchcrepe_f0(self, wav_path, hop_length=256): audio_numpy = audio.squeeze(0).numpy() audio_x = np.arange(0, len(audio_numpy)) / 22050.0 + device = "cuda" if torch.cuda.is_available() else "cpu" frequency, confidence = torchcrepe.predict( audio, sr, @@ -407,7 +408,7 @@ def _torchcrepe_f0(self, wav_path, hop_length=256): decoder=torchcrepe.decode.viterbi, return_periodicity=True, batch_size=128, - device="cuda:0", + device=device, ) confidence = torchcrepe.filter.median(confidence, 3) diff --git a/mycroft_talknet.py b/mycroft_talknet.py index d94eb8e..fe4d601 100644 --- a/mycroft_talknet.py +++ b/mycroft_talknet.py @@ -19,7 +19,7 @@ app = Flask(__name__) RUN_PATH = os.path.dirname(os.path.realpath(__file__)) -DEVICE = "cuda:0" +DEVICE = "cuda" if torch.cuda.is_available() else "cpu" def load_hifigan(model_name, conf_name):