You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some reason when i try create a context, the whole thread stops with:
Exception in thread "main" java.lang.UnsatisfiedLinkError: 'int io.github.givimad.whisperjni.WhisperJNI.init(java.lang.String)'
at io.github.givimad.whisperjni.WhisperJNI.init(Native Method)
at io.github.givimad.whisperjni.WhisperJNI.init(WhisperJNI.java:51)
at org.echoai.Main.main(Main.java:49)
Here is my current code:
public class Main {
public static WhisperContext whisperContext;
public static File tempModel;
public static WhisperJNI whisper;
public static WhisperFullParams whisperFullParams;
public static void main(String[] args) throws InterruptedException {
loadWhisperLibrary();
whisper = new WhisperJNI();
try {
// Load the model as a stream
InputStream modelStream = Main.class.getClassLoader().getResourceAsStream("ggml-base.en.bin");
if (modelStream == null) {
throw new IllegalArgumentException("Model file not found!");
}
// Create a temporary file to copy the model into
tempModel = File.createTempFile("whisper-model", ".bin");
tempModel.deleteOnExit(); // Ensure the file is deleted when the program exits
try (OutputStream out = new FileOutputStream(tempModel)) {
// Copy the model from the resource stream to the temporary file
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = modelStream.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead);
}
}
log.info(tempModel.getAbsolutePath());
whisperContext = whisper.init(Path.of(tempModel.getAbsolutePath()));
whisperFullParams = new WhisperFullParams();
} catch (IOException e) {
throw new RuntimeException("Failed to load Whisper model", e);
}
}
This would mean that JNI is unable to find the native method implementations in the .dll file. But i do not see any issue with it.
I have the .dll and my .jar from here: https://github.com/ggerganov/whisper.cpp/actions/runs/6703965523
Specifically: win32-x86-64_whisper.dll & whispercpp.jar
The dll is placed here: src/main/resources/whisper.dll
and the . jar files are here:
C:\Users\Losokos\IdeaProjects\EchoAI\libs\whispercpp-1.4.0.jar
C:\Users\Losokos\IdeaProjects\EchoAI\libs\whispercpp-1.4.0-javadoc.jar
C:\Users\Losokos\IdeaProjects\EchoAI\libs\whispercpp-1.4.0-sources.jar
I have used this method to load the whisper.dll
public static void loadWhisperLibrary() {
try {
// Get the .dll as an input stream
InputStream in = LibraryLoader.class.getResourceAsStream("/whisper.dll");
if (in == null) {
throw new FileNotFoundException("whisper.dll not found in resources.");
}
// Create a temporary file to copy the .dll
File tempDll = File.createTempFile("whisper", ".dll");
// Ensure the file is deleted on exit
tempDll.deleteOnExit();
// Copy the .dll to the temporary file
try (OutputStream out = new FileOutputStream(tempDll)) {
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = in.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead);
}
}
// Load the .dll from the temporary file
System.load(tempDll.getAbsolutePath());
log.info(".dll loaded {}", tempDll.exists());
} catch (IOException e) {
throw new RuntimeException("Failed to load the native library", e);
}
}
and included the .jar's in gradle implementation fileTree(dir: 'libs', include: ['*.jar'])
I have also added the .jar's in the project structure -> Libraries in IntelliJ IDEA
Please help me out, i am literally dying to finally get this working. ThanQ!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
For some reason when i try create a context, the whole thread stops with:
Here is my current code:
This would mean that JNI is unable to find the native method implementations in the .dll file. But i do not see any issue with it.
I have the .dll and my .jar from here: https://github.com/ggerganov/whisper.cpp/actions/runs/6703965523
Specifically: win32-x86-64_whisper.dll & whispercpp.jar
The dll is placed here: src/main/resources/whisper.dll
and the . jar files are here:
C:\Users\Losokos\IdeaProjects\EchoAI\libs\whispercpp-1.4.0.jar
C:\Users\Losokos\IdeaProjects\EchoAI\libs\whispercpp-1.4.0-javadoc.jar
C:\Users\Losokos\IdeaProjects\EchoAI\libs\whispercpp-1.4.0-sources.jar
I have used this method to load the whisper.dll
and included the .jar's in gradle
implementation fileTree(dir: 'libs', include: ['*.jar'])
I have also added the .jar's in the project structure -> Libraries in IntelliJ IDEA
Please help me out, i am literally dying to finally get this working. ThanQ!
Beta Was this translation helpful? Give feedback.
All reactions