File size: 2,348 Bytes
552ebb8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/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")