Add command-line interface for Urdu Intent Extractor
This commit is contained in:
parent
b4f224796d
commit
329222934f
60
main.py
Normal file
60
main.py
Normal file
@ -0,0 +1,60 @@
|
||||
import argparse
|
||||
from helpers.audio_analysis import UrduIntentExtractor
|
||||
|
||||
def main():
|
||||
"""
|
||||
Command-line interface for Urdu Intent Extractor
|
||||
"""
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Extract intent from Urdu speech using Whisper translation"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"audio_file",
|
||||
help="Path to audio file (mp3, wav, m4a, flac, etc.)"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--model",
|
||||
default="base",
|
||||
choices=["base", "medium", "large-v1", "large-v2", "large-v3"],
|
||||
help="Whisper model size (default: base)"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--output",
|
||||
help="Save results to JSON file"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--quiet",
|
||||
action="store_true",
|
||||
help="Minimal output"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
# Initialize extractor
|
||||
extractor = UrduIntentExtractor(model_size=args.model)
|
||||
|
||||
# Process audio file
|
||||
results = extractor.process_audio_file(
|
||||
args.audio_file,
|
||||
verbose=not args.quiet
|
||||
)
|
||||
|
||||
# Save to JSON if requested
|
||||
if args.output:
|
||||
import json
|
||||
with open(args.output, 'w', encoding='utf-8') as f:
|
||||
json.dump(results, f, ensure_ascii=False, indent=2)
|
||||
print(f"\nResults saved to: {args.output}")
|
||||
|
||||
except FileNotFoundError as e:
|
||||
print(f"❌ Error: {e}")
|
||||
except Exception as e:
|
||||
print(f"❌ An error occurred: {str(e)}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
x
Reference in New Issue
Block a user