Add command line options to sndid
parent
006d863936
commit
d164987264
80
sndid
80
sndid
|
@ -25,18 +25,86 @@ https://joeweiss.github.io/birdnetlib/getting-started/
|
||||||
from birdnetlib import Recording
|
from birdnetlib import Recording
|
||||||
from birdnetlib.analyzer import Analyzer
|
from birdnetlib.analyzer import Analyzer
|
||||||
from datetime import datetime
|
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.
|
# Load and initialize the BirdNET-Analyzer models.
|
||||||
analyzer = Analyzer()
|
analyzer = Analyzer()
|
||||||
|
|
||||||
recording = Recording(
|
recording = Recording(
|
||||||
analyzer,
|
analyzer,
|
||||||
"samples/sample.wav",
|
INFILE,
|
||||||
lat=40.0,
|
lat=LAT,
|
||||||
lon=-105.0,
|
lon=LON,
|
||||||
date=datetime(year=2023, month=9, day=21),
|
date=datetime(year=YEAR, month=MONTH, day=DAY),
|
||||||
min_conf=0.50,
|
min_conf=CONFIDENCE,
|
||||||
)
|
)
|
||||||
recording.analyze()
|
recording.analyze()
|
||||||
print(recording.detections)
|
print(recording.detections)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue