111 lines
2.3 KiB
Python
Executable File
111 lines
2.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
"""
|
|
sndid
|
|
|
|
Copyright 2022, 2023, Joe Weiss <joe.weiss@gmail.com>
|
|
Copyright 2023, Jeff Moe <moe@spacecruft.org>
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
|
|
https://joeweiss.github.io/birdnetlib/getting-started/
|
|
"""
|
|
|
|
|
|
from birdnetlib import Recording
|
|
from birdnetlib.analyzer import Analyzer
|
|
from datetime import datetime
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser(description="Run sndid")
|
|
parser.add_argument(
|
|
"-i",
|
|
"--input",
|
|
help="Input filename to process (default samples/sample.wav)",
|
|
type=str,
|
|
required=False,
|
|
default="samples/sample.wav",
|
|
)
|
|
parser.add_argument(
|
|
"-t",
|
|
"--latitude",
|
|
help="Latitude (default 40.57)",
|
|
type=str,
|
|
required=False,
|
|
default="40.57",
|
|
)
|
|
parser.add_argument(
|
|
"-n",
|
|
"--longitude",
|
|
help="Longitude (default -105.23)",
|
|
type=str,
|
|
required=False,
|
|
default="-105.23",
|
|
)
|
|
# XXX set to NOW for default.
|
|
parser.add_argument(
|
|
"-y",
|
|
"--year",
|
|
help="Year (default 2023)",
|
|
type=int,
|
|
required=False,
|
|
default="2023",
|
|
)
|
|
parser.add_argument(
|
|
"-m",
|
|
"--month",
|
|
help="Month (default 9)",
|
|
type=int,
|
|
required=False,
|
|
default="9",
|
|
)
|
|
parser.add_argument(
|
|
"-d",
|
|
"--day",
|
|
help="Day (default 19)",
|
|
type=int,
|
|
required=False,
|
|
default="19",
|
|
)
|
|
parser.add_argument(
|
|
"-c",
|
|
"--confidence",
|
|
help="Minimum Confidence (default 0.50)",
|
|
type=float,
|
|
required=False,
|
|
default="0.50",
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
INFILE = args.input
|
|
LAT = args.latitude
|
|
LON = args.longitude
|
|
YEAR = args.year
|
|
MONTH = args.month
|
|
DAY = args.day
|
|
CONFIDENCE = args.confidence
|
|
|
|
# Load and initialize the BirdNET-Analyzer models.
|
|
analyzer = Analyzer()
|
|
|
|
recording = Recording(
|
|
analyzer,
|
|
INFILE,
|
|
lat=LAT,
|
|
lon=LON,
|
|
date=datetime(year=YEAR, month=MONTH, day=DAY),
|
|
min_conf=CONFIDENCE,
|
|
)
|
|
recording.analyze()
|
|
print(recording.detections)
|