# test_app.py # Simple testing script for Whisper Spaces App # This script verifies imports, model loading, and WAV conversion. import os import tempfile from pydub import AudioSegment import whisper print("TEST: Starting basic tests...") # 1. Test Whisper model loading try: model = whisper.load_model("small") print("TEST: Whisper model loaded ✔️") except Exception as e: print("TEST FAIL: Whisper model load error:", e) # 2. Test creating a dummy WAV file try: tmp = tempfile.NamedTemporaryFile(suffix=".wav", delete=False) tmp_path = tmp.name tmp.close() # Generate 1 second of silence AudioSegment.silent(duration=1000).export(tmp_path, format="wav") if os.path.exists(tmp_path) and os.path.getsize(tmp_path) > 100: print("TEST: WAV generation ✔️ ->", tmp_path) else: print("TEST FAIL: WAV file too small or missing.") except Exception as e: print("TEST FAIL: WAV generation error:", e) # 3. Test transcription on the silent audio try: result = model.transcribe(tmp_path) print("TEST: Transcription output ✔️ ->", result.get("text")) except Exception as e: print("TEST FAIL: Transcription error:", e) print("TEST: Completed.")