-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added arguments to detect_test.py so arguments can be passed directly
- Loading branch information
1 parent
66368a5
commit e1bef1d
Showing
3 changed files
with
48 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,42 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
import json | ||
import sys | ||
from icad_tone_detection import tone_detect | ||
|
||
if len(sys.argv) > 1: | ||
audio_path = sys.argv[1] | ||
else: | ||
print("Requires a audio path provided. Either file path, or URL.") | ||
exit(0) | ||
|
||
detect_result = tone_detect(audio_path, matching_threshold=1.5, time_resolution_ms=50, debug=True) | ||
def main(): | ||
parser = argparse.ArgumentParser(description='Run tone detection on an audio file.') | ||
parser.add_argument('audio_path', type=str, help='Path to the audio file') | ||
parser.add_argument('-t', '--matching_threshold', type=float, default=2.5, help='Matching threshold percentage') | ||
parser.add_argument('-r', '--time_resolution_ms', type=int, default=25, help='Time resolution in ms') | ||
parser.add_argument('-a', '--tone_a_min_length', type=float, default=0.7, help='Min length of tone A in seconds') | ||
parser.add_argument('-b', '--tone_b_min_length', type=float, default=2.7, help='Min length of tone B in seconds') | ||
parser.add_argument('-i', '--hi_low_interval', type=float, default=0.2, | ||
help='Max interval between hi-low tones in seconds') | ||
parser.add_argument('-n', '--hi_low_min_alternations', type=int, default=6, | ||
help='Min number of hi-low alternations') | ||
parser.add_argument('-l', '--long_tone_min_length', type=float, default=3.8, | ||
help='Min length of a long tone in seconds') | ||
parser.add_argument('-d', '--debug', action='store_true', help='Enable debug mode') | ||
|
||
data_dict = {"two_tone": detect_result.two_tone_result, "long_tone": detect_result.long_result, "hl_tone": detect_result.hi_low_result} | ||
args = parser.parse_args() | ||
|
||
print(json.dumps(data_dict)) | ||
detect_result = tone_detect( | ||
audio_path=args.audio_path, | ||
matching_threshold=args.matching_threshold, | ||
time_resolution_ms=args.time_resolution_ms, | ||
tone_a_min_length=args.tone_a_min_length, | ||
tone_b_min_length=args.tone_b_min_length, | ||
hi_low_interval=args.hi_low_interval, | ||
hi_low_min_alternations=args.hi_low_min_alternations, | ||
long_tone_min_length=args.long_tone_min_length, | ||
debug=args.debug | ||
) | ||
|
||
data_dict = {"two_tone": detect_result.two_tone_result, "long_tone": detect_result.long_result, | ||
"hl_tone": detect_result.hi_low_result} | ||
|
||
print(json.dumps(data_dict)) | ||
|
||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "icad_tone_detection" | ||
version = "1.3" | ||
version = "1.4" | ||
authors = [ | ||
{name = "TheGreatCodeholio", email = "[email protected]"}, | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters