How to reference and utilize the Java binding for whisper.cpp in Clojure?

Hello everyone! I’m trying to use the Java binding for whisper.cpp in my Clojure project. Could someone please guide me on how to properly reference and utilize the binding? Any help or pointers would be greatly appreciated. Thank you!

1 Like

Same way as with every other Java class:

(ns some.ns
  (:import (io.github.ggerganov.whispercpp WhisperCpp)))

(defn -main [& _]
  (let [whisper (WhisperCpp.)]
    ...))

It’s just regular Java interop - Clojure is completely agnostic of the fact that it’s a wrapper for a native library.
You do have to do some preparations before you can use the library, but those are exactly the same as the ones you have to do for plain Java and they’re described in the README of that wrapper.
One other thing is that, given that you’ll have a local JAR, you’ll have to add that JAR to the classpath of your Clojure process. If you’re using deps.edn, it’s documented here.

Thank you very much for your response and guidance. I am not very familiar with Java integration, but I have reviewed the documentation. I will give it another try and see how it goes!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.