Hello, World!
If I added several files in pocketsphinx, how can I compile it for Android?
I don't understand.
P.S. I want to put the compiled project in Unity.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Another thing is that you edited the file with windows editor and introduced windows-style newline in it. The build process didn't respect this change, that's why you have newline in file path here:
[exec] make: *** No rule to make target `../sphinxbase/src/libsphinxbase
/util/errno.c', needed by `obj/local/arm64-v8a/objs/sphinxutil/errno.o'. Stop.
Overall, please make sure you run from a clean checkout
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes. There was not errno.c, because I did incorrectly checkout. Now, it's all right.
How can I add my files in pocketsphinx for Android? I added mymodule.h in pocketsphinx/include and mymodule.c in pocketsphinx/src/libpocketsphinx.
Next, I added "mymodule.c \" in Android.mk on line 139. It's in block:
I presume you do not need java wrapper part for Unity, you can just load library from C#.
Java classes are created with SWIG. In case you still want to access API in java, you need to add interface in SWIG. You can read documentation on SWIG for details.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello.
I began to test the library. It don't work. Unity see the library (.so files), but it cannot find my function. So I have EntryPointNotFoundException.
I have copied files from /pocketsphinx-android/lib/ into Unity.
Last edit: Nikita Furin 2015-05-05
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can check so public symbols with arm-linux-androideabi-nm (part of ndk). It is hard to say why symbols is not exported, maybe you define it as static.
You can share your files if you need help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Binary does not export your functions which means that module is not included into so file. You need to check build process yourself or provide makefile you use.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I changed /pocketsphinx/include/Makefile.am and /pocketsphinx/src/libpocketsphinx and rebuild(ant clean, ant jar) the library.
This did not help, because
cat libpocketsphinx_jni.so | grep mm_f
return nothing, i.e. binary does not export my functions.
Makefile.am is irrelevant here, it is only used on Linux automake-based build. You are building with ndk-build and only Android.mk is relevant.
Your issue is that you included your wrapper into pocketsphinx static library. During build all unused symbols from static libraries are excluded, only functions referenced from "whole" static libraries are kept. You need to add module as LOCAL_WHOLE_STATIC_LIBRARY, not inside pocketsphinx. An example Android.mk is attached.
However, there is another issue. You used ad.h for audio recording which is not supported in android. You need to record audio with Android native framework like openal instead of sphinxad.
Alternatively you can record with C# and then pass audio buffers into pocketsphinx through interop. In that case you will have to modify the wrapper you wrote.
Hello, World!
If I added several files in pocketsphinx, how can I compile it for Android?
I don't understand.
P.S. I want to put the compiled project in Unity.
You can find pocketsphinx-android project in our repository
You can list additional files to add to the library in jni/Android.mk.
Thanks for quick reply!
I'm trying to build, but I'm getting error.
History of my console commands:
You need to set sdk.path in build.properties. Check README file for details.
My build.properties:
It is in /home/nikita/Исходники/pocketsph/pocketsphinx-android
The error persists.
I changed sdk.version from 21.1.1 to 21. This error disappeared, but new error appeared.
Looks like you accidentally deleted errno.c, this file must be there. You can refresh your checkout or start from a clean one.
Another thing is that you edited the file with windows editor and introduced windows-style newline in it. The build process didn't respect this change, that's why you have newline in file path here:
Overall, please make sure you run from a clean checkout
Yes. There was not errno.c, because I did incorrectly checkout. Now, it's all right.
How can I add my files in pocketsphinx for Android? I added mymodule.h in pocketsphinx/include and mymodule.c in pocketsphinx/src/libpocketsphinx.
Next, I added "mymodule.c \" in Android.mk on line 139. It's in block:
Next, I executed
(BUILD SUCCESSFUL)
It, certainly, didn't work. How to make correctly?
You did everything correctly, maybe you need to run "ant clean" to rebuild after makefile change.
But I can not find my functions in build/.
I presume you do not need java wrapper part for Unity, you can just load library from C#.
Java classes are created with SWIG. In case you still want to access API in java, you need to add interface in SWIG. You can read documentation on SWIG for details.
Hello.
I began to test the library. It don't work. Unity see the library (.so files), but it cannot find my function. So I have EntryPointNotFoundException.
I have copied files from /pocketsphinx-android/lib/ into Unity.
Last edit: Nikita Furin 2015-05-05
During compiling the library, mymodule.c is used. So I suppose that mymodule.h make trouble.
You can check so public symbols with arm-linux-androideabi-nm (part of ndk). It is hard to say why symbols is not exported, maybe you define it as static.
You can share your files if you need help.
Yes, I need help.
You need to share other files including so file and C# code.
I attach them.
Binary does not export your functions which means that module is not included into so file. You need to check build process yourself or provide makefile you use.
I just added "mymodule.c \" into Android.mk, as I wrote above.
Should I change files named "Makefile.am"?
I changed /pocketsphinx/include/Makefile.am and /pocketsphinx/src/libpocketsphinx and rebuild(ant clean, ant jar) the library.
This did not help, because
return nothing, i.e. binary does not export my functions.
Last edit: Nikita Furin 2015-05-06
Makefile.am is irrelevant here, it is only used on Linux automake-based build. You are building with ndk-build and only Android.mk is relevant.
Your issue is that you included your wrapper into pocketsphinx static library. During build all unused symbols from static libraries are excluded, only functions referenced from "whole" static libraries are kept. You need to add module as LOCAL_WHOLE_STATIC_LIBRARY, not inside pocketsphinx. An example Android.mk is attached.
However, there is another issue. You used ad.h for audio recording which is not supported in android. You need to record audio with Android native framework like openal instead of sphinxad.
http://mobilepearls.com/labs/native-android-api/ndk/docs/opensles/
Alternatively you can record with C# and then pass audio buffers into pocketsphinx through interop. In that case you will have to modify the wrapper you wrote.
Thank you, Nickolay!