whisper.cpp icon indicating copy to clipboard operation
whisper.cpp copied to clipboard

Golang bindings

Open chrisbward opened this issue 2 years ago • 8 comments

Just keen to see these, and I'm now looking how to make this happen - I'm fairly new to this part of Go. Would anyone like to collaborate?

Ideally I'd like to be able to fire off set commands to Whisper and have it trigger actions - a pretty standard affair, but not sure how to begin?

Chris

chrisbward avatar Dec 13 '22 06:12 chrisbward

Ive already made a start on this.. its not pretty, and id call myself "proficient" with go, but I've likely done things that are not best practice.

Take a look, and submit pull requests as you like. Once we have something good enough, ill be submitting back to ggerganov for sure.

https://github.com/jaybinks/whisper.cpp/tree/master/bindings/go_whisper

I should also note, but I bumped in to someone else's effort for whisper.cpp go bindings that seemed fairly advanced. however Im struggling to find that URL right now, ill share it if / when I find it again.

On Tue, 13 Dec 2022 at 16:40, Chris Ward @.***> wrote:

Just keen to see these, and I'm now looking how to make this happen - I'm fairly new to this part of Go. Would anyone like to collaborate?

Ideally I'd like to be able to fire off set commands to Whisper and have it trigger actions - a pretty standard affair, but not sure how to begin?

Chris

— Reply to this email directly, view it on GitHub https://github.com/ggerganov/whisper.cpp/issues/269, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALQR65A4RQTBWQWJFONSTTWNAK65ANCNFSM6AAAAAAS42GCNE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Sincerely

Jay

jaybinks avatar Dec 13 '22 09:12 jaybinks

I created the beginnings of some "golang" bindings here:

https://github.com/djthorpe/go-whisper

Specifically, the "sys/whisper" directory is staight bindings to the function calls in whisper.cpp and a more golang-style interface under "pkg/whisper". All needs a lot more work and some tests however.

djthorpe avatar Dec 13 '22 10:12 djthorpe

Here we go ... thankyou David !! I think yours was the one that I bumped into.

This was the first time id implemented a C library in Go so I wanted to keep playing around with that a bit more, I also wasn't sure just how mature yours was, so I wasn't sure if I wanted to wrap the C Calls in a class (that may or may not have been good for my purpose) or just work directly with the underlying C calls.

Also, if I was being REALLY pedantic ... id probably also call out that your code is pulls in a few other dependencies that id try and minimise (my personal opinion) EG : sdl2, stretchr/testify, djthorpe/go-errors (sdl2 makes sense if its just for the streaming example I guess )

That all being said ... your addition of stream.go and main.go as well as test cases etc etc FAR outweighs anything I've done or contributed, and id suggest we adopt your whisper.cpp go module and contribute to enhancing it !

Are you happy to merge it back in to ggerganov 's repo

On Tue, 13 Dec 2022 at 20:14, David Thorpe @.***> wrote:

I created the beginnings of some "golang" bindings here:

https://github.com/djthorpe/go-whisper

Specifically, the "sys/whisper" directory is staight bindings to the function calls in whisper.cpp and a more golang-style interface under "pkg/whisper". All needs a lot more work and some tests however.

— Reply to this email directly, view it on GitHub https://github.com/ggerganov/whisper.cpp/issues/269#issuecomment-1348127017, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALQR62QVGSD37LASOFONMLWNBD7DANCNFSM6AAAAAAS42GCNE . You are receiving this because you commented.Message ID: @.***>

-- Sincerely

Jay

jaybinks avatar Dec 13 '22 10:12 jaybinks

Well I took a bit of a different approach, but how about this...

I'll clone your repository https://github.com/jaybinks/whisper.cpp and copy in my sys/whisper implementation into there. I'll send you a pull request, and when you're satisfied you can then send a pull request to the original author? I think that way, you can continue to have a say in how these get merged in?

I should have some time over the next week. LMK what you think.

djthorpe avatar Dec 13 '22 10:12 djthorpe

Well done guys! I can assist by helping with testing and writing some quick apps/docs!

chrisbward avatar Dec 15 '22 03:12 chrisbward

Because your repo was so out-of-date @jaybinks I just made a PR directly against Georgi's.

djthorpe avatar Dec 18 '22 10:12 djthorpe

Awesome stuff David.

On Sun, 18 Dec 2022 at 20:39, David Thorpe @.***> wrote:

Because your repo was so out-of-date @jaybinks https://github.com/jaybinks I just made a PR directly against Georgi's.

— Reply to this email directly, view it on GitHub https://github.com/ggerganov/whisper.cpp/issues/269#issuecomment-1356769664, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALQR65B5FTBB5X2SMIOTHDWN3SUJANCNFSM6AAAAAAS42GCNE . You are receiving this because you were mentioned.Message ID: @.***>

-- Sincerely

Jay

jaybinks avatar Dec 18 '22 11:12 jaybinks

@ggerganov probably worth closing this issue now that the go bindings (albeit early version) are merged (thanks!). If you have future issues around the go bindings, feel free to assign me and I will take a look.

djthorpe avatar Dec 20 '22 08:12 djthorpe

I just added a reference to the bindings in the main README.md and created a Github Discussion for future discussions on this topic:

https://github.com/ggerganov/whisper.cpp/discussions/312

Thanks again for the contributions!

ggerganov avatar Dec 22 '22 16:12 ggerganov