|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os |
|
|
import tempfile |
|
|
from pydub import AudioSegment |
|
|
import whisper |
|
|
|
|
|
print("TEST: Starting basic tests...") |
|
|
|
|
|
|
|
|
try: |
|
|
model = whisper.load_model("small") |
|
|
print("TEST: Whisper model loaded ✔️") |
|
|
except Exception as e: |
|
|
print("TEST FAIL: Whisper model load error:", e) |
|
|
|
|
|
|
|
|
try: |
|
|
tmp = tempfile.NamedTemporaryFile(suffix=".wav", delete=False) |
|
|
tmp_path = tmp.name |
|
|
tmp.close() |
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
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.") |