From c91189d181552c923103caccc3b4988cbcc8e99a Mon Sep 17 00:00:00 2001 From: sanj <67624670+iodrift@users.noreply.github.com> Date: Tue, 11 Feb 2025 14:35:32 -0800 Subject: [PATCH] Auto-update: Tue Feb 11 14:35:32 PST 2025 --- mlx | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100755 mlx diff --git a/mlx b/mlx deleted file mode 100755 index 1f822c5..0000000 --- a/mlx +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import os -import sys -import tempfile -import subprocess -from lightning_whisper_mlx import LightningWhisperMLX - -def convert_to_mp3(input_path): - """Convert input file to MP3 using ffmpeg if necessary, storing in a temporary directory.""" - if input_path.lower().endswith(".mp3"): - return input_path # No conversion needed - - temp_dir = tempfile.mkdtemp() - output_path = os.path.join(temp_dir, "converted.mp3") - - try: - subprocess.run(["ffmpeg", "-y", "-i", input_path, "-q:a", "2", output_path], - check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - except subprocess.CalledProcessError: - sys.exit("Error: Failed to convert file to MP3. Ensure ffmpeg is installed.") - - return output_path - -def main(): - parser = argparse.ArgumentParser(description="Transcribe or translate audio using LightningWhisperMLX.") - parser.add_argument("file", help="Path to the audio file.") - parser.add_argument("--translate", action="store_true", help="Enable translation mode.") - - args = parser.parse_args() - - audio_path = convert_to_mp3(args.file) - - # Selecting a valid model - whisper = LightningWhisperMLX(model="large-v3", batch_size=12, quant=None) - - if args.translate: - print("Translation mode enabled.") - result = whisper.transcribe(audio_path=audio_path, language="en") # Explicitly setting language to English - else: - result = whisper.transcribe(audio_path=audio_path) - - print(result['text']) - -if __name__ == "__main__": - main() -