Skip to content

Commit ea13674

Browse files
committed
make confidence optional
1 parent ee3c07d commit ea13674

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/arduino/app_bricks/audio_classification/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def stop(self):
6868
super().stop()
6969

7070
@staticmethod
71-
def classify_from_file(audio_path: str, confidence: int) -> dict | None:
71+
def classify_from_file(audio_path: str, confidence: float = 0.8) -> dict | None:
7272
"""Classify audio content from a WAV file.
7373
7474
Supported sample widths:
@@ -79,9 +79,8 @@ def classify_from_file(audio_path: str, confidence: int) -> dict | None:
7979
8080
Args:
8181
audio_path (str): Path to the `.wav` audio file to classify.
82-
confidence (int, optional): Confidence threshold (0–1). If None,
83-
the default confidence level specified during initialization
84-
will be applied.
82+
confidence (float, optional): Minimum confidence threshold (0.0–1.0) required
83+
for a detection to be considered valid. Defaults to 0.8 (80%).
8584
8685
Returns:
8786
dict | None: A dictionary with keys:
@@ -93,9 +92,6 @@ def classify_from_file(audio_path: str, confidence: int) -> dict | None:
9392
AudioClassificationException: If the file cannot be found, read, or processed.
9493
ValueError: If the file uses an unsupported sample width or if confidence is not specified.
9594
"""
96-
if confidence is None:
97-
raise ValueError("Confidence level must be specified.")
98-
9995
try:
10096
with wave.open(audio_path, "rb") as wf:
10197
# Get WAV file properties

0 commit comments

Comments
 (0)