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

[Bug]: ChunkedArrayBufferStream throws RangeError when targetChunkSize is not an integer #848

Open
rseanhall opened this issue Jul 26, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@rseanhall
Copy link

What happened?

I'm trying to transcribe speech from a WAV file from the npm package of version 1.38.0.

    let sourceFile: File;
    // let user pick the file
    const audioConfig = AudioConfig.fromWavFileInput(sourceFile);
    let speechConfig: SpeechConfig;
    // initialize speechConfig
    const conversationTranscriber = new ConversationTranscriber(speechConfig, audioConfig);
    // subscribe to events in conversationTranscriber
    conversationTranscriber.startTranscribingAsync();

For this specific WAV file, it causes an error:
problemfile.zip

ERROR RangeError: offset is out of bounds

    at Uint8Array.set (<anonymous>)
    at R.writeStreamChunk (ChunkedArrayBufferStream.ts:40:24)
    at j (FileAudioSource.ts:225:24)
    at Y.onload (FileAudioSource.ts:239:21)
    at w.invoke (zone.js:372:26)
    at Object.onInvoke (ng_zone.ts:423:29)
    at w.invoke (zone.js:371:52)
    at j.runGuarded (zone.js:144:47)
    at FileReader.<anonymous> (zone.js:128:29)

After some investigating, the problem seems to be in the ChunkedArrayBufferStream constructor:

public constructor(targetChunkSize: number, streamId?: string) {
super(streamId);
this.privTargetChunkSize = targetChunkSize;
this.privNextBufferReadyBytes = 0;
}

It's getting initialized with the targetChunkSize of 1102.5. This causes problems because it is used to setup byte arrays, which can't have fractional items.

Version

1.36.0 (Latest)

What browser/platform are you seeing the problem on?

Chrome

Relevant log output

logging is not relevant here, the problem is client side
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants