Spaces:
Paused
Paused
CrispStrobe commited on
Commit ·
eabe081
1
Parent(s): 7027f5a
Fix CrispASR runtime loading and improve import robustness
Browse files
app.py
CHANGED
|
@@ -68,12 +68,28 @@ except Exception as e:
|
|
| 68 |
logging.error(f"Unexpected error during setup: {str(e)}")
|
| 69 |
sys.exit(1)
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
from faster_whisper import WhisperModel
|
| 75 |
from faster_whisper.transcribe import BatchedInferencePipeline
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
# Check for CUDA availability
|
| 79 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 68 |
logging.error(f"Unexpected error during setup: {str(e)}")
|
| 69 |
sys.exit(1)
|
| 70 |
|
| 71 |
+
# Set up paths for CrispASR
|
| 72 |
+
crispasr_path = os.path.abspath("./CrispASR")
|
| 73 |
+
sys.path.append(os.path.join(crispasr_path, "python"))
|
| 74 |
+
|
| 75 |
+
# Add built libraries to LD_LIBRARY_PATH for runtime loading
|
| 76 |
+
build_lib_paths = [
|
| 77 |
+
os.path.join(crispasr_path, "build/src"),
|
| 78 |
+
os.path.join(crispasr_path, "build/ggml/src")
|
| 79 |
+
]
|
| 80 |
+
current_ld_path = os.environ.get("LD_LIBRARY_PATH", "")
|
| 81 |
+
os.environ["LD_LIBRARY_PATH"] = ":".join(build_lib_paths + [current_ld_path])
|
| 82 |
|
| 83 |
from faster_whisper import WhisperModel
|
| 84 |
from faster_whisper.transcribe import BatchedInferencePipeline
|
| 85 |
+
|
| 86 |
+
try:
|
| 87 |
+
import crispasr
|
| 88 |
+
logging.info("CrispASR imported successfully")
|
| 89 |
+
except ImportError as e:
|
| 90 |
+
logging.error(f"Failed to import crispasr: {e}")
|
| 91 |
+
# We don't exit here to allow other backends to work,
|
| 92 |
+
# but the UI will show error if crispasr is picked.
|
| 93 |
|
| 94 |
# Check for CUDA availability
|
| 95 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|