Skip to content

A lightweight yet powerful audio-to-MIDI converter with pitch bend detection

use cuda with onnx if available

Nathan Rawb7e349dd132a
diff --git a/basic_pitch/inference.py b/basic_pitch/inference.py
index 2544cd9..25b062c 100644
--- a/basic_pitch/inference.py
+++ b/basic_pitch/inference.py
@@ -129,7 +129,10 @@ class Model:
present.append("ONNX")
try:
self.model_type = Model.MODEL_TYPES.ONNX
- self.model = ort.InferenceSession(str(model_path), providers=["CPUExecutionProvider"])
+ providers = ["CPUExecutionProvider"]
+ if "CUDAExecutionProvider" in ort.get_available_providers():
+ providers.insert(0, "CUDAExecutionProvider")
+ self.model = ort.InferenceSession(str(model_path), providers=providers)
return
except Exception as e:
if str(model_path).endswith(".onnx"):