Hacker News new | ask | show | jobs
by hamza_q_ 15 days ago
Investigated this and it turned out to be an amusing bug: audio decoding was happening three times instead of just once lol. I've put up a PR to remove the wasteful redundant decoding:

https://github.com/FluidInference/FluidAudio/pull/799

With the updated PR code, ran a test comparing transcribing (using Parakeet V3) a 1 hr stereo 44.1 kHz mp3 vs the same audio in 16 kHz mono wav format. The result was about 21.3% slower with the mp3 vs the wav, i.e. that's the overhead of decoding + resampling.

Currently the decoding + resampling is done up front. If it was done in a pipelined fashion with the inference, that overhead can be eliminated. This is what I did in a recent app I made:

https://apps.apple.com/us/app/drea-podcast-ad-blocker/id6759...

It uses FluidAudio as well, but I forked it and replaced the audio decoding code to (a) use mpg123 instead of the native Apple API and (b) do audio decoding and inference in a pipelined fashion. These two changes effectively eliminated the overhead. mpg123 is quite a bit faster than the native Apple API at mp3 decoding (has some very optimized arm64 assembly routines), and the pipelining ensures that the inference is never starved by the mp3 decoding.

Contributing this pipelined setup to FluidAudio would be good.

2 comments

Thanks!

I use fluidaudiocli and it's unfortunate that it doesn't support streaming (e.g. from a named pipe); that would have been an easy workaround to both the pipelining problem and the faster-decoder problem.

Yep, agreed, streaming would be great to have. Although via pipes I think is better suited for a macOS. Since FluidAudio has to support both macOS and iOS, I think using Swift concurrency primitives would be the better fit. That's what I did for my app (TaskGroup, actor, AsyncSequence).
That app was exactly what I was looking for, something like SponsorBlock but for podcasts but I suppose using AI for finding the ads works too. Any chance it'll release on Android?
Yep it's something I wanted for a while too; there were existing apps that did this, but had two issues: they were paid, and the UI was subpar. So for mine, I made sure it's fully free and that the UI is on par with Apple Podcasts, Spotify, etc.

Making the ad-finding cheap enough such that I could make it free turned out to be harder than expected. The main issue you run into is dynamic, location-targeted ads. So I came up with a novel technique that uses Shazam-style audio fingerprints for accurate matching, instead of their normal use case, which is identification. This technique is what allows the ad finding to be very cheap, allowing me to make it free.

The SponsorBlock model would actually not work for podcasts, due to dynamic ads. I.e. the location and content of the ads in episodes these days varies by download location. You need the media to be static, like YouTube, for SponsorBlock model to work. Therefore, using an LLM to find the ads + the fingerprints matching in combination is an efficient technique.

Android has def been the most requested thing thus far haha. It'll be a decent undertaking due to me having written the app fully in Swift, i.e. it'll be a complete rewrite. I'll also need to replace FluidAudio with some good, fast Android equivalent.

The goal of making this app was to create something impressive so that I could get a job. Haven't gotten a job yet, but if and when I do, then I'll have time & resources to think about doing an Android version. Currently a bit stressed and occupied from the job search lol.

Could you speak more on the Shazam style part? Don't you need a database of all ads to figure out if some snippet is an ad or not? That's how Shazam works for songs at least.

A native implementation I had thought of was running the audio through a STT LLM that then detects the ad timestamps then returns that to the UI to block.

Yeah that's what I do (STT -> LLM -> timestamps to block), but if you did that for every episode download, due to location-targeted dynamic ads, your LLM API bill would run up very fast. So that's where the fingerprints matching comes in, for further versions of an episode (version = same episode but with different dynamic ads inside).

I explained how the full system works here (someone emailed me and asked): https://pastebin.com/raw/r2YUEkK5