B4J Question Help Converting .aar files to .arr.jar

MrKim

Well-Known Member
Licensed User
Longtime User
I am trying to convert THIS Speech to text Project to B4XPages (specifically for me B4J). The B4A version is working just fine.
I tried copying the Speech to text libraries from B4A libs to B4J libs but it fails with:
B4X:
Cannot find: C:\Program Files\Anywhere Software\B4J\libraries\vosk-android-0.3.47.aar.jar
and
B4X:
Cannot find: C:\Program Files\Anywhere Software\B4J\libraries\jna-5.13.0.aar.jar
I understand it is possible to convert .arr files to .jar and I did that using the instructions HERE. It did create files as advertised but they don't work.
The compile works but fails on this line:
B4X:
Sub Class_Globals
    Private STT As SpeechToText
With the following error:
B4X:
WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing
Waiting for debugger to connect...
Program started.
Error occurred on line: 11 (B4XMainPage)
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at b4j.example.b4xmainpage.innerInitialize(b4xmainpage.java:21)
    at b4j.example.b4xmainpage._initialize(b4xmainpage.java:377)
    at b4j.example.b4xpagesmanager._initialize(b4xpagesmanager.java:110)
    at b4j.example.main._appstart(main.java:85)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at b4j.example.main.start(main.java:38)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.NoClassDefFoundError: org/vosk/android/RecognitionListener
    at b4j.example.b4xmainpage._class_globals(b4xmainpage.java:124)
    ... 32 more
Caused by: java.lang.ClassNotFoundException: org.vosk.android.RecognitionListener
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 33 more
I honestly don't know if this is even possible but I would like to have windows stand alone STT for security reasons.
Any help appreciated.
 

MrKim

Well-Known Member
Licensed User
Longtime User
?? Where doe it comes from?

B4X:
    Private vosk As VoskInit
    Private voskRecognizer As VoskRecognizer

these are the only ones in the example i uploaded.
It comes from the B4A example I am trying to get to work in B4J. Perhaps you uploaded the wrong example?
The lines you mention are not in the example you uploaded (VoskAPI.zip). If contains:
B4X:
#AdditionalJar: jna-5.14.0
#AdditionalJar: jna-platform-5.14.0
#AdditionalJar: vosk-0.3.45
In main and B4XMainpage is just the Default "Hello World". Since there was no other code I thought you wanted me to add those lines to the Code in the B4X project which I am trying to convert. That project does contain
B4X:
Private STT As SpeechToText

Thanks for your time helping with this.
 
Upvote 0
Top