Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Refactors the JS live audio transcription sample to make streaming output cleaner and to make microphone audio ingestion more resilient to short event-loop stalls (aligning behavior more closely with the existing C# sample pattern).
Changes:
- Adjust transcription printing to skip empty partials and treat
is_finalas a marker (not a stop condition). - Increase PortAudio chunk size / queue depth to reduce callback frequency and overflow risk.
- Replace “drop-while-backpressured” audio appends with a bounded async append queue and a pump loop.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const pcm = new Uint8Array(buffer); | ||
| appendPending = true; | ||
| session.append(pcm).then(() => { | ||
| appendPending = false; | ||
| }).catch((err) => { | ||
| appendPending = false; | ||
| console.error('append error:', err.message); | ||
| }); | ||
| const copy = new Uint8Array(pcm.length); | ||
| copy.set(pcm); |
There was a problem hiding this comment.
In the audio data handler you’re copying the PCM buffer twice (new Uint8Array(buffer) already copies when buffer is a Node Buffer/TypedArray, and then you allocate/copy again into copy). This adds avoidable work on a hot path and can increase overflow risk under load. Consider doing a single copy into the queued Uint8Array (or creating a view + one explicit copy if you need to detach from a reused native buffer).
No description provided.