Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VAD usage issue, provided sample is incorrect #283

Closed
RevanthRameshkumar opened this issue Jul 3, 2024 · 2 comments
Closed

VAD usage issue, provided sample is incorrect #283

RevanthRameshkumar opened this issue Jul 3, 2024 · 2 comments

Comments

@RevanthRameshkumar
Copy link

Hi there, I'm getting this error when using the VAD module:
Provided number of samples is 320 (Supported values: 256 for 8000 sample rate, 512 for 16000)

here is my little demo code. The sample rate is 8000 with 1 channel

    wav = wave.open(r'demo-instruct.wav', "rb")
    total_frames = wav.getnframes()
    sample_rate = wav.getframerate()
    num_channels = wav.getnchannels()
    print(sample_rate)
    print(num_channels)

    vad_analyzer = SileroVADAnalyzer(
        sample_rate=sample_rate, params=VADParams())

    sent_frames = 0

    while sent_frames < total_frames:
        # Read 100ms worth of audio frames.
        frames = wav.readframes(128)
        audio_data = np.frombuffer(frames, dtype=np.int16)

        # Convert back to bytes
        frames_to_send = audio_data.tobytes()
        if len(frames_to_send) > 0:
            sent_frames += len(frames_to_send)
            new_vad_state = vad_analyzer.analyze_audio(frames_to_send)
            print(new_vad_state)

Any ideas on this? The program itself doesn't raise an error...it is something inside silero itself that is printing the error but not actually raising:

Traceback of TorchScript, original code (most recent call last):
  File "/home/keras/notebook/nvme1/adamnsandle/silero-models-research/vad/model/vad_annotator.py", line 484, in forward
        num_samples = 512 if sr == 16000 else 256
        if x.shape[-1] != num_samples:
            raise ValueError(f"Provided number of samples is {x.shape[-1]} (Supported values: 256 for 8000 sample rate, 512 for 16000)")
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    
        batch_size = x.shape[0]
builtins.ValueError: Provided number of samples is 320 (Supported values: 256 for 8000 sample rate, 512 for 16000)
@RevanthRameshkumar
Copy link
Author

Here is an example frame that it will fail on:

b'\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x01\x00\xff\xff\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\xff\xff\x00\x00\x01\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\xff\xff\x01\x00\x00\x00\xff\xff\x01\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x01\x00\x00\x00\xff\xff\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\xff\xff\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\xfe\xff\x00\x00\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\xff\xff\x00\x00\x00\x00\x00\x00'

@RevanthRameshkumar
Copy link
Author

fixed! Going to the latest version fixed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant