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

Support for streaming inference #20

Open
ojus1 opened this issue Sep 3, 2024 · 1 comment
Open

Support for streaming inference #20

ojus1 opened this issue Sep 3, 2024 · 1 comment

Comments

@ojus1
Copy link

ojus1 commented Sep 3, 2024

Is it possible to use pretrained weights for predicting codes in a chunk-wise fashion (streaming input audio)?

@MrWaterZhou
Copy link

MrWaterZhou commented Nov 12, 2024

Sliding window should be enough
`
def sliding_window(data, window_size=21, step=7):
return [data[i:i + window_size] for i in range(0, len(data) - window_size + 1, step)]

    id_list = sliding_window(output_ids)
    pcm_list = []
    for i, l in enumerate(id_list):
        audio_hat = decode(l)
        if i == 0:
            # first chunk
            pcm_list.append(audio_hat[:, :, :2048 * 2])
        elif i < len(id_list)-1:
            # middle 
            pcm_list.append(audio_hat[:, :, 2048:2048 * 2])
        else:
            # last chunk
            pcm_list.append(audio_hat[:, :, 2048:])
    pcm_list = torch.cat(pcm_list, dim=-1)
    torchaudio.save('stream_test.wav', pcm_list[0].cpu(), 24000)

`

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

2 participants