#!/usr/bin/env python3 """ Quick test script to verify everything works before full demo """ import numpy as np import gradio as gr print("๐Ÿงช Testing core libraries...") try: import torch print("โœ… PyTorch:", torch.__version__) except ImportError as e: print("โŒ PyTorch:", e) try: import librosa print("โœ… Librosa:", librosa.__version__ if hasattr(librosa, '__version__') else "OK") # Test librosa functionality y = np.random.randn(1000).astype(np.float32) mfcc = librosa.feature.mfcc(y=y, sr=16000, n_mfcc=1) stft = librosa.stft(y) print("โœ… Librosa functions working") except ImportError as e: print("โŒ Librosa import:", e) except Exception as e: print("โŒ Librosa functions:", e) try: import numba print("โœ… Numba:", numba.__version__) except ImportError as e: print("โŒ Numba:", e) print("\n๐ŸŽค Testing Silero-VAD...") try: model, utils = torch.hub.load(repo_or_dir='snakers4/silero-vad', model='silero_vad', force_reload=False) # Test with correct chunk size test_audio = torch.randn(1, 512) # Correct size for 16kHz with torch.no_grad(): result = model(test_audio, 16000) print(f"โœ… Silero-VAD working: {result.item():.3f}") except Exception as e: print(f"โŒ Silero-VAD error: {e}") print("\n๐ŸŽจ Testing Gradio...") try: def dummy_function(audio): if audio is not None: return "Audio received!", np.random.random() return "No audio", 0.0 interface = gr.Interface( fn=dummy_function, inputs=gr.Audio(sources=["microphone"], type="numpy"), outputs=[gr.Textbox(), gr.Number()], title="Quick Test" ) print("โœ… Gradio interface created") # Launch for quick test print("\n๐Ÿš€ Launching test interface on http://127.0.0.1:7860") print(" Test microphone, then close and run full demo") interface.launch( server_name="127.0.0.1", server_port=7860, show_error=True, quiet=False ) except Exception as e: print(f"โŒ Gradio error: {e}") print("\n๐ŸŽฏ If everything above shows โœ…, run: python app.py")