import soundfile as sf import torch DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu") CUDA_AVAILABLE = DEVICE.type == "cuda" TORCH_DTYPE = torch.float16 if CUDA_AVAILABLE else torch.float32 print(f"Using device: {DEVICE}") if CUDA_AVAILABLE: print(f"CUDA device: {torch.cuda.get_device_name(DEVICE)}") def getAudioDuration(filePath: str) -> float: try: data, samplerate = sf.read(filePath) duration = len(data) / samplerate return duration except Exception as e: print(f"Error getting audio duration: {e}") return 0.0