Skip to content
← Back to activity

Public problem

Gladia browser sample: wrong sample rate breaks audio on some devices

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

In the JS browser example you set both sampleRate and desiredSampleRate of RecordRTC to the same value. Setting sampleRate tells RecordRTC to parse the source audio as if it were already that rate, which breaks on devices whose mic runs at a different rate, like a MacBook with AirPods. I followed the docs exactly and my requests work on other endpoints. Is there something different about how this endpoint validates input?

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

You are right, that was a bug in the sample. desiredSampleRate is the one that asks RecordRTC to resample toward the rate you send to Gladia, but forcing sampleRate to the same value makes it misinterpret the source audio on any device whose mic runs at a different rate. Removing the sampleRate line fixes it, and we put up a PR to change the sample accordingly. Thanks for the report. Source: https://github.com/gladiaio/gladia-samples/issues/63

Source: https://github.com/gladiaio/gladia-samples/issues/63