Skip to content

❓ Question: How to load RAW audio instead of only WAV? #261

Answered by adamnsandle
hobojoe asked this question in Q&A
Discussion options

You must be logged in to vote

I was able to load your example using the following code:

import soundfile as sf
wav, sr = sf.read('files/01b084d5-e5e3-4348-b14e-beee32cb6909.raw', samplerate=8000, channels=1, subtype='ALAW', dtype='float32')
wav = torch.tensor(wav)

Then you can use VAD model to process this chunk.
For example:

## just probabilities

speech_probs = []
window_size_samples = 256
for i in range(0, len(wav), window_size_samples):
    chunk = wav[i: i+window_size_samples]
    if len(chunk) < window_size_samples:
        break
    speech_prob = model(chunk, 8000).item()
    speech_probs.append(speech_prob)
model.reset_states() # reset model states after each audio

print(speech_probs[:10]) # first 10 chunks p…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by snakers4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
help wanted Extra attention is needed
2 participants
Converted from issue

This discussion was converted from issue #257 on October 31, 2022 03:32.