From 54ca55558775c43b72c768f6360c996b58629b9a Mon Sep 17 00:00:00 2001 From: Kavi Date: Thu, 27 Feb 2025 13:51:58 +0100 Subject: [PATCH] Fixed code to support Python3.9 syntax --- batdetect2/api.py | 4 ++-- batdetect2/utils/audio_utils.py | 2 +- batdetect2/utils/detector_utils.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/batdetect2/api.py b/batdetect2/api.py index 8978b63..da2d106 100644 --- a/batdetect2/api.py +++ b/batdetect2/api.py @@ -250,7 +250,7 @@ def process_file( model: DetectionModel = MODEL, config: Optional[ProcessingConfiguration] = None, device: torch.device = DEVICE, - file_id: str | None = None + file_id: Optional[str] = None ) -> du.RunResults: """Process audio file with model. @@ -286,7 +286,7 @@ def process_url( model: DetectionModel = MODEL, config: Optional[ProcessingConfiguration] = None, device: torch.device = DEVICE, - file_id: str | None = None + file_id: Optional[str] = None ) -> du.RunResults: """Process audio file with model. diff --git a/batdetect2/utils/audio_utils.py b/batdetect2/utils/audio_utils.py index 66714f0..134fee7 100644 --- a/batdetect2/utils/audio_utils.py +++ b/batdetect2/utils/audio_utils.py @@ -185,7 +185,7 @@ def load_audio_data( target_samp_rate: int, scale: bool = False, max_duration: Optional[float] = None, -) -> Tuple[int, np.ndarray, int | float]: +) -> Tuple[int, np.ndarray, Union[float, int]]: """Load an audio file and resample it to the target sampling rate. The audio is also scaled to [-1, 1] and clipped to the maximum duration. diff --git a/batdetect2/utils/detector_utils.py b/batdetect2/utils/detector_utils.py index ffbcf6e..f6e5776 100644 --- a/batdetect2/utils/detector_utils.py +++ b/batdetect2/utils/detector_utils.py @@ -742,7 +742,7 @@ def process_file( model: DetectionModel, config: ProcessingConfiguration, device: torch.device, - file_id: str | None = None + file_id: Optional[str] = None ) -> Union[RunResults, Any]: """Process a single audio file with detection model.