Live data from Hacker News

Show HN: Port of OpenAI's Whisper model in C/C++

github.com

71–80 of 93 posts

Re: Show HN: Port of OpenAI's Whisper model in C/C++

#71
Works well on my old Intel 2020 Macbook Pro. Having no dependencies meant I was able to just clone the repo and build (as long as you have the C++ tooling). There's something magical about how simple it is without having to jump through hoops getting your dependencies resolved.

Re: Show HN: Port of OpenAI's Whisper model in C/C++

#72

There is no language called "C/C++". If, to use it, you need C++, it's a C++ system, period. If parts are in C, that is an implementation detail, and is furthermore pointless; modernizing those to C++ would make them more robust and probably faster. Using C anywhere just makes it as bug-prone in those parts as C code everywhere is.

> If, to use it, you need C++, it's a C++ system, period. If parts are in C, that is an implementation detail

C and C++ are different languages, you can't necessarily treat a codebase of mixed C and C++ as if it were written entirely in C++.

This isn't purely academic, either. For a long time the MSVC compiler had pretty good C++ language support but surprisingly poor C support, which inconvenienced some folks.

> modernizing those to C++ would make them more robust and probably faster

I agree that adopting C++'s insistence on explicit type conversions is a good move for C codebases. I'd be surprised if performance were improved by reworking a C codebase to get it to compile as C++, though.

Re: Show HN: Port of OpenAI's Whisper model in C/C++

#73

This is really awesome, great work! I downloaded a long video from YouTube that is very challenging to transcribe (it is an interview with Hayek, who was both very soft spoken and had a thick German accent) because I wanted to evaluate OpenAI’s claims about whisper being “superhuman” in recognition. It was a bit picky about having the audio in the exact right format (it needs to be 16kHz wav files— would be really ni…

Btw, there is the `yt-wsp.sh` helper script to download, convert and transcribe a video by given url: ./examples/yt-wsp.sh

I actually couldn't get the script to work-- it keeps complaining that it can't find the Whisper executable. Do you know what I would have to do first to get it to work starting from a "blank slate" and cloning the repo? Thanks!

Re: Show HN: Port of OpenAI's Whisper model in C/C++

#75

There is no language called "C/C++". If, to use it, you need C++, it's a C++ system, period. If parts are in C, that is an implementation detail, and is furthermore pointless; modernizing those to C++ would make them more robust and probably faster. Using C anywhere just makes it as bug-prone in those parts as C code everywhere is.

> If, to use it, you need C++, it's a C++ system, period. If parts are in C, that is an implementation detail C and C++ are different languages, you can't necessarily treat a codebase of mixed C and C++ as if it were written entirely in C++. This isn't purely academic, either. For a long time the MSVC compiler had pretty good C++ language support but surprisingly poor C support, which inconvenienced some folks. > mod…

You can, in fact, compile the C code with a C++ compiler, given trivial adjustments. Adopting "explicit type conversions" would have similarly trivial results. The benefits would come from leaning into higher-level organization.

C++ code going faster than the C is routine. It doesn't come without activity, but the activity yields a more maintainable system, so is commonly done.

MSVC's C compiler only recognized C90. It was generally easier to make your C99 code compile as C++ than to backport it to C90.

Re: Show HN: Port of OpenAI's Whisper model in C/C++

#76

This is really cool, and I have been meaning to get my hands dirty with Whisper I looks like you’ve definitely maximized the parallelization on the CPU/AMX here, but have you tried getting it to run on the GPU or the Neural Engine? I love the portability, but I feel like you would get a massive parallelization boost while dramatically cutting energy consumption.

I did some experiments with adding Metal Performance Shaders support, but the performance that I achieved was only marginally better compared to the one I get when using just the Accelerate framework (there is an unmerged PR with the tests). Honestly, I am bit confused with all the different types of processing units available on Apple Silicon. If I understand correctly, we have: CPU, GPU, AMX coprocessor and Neural…

I suggest looking into Halide as it will make trying different paths much easier (https://halide-lang.org/).

I haven't looked at your code closely so can't say with certainty it would be the right fit but worth a look.

Re: Show HN: Port of OpenAI's Whisper model in C/C++

#77

There is no language called "C/C++". If, to use it, you need C++, it's a C++ system, period. If parts are in C, that is an implementation detail, and is furthermore pointless; modernizing those to C++ would make them more robust and probably faster. Using C anywhere just makes it as bug-prone in those parts as C code everywhere is.

> There is no language called "C/C++".

He clearly means that he used two languages: C and C++.

"I decided to reimplement the inference of the model from scratch using C/C++. To achieve this I implemented a minimalistic tensor library in C and ported the high-level architecture of the model in C++."

Re: Show HN: Port of OpenAI's Whisper model in C/C++

#78

There is no language called "C/C++". If, to use it, you need C++, it's a C++ system, period. If parts are in C, that is an implementation detail, and is furthermore pointless; modernizing those to C++ would make them more robust and probably faster. Using C anywhere just makes it as bug-prone in those parts as C code everywhere is.

>There is no language called "C/C++".

Yes there is.

Take the union of C and C++ which is valid syntax (and same semantics) in both languages, voila; C/C++.

Re: Show HN: Port of OpenAI's Whisper model in C/C++

#79

Earlier quoted context omitted.

Btw, there is the `yt-wsp.sh` helper script to download, convert and transcribe a video by given url: ./examples/yt-wsp.sh

I actually couldn't get the script to work-- it keeps complaining that it can't find the Whisper executable. Do you know what I would have to do first to get it to work starting from a "blank slate" and cloning the repo? Thanks!

It's trying to run `WHISPER_EXECUTABLE` which it defaults to `whisper` - but if you follow the instructions in the README, you end up with `main`.

    WHISPER_EXECUTABLE=main examples/yt-wsp.sh youtube_url
Or the script itself prints out a handy hint.

    Whisper needs to be built into the main binary with make, then you can rename it to something like 'whisper' and add it to your PATH for convenience.

Re: Show HN: Port of OpenAI's Whisper model in C/C++

#80
post #78

There is no language called "C/C++". If, to use it, you need C++, it's a C++ system, period. If parts are in C, that is an implementation detail, and is furthermore pointless; modernizing those to C++ would make them more robust and probably faster. Using C anywhere just makes it as bug-prone in those parts as C code everywhere is.

>There is no language called "C/C++". Yes there is. Take the union of C and C++ which is valid syntax (and same semantics) in both languages, voila; C/C++.

But it is not, in fact, written in such a "language". Nothing is.
Post reply on HN