Add WAV file support with MP3 conversion and reuse
- Add support for WAV files with automatic conversion to MP3 - Save converted MP3 files in the same directory as WAV files - Reuse existing MP3 files if already converted - Update documentation and requirements
This commit is contained in:
@@ -4,7 +4,7 @@ import os
|
||||
from tqdm import tqdm
|
||||
|
||||
from src.cli import parse_args
|
||||
from src.utils import find_audio_files, ensure_directory_exists
|
||||
from src.utils import find_audio_files, ensure_directory_exists, convert_wav_to_mp3
|
||||
from src.transcriber import transcribe_audio
|
||||
from src.enhancer import enhance_note
|
||||
|
||||
@@ -27,7 +27,7 @@ def main():
|
||||
base_name = os.path.splitext(os.path.basename(audio_path))[0]
|
||||
txt_path = os.path.join(output_dir, base_name + ".txt")
|
||||
md_path = os.path.join(output_dir, base_name + ".md")
|
||||
|
||||
|
||||
# Skip if enhanced note already exists (unless force flag is set)
|
||||
if os.path.exists(md_path) and not args.force:
|
||||
print(f"Skipping {audio_path} - enhanced note already exists at {md_path}")
|
||||
@@ -39,9 +39,20 @@ def main():
|
||||
with open(txt_path, "r", encoding="utf-8") as f:
|
||||
transcription = f.read()
|
||||
else:
|
||||
# Convert WAV to MP3 if needed
|
||||
path_to_transcribe = audio_path
|
||||
|
||||
if audio_path.lower().endswith(".wav"):
|
||||
print(f"Processing WAV file: {audio_path}")
|
||||
mp3_path = convert_wav_to_mp3(audio_path)
|
||||
if mp3_path:
|
||||
path_to_transcribe = mp3_path
|
||||
else:
|
||||
print(f"Warning: Failed to convert {audio_path}. Will attempt to transcribe the WAV file directly.")
|
||||
|
||||
# Transcribe audio
|
||||
transcription = transcribe_audio(
|
||||
audio_path,
|
||||
path_to_transcribe,
|
||||
txt_path,
|
||||
model_size=model_size,
|
||||
turbo=args.turbo
|
||||
|
||||
Reference in New Issue
Block a user