import sys
import os
from pydub import AudioSegment
# speech_recognition removed; debug helper disabled


def debug_transcribe(path):
    print(f"File: {path}")
    if not os.path.exists(path):
        print("File not found")
        return
    print(f"Size: {os.path.getsize(path)} bytes")

    print("speech_recognition not available in this environment.")
    return

    # Convert to wav if needed
    if not path.endswith('.wav'):
        try:
            audio = AudioSegment.from_file(path)
            wav_path = path.rsplit('.', 1)[0] + '_debug.wav'
            audio.export(wav_path, format='wav')
            path = wav_path
            print(f"Converted to: {path}")
        except Exception as e:
            print(f"Conversion failed: {e}")
            return

    # local transcription code removed

    # Try show_all
    try:
        raw = recognizer.recognize_google(audio_data, language='en-US', show_all=True)
        print('raw (show_all):')
        print(str(raw)[:1000])
    except Exception as e:
        print(f"show_all failed: {e}")
        raw = None

    # Try simple
    try:
        text = recognizer.recognize_google(audio_data, language='en-US')
        print('simple text:')
        print(text)
    except Exception as e:
        print(f"simple call failed: {e}")


if __name__ == '__main__':
    if len(sys.argv) < 2:
        print('Usage: python scripts/transcribe_debug.py <audio_path>')
        sys.exit(1)
    debug_transcribe(sys.argv[1])
