samirkumardas/pcm-player

1 second pause when playing

Aroxed opened this issue · 0 comments

Aroxed commented

Hi guys.
I'm trying to play PCM audio received via Web sockets.
Everything is cool except playing is occurring after a 1-second delay. Every time I speak at the server microphone, a 1-second delay occurs before the PCMPlayer plays it.
I tried to investigate the source code but didn't find a solution.
Also, I am convinced that the server side sends sound data accurately.
Could you help me to find a workaround?

Let me show you the code of my player class:
initPlayer() {
this.player = new PCMPlayer({
encoding: '16bitInt',
channels: 1,
sampleRate: 8000,
flushingTime: 100 // 1, 400, 1000 tested, no effect
});
}

play(data) { // data retrieved from WebSockets
    const dataArray = new Uint8Array(data);
    if (this.player) {
        this.player.feed(dataArray);

    }
}