File size: 1,223 Bytes
34ecfcb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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.")