Introducing ChatGPT and Whisper APIs
Wow not a single mention of Whisper this entire comment first page! I think Whisper is really cool: the large model can pull speech out of even heavily distorted (wind noise, clipping, etc) audio. I have a story to illustrate why running Whisper on your own locally is not so easy! Much easier to sign up to the OpenAI API.<p>In my research I found that actually pre-processing the audio to reduce noise (using the IMO best-in-class FB research &quot;denoiser&quot;) actually increases WER. This was surprising! From a human perspective, I assumed bringing up the &quot;signal&quot; would increase accuracy. But it seems that, from a machine perspective, there&#x27;s actually &quot;information&quot; to be gleaned from the heavily distorted noise part of the signal. To me, this is <i>amazing</i> because it reveals a difference in how machines vs humans process. The implication is that there is actually <i>speech signal</i> that is inside the noise, as if voice has bounced off and interacted with the noise source (wind, fan, etc), and altered those sounds, left its impression, and that this information is then able to be utilized and contributes to the inference. Incredible!<p>With whisper: I started with the standard python models. They&#x27;re kind of slow. I tried compiling python into a single binary using various tools. That didn&#x27;t work. Then I found whisper.cpp--fantastic! A port of whisper to C++ that is <i>so; much; faster</i>. Mind blowing speed! Plus easily compilation. My use case was including transcription in a private, offline &quot;transcribe anything&quot; MacOS app. Whisper.cpp was the way to go.<p>Then I encountered another problem. What the &quot;Whisperists&quot; (experts in this nascent field, I guess) call it &quot;hallucination&quot;. The model will &quot;hallucinate&quot;. I found this hilarious! Another cross-over of human-machine conceptual models, our forever anthropomorphizing everything effortlessly. :)<p>Basically hallucination includes: feed Whisper a long period of silence, and the model is so desperate to find speech, it will infer (overfit? hallucinate?) speech out of the random background signal of silence &#x2F; analog silence &#x2F; background noise. Normally this presents as a loop of repeats of previous accurate transcribed phrase. Or, with smaller models, some &quot;end-of-youtube video&quot; common phrases like &quot;Thank You!&quot; or even &quot;Thanks for Watching&quot;. I even got (from one particularly heavily distorted section, completely inaccurate) &quot;Don&#x27;t forget to like and subscribe!&quot; Haha. But the larger models produce less hallucinations, and less generic &quot;oh-so-that&#x27;s-what-your-dataset-was!&quot; hallucinations. But they do still hallucinate. Especially during silent sections.<p>At first, I tried using ffmpeg to chop the audio into small segments, ideally partitioned on silences. Unfortunately ffmpeg can only chop it into regular size segments, but it can output silence intervals, and you can chop around that (but not &quot;online&quot; &#x2F; real time) as I was trying to achieve. Removing the silent segments (even the imperfect metric of &quot;some %&quot; of average output signal magnitude (sorry for my terminology, I&#x27;m not expert in DSP&#x2F;audio)) <i>drastically</i> improved Whisper performance. Suddenly it went from hallucinating during silent segments, to perfect transcripts.<p>The other problem with silent segments is the model gets stuck. It gets &quot;locked up&quot; (spinning beach ball, blue screen of death style--I don&#x27;t think it actually dies, but it spends <i>a long</i>, disproportionately long, time on segments with no speech. Like I said before, it&#x27;s so cute that it&#x27;s so desperate to find speech everywhere, it tries really hard, and works its little legs of during silence, but to no avail.<p>Anyway, moving on to the next problem: the imperfect metric of silence. This caused many issues. We were chopping out quieter speech. We were including loud background noise. Both these things caused issues: the first obvious, the second, the same as we faced before: Whisper (or Whisper.cpp) would hallucinate text into these noise segments.<p>At last, I discovered something truly great! VAD. Voice Activity Detection is another (normally) AI technique that allows segmenting audio around voice segments. I tried a couple Python implementations in standard speech toolkits, but none were that good. Then I found Silero VAD: an MIT licensed (for some model versions), AI VAD model. Wonderful!<p>Next problem was it was also in Python. And I needed it to be in C++. Luckily there was a C++ example, using ONNX runtime. (I had no idea any of these projects or tools existed mere weeks ago, and suddenly I&#x27;m knee deep!). There were a few errors, but I got rid of the bugs, and had a little command line tool from a minimal C++ build of ONNXruntime &#x2F; Protobuf-Lite and the model. Last step was the ONNX model needed to be converted to ORT format. Luckily there&#x27;s a handy Python script to do this inside the Python release of ONNXruntime. And, now, the VAD was super fast.<p>So i put all these pieces together: ffmpeg, VAD, whisper.cpp and made a MacOS app (with the correct signing and entitlements of course!) to transcribe English text from any input format: audio or video. Pretty cool, right?<p>Anyway, running Whisper on your own locally is not so easy!  Much easier to sign up to the OpenAI API.<p>MacOS APP using Whisper (C++) and VAD0--conveniently called: WisprNote heh :) 
 <a href="https:&#x2F;&#x2F;apps.apple.com&#x2F;app&#x2F;wisprnote&#x2F;id1671480366" rel="nofollow">https:&#x2F;&#x2F;apps.apple.com&#x2F;app&#x2F;wisprnote&#x2F;id1671480366</a>