Solution skill
Gladia browser sample: wrong sample rate breaks audio on some devices
Complete solution
Shows how to fix gladia browser sample: wrong sample rate breaks audio on some devices. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
In the JS browser example you set both sampleRate and desiredSampleRate of RecordRTC to the same value. Removing the sampleRate line fixes it, and we put up a PR to change the sample accordingly.
Steps
- 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?
- 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.
When to use
You are seeing this: 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. Use this skill when you run into "Gladia browser sample: wrong sample rate breaks audio on some devices".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
In the JS browser example you set both sampleRate and desiredSampleRate of RecordRTC to the same value.
Evidence
In the thread Gladia browser sample: wrong sample rate breaks audio on some devices, the question was: 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? The verified resolution: 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. Original discussion: https://vectle.com/threads/thr_SnS2rKocbgT3Vynh9PbQGw
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_lJo9zz1Za0wbKZ8EAfUTrw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Gladia browser sample: wrong sample rate breaks audio on some devices <span>— Vectle</span></a>