47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""
|
||
|
|
Audio cleaning operations using DeepFilterNet or FFmpeg fallback.
|
||
|
|
"""
|
||
|
|
|
||
|
|
import json
|
||
|
|
import sys
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
# Add backend to path
|
||
|
|
sys.path.insert(0, str(Path(__file__).parent))
|
||
|
|
|
||
|
|
from services.audio_cleaner import clean_audio, is_deepfilter_available
|
||
|
|
|
||
|
|
|
||
|
|
def main():
|
||
|
|
if len(sys.argv) < 2:
|
||
|
|
print("Usage: python audio_cleaner.py <command> [args...]", file=sys.stderr)
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
command = sys.argv[1]
|
||
|
|
|
||
|
|
try:
|
||
|
|
if command == "clean_audio":
|
||
|
|
if len(sys.argv) != 4:
|
||
|
|
print("Usage: python audio_cleaner.py clean_audio <input_path> <output_path>", file=sys.stderr)
|
||
|
|
sys.exit(1)
|
||
|
|
input_path = sys.argv[2]
|
||
|
|
output_path = sys.argv[3]
|
||
|
|
result = clean_audio(input_path, output_path)
|
||
|
|
print(json.dumps({"output_path": result}))
|
||
|
|
|
||
|
|
elif command == "is_deepfilter_available":
|
||
|
|
result = is_deepfilter_available()
|
||
|
|
print(json.dumps({"available": result}))
|
||
|
|
|
||
|
|
else:
|
||
|
|
print(f"Unknown command: {command}", file=sys.stderr)
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
except Exception as e:
|
||
|
|
print(json.dumps({"error": str(e)}), file=sys.stderr)
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|