argmaxinc / WhisperKit

On-device Speech Recognition for Apple Silicon
https://takeargmax.com/blog/whisperkit
MIT License
3.17k stars 268 forks source link

Fix crash with mic device sample rate mismatch #69

Closed ZachNagengast closed 6 months ago

ZachNagengast commented 6 months ago

Previously the inputNode was using the sample rate based on the hardware that the app was running on. When selecting a microphone that is connected to the device but has a different hardware sample rate, there was a crash occuring:

required condition is false: format.sampleRate == hwFormat.sampleRate

This updates that code to always use the correct sample rate for the selected microphone.

Note: This PR also includes some minor fixes for the example app and tests