#!/usr/bin/env python3 """Simple transcription script using faster-whisper directly.""" import time from pathlib import Path from faster_whisper import WhisperModel def main(): """Transcribe the BAP South meeting recording using faster-whisper directly.""" audio_file = Path("BAP_South_Meeting_Clean.wav") if not audio_file.exists(): print(f"āŒ Audio file not found: {audio_file}") return print(f"šŸŽµ Transcribing: {audio_file.name}") print(f"šŸ“ File size: {audio_file.stat().st_size / (1024*1024):.1f} MB") try: print("šŸš€ Loading Whisper model (distil-large-v3)...") start_time = time.time() # Load the model directly model = WhisperModel( "distil-large-v3", device="cpu", compute_type="int8_float32" ) model_load_time = time.time() - start_time print(f"āœ… Model loaded in {model_load_time:.1f} seconds") print("šŸŽÆ Starting transcription...") transcription_start = time.time() # Transcribe the audio segments, info = model.transcribe( str(audio_file), language=None, # Auto-detect temperature=0.0, # Deterministic beam_size=1, best_of=1 ) # Convert generator to list and extract text segments_list = list(segments) full_text = " ".join([seg.text for seg in segments_list]) transcription_time = time.time() - transcription_start total_time = time.time() - start_time print("āœ… Transcription completed!") print(f"šŸ“ Text length: {len(full_text)} characters") print(f"ā±ļø Transcription time: {transcription_time:.1f} seconds") print(f"ā±ļø Total time (including model load): {total_time:.1f} seconds") print(f"šŸŽÆ Language detected: {info.language}") print(f"šŸ“Š Segments: {len(segments_list)}") # Save to text file output_file = Path("BAP_South_Meeting_Transcript.txt") with open(output_file, "w", encoding="utf-8") as f: f.write(f"BAP South Meeting - August 28, 2025\n") f.write(f"Transcription completed at: {time.strftime('%Y-%m-%d %H:%M:%S')}\n") f.write(f"Model: distil-large-v3\n") f.write(f"Language: {info.language}\n") f.write(f"Transcription time: {transcription_time:.1f} seconds\n") f.write(f"Total time: {total_time:.1f} seconds\n") f.write(f"Segments: {len(segments_list)}\n") f.write("=" * 80 + "\n\n") f.write(full_text) print(f"šŸ’¾ Transcript saved to: {output_file}") # Also save as JSON for detailed analysis import json json_output = { "text": full_text, "segments": [ { "start": seg.start, "end": seg.end, "text": seg.text, "avg_logprob": seg.avg_logprob, "no_speech_prob": seg.no_speech_prob } for seg in segments_list ], "info": { "language": info.language, "language_probability": info.language_probability, "all_language_probs": info.all_language_probs }, "processing_time": transcription_time, "total_time": total_time, "model": "distil-large-v3", "segments_count": len(segments_list) } json_file = Path("BAP_South_Meeting_Transcript.json") with open(json_file, "w", encoding="utf-8") as f: json.dump(json_output, f, indent=2, ensure_ascii=False) print(f"šŸ“Š Detailed data saved to: {json_file}") # Show first few segments as preview print(f"\nšŸ“‹ Preview (first 3 segments):") for i, seg in enumerate(segments_list[:3]): print(f" {i+1}. [{seg.start:.1f}s - {seg.end:.1f}s] {seg.text}") if len(segments_list) > 3: print(f" ... and {len(segments_list) - 3} more segments") except Exception as e: print(f"āŒ Transcription failed: {e}") import traceback traceback.print_exc() if __name__ == "__main__": main()