googlesamples / assistant-sdk-python

Samples and bindings for the Google Assistant API
http://developer.google.com/assistant/sdk
Apache License 2.0
917 stars 320 forks source link

googlesamples-assistant-hotword does not work on alpine-linux #209

Closed subjectxbj closed 6 years ago

subjectxbj commented 6 years ago

My device is a ARM7 device, and I installed a alpine linux container on the device.

After install all the required packages in the container, I start to run "googlesamples-assistant-hotword".

But it report following result:

[dev-env] / # googlesamples-assistant-hotword --device_model_id model-1234 --cr
edentials /etc/credentials.json
Traceback (most recent call last):
  File "/usr/bin/googlesamples-assistant-hotword", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/googlesamples/assistant/library/hotword.py", line 136, in main
    with Assistant(credentials, args.device_model_id) as assistant:
  File "/usr/lib/python3.6/site-packages/google/assistant/library/assistant.py", line 90, in __init__
    self._load_lib()
  File "/usr/lib/python3.6/site-packages/google/assistant/library/assistant.py", line 251, in _load_lib
    self._lib = cdll.LoadLibrary(lib_path)
  File "/usr/lib/python3.6/ctypes/__init__.py", line 426, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: Error loading shared library ld-linux-armhf.so.3: No such file or directory (needed by /usr/lib/python3.6/site-packages/google/assistant/library/libassistant_embedder.so)

I googled this problem, looks like "libassistant_embedder.so" is built uppon "glibc", so it tries to load the library "ld-linux-armhf.so.3".

Now alpine-linux only support musl libc, so it has only "ld-musl-armhf.so.1" under the path "/lib". That's why it return error.

So I installed a package "libc6-compat" on the alpine-linux, which is said to be compatible with glibc. After that, the library " ld-linux-armhf.so.3" is appeared under "/lib".

Then I run "googlesamples-assistant-hotword" again, now it report another error:

[dev-env] / # googlesamples-assistant-hotword --device_model_id model-1234 --cr
edentials /etc/credentials.json
Traceback (most recent call last):
  File "/usr/bin/googlesamples-assistant-hotword", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/googlesamples/assistant/library/hotword.py", line 136, in main
    with Assistant(credentials, args.device_model_id) as assistant:
  File "/usr/lib/python3.6/site-packages/google/assistant/library/assistant.py", line 90, in __init__
    self._load_lib()
  File "/usr/lib/python3.6/site-packages/google/assistant/library/assistant.py", line 251, in _load_lib
    self._lib = cdll.LoadLibrary(lib_path)
  File "/usr/lib/python3.6/ctypes/__init__.py", line 426, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: Error relocating /usr/lib/python3.6/site-packages/google/assistant/library/libassistant_embedder.so: strtoll_l: symbol not found

Then I use ldd to show "libassistant_embedder.so":

[dev-env] / # ldd /usr/lib/python3.6/site-packages/google/assistant/library/liba
ssistant_embedder.so
        ldd (0x54b04000)
        libpthread.so.0 => ldd (0x54b04000)
        libdl.so.2 => ldd (0x54b04000)
        librt.so.1 => ldd (0x54b04000)
        libasound.so.2 => /usr/lib/libasound.so.2 (0x763a0000)
        libm.so.6 => ldd (0x54b04000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x76386000)
        libc.so.6 => ldd (0x54b04000)
Error relocating /usr/lib/python3.6/site-packages/google/assistant/library/libassistant_embedder.so: strtoll_l: symbol not found
Error relocating /usr/lib/python3.6/site-packages/google/assistant/library/libassistant_embedder.so: __isnanf: symbol not found
Error relocating /usr/lib/python3.6/site-packages/google/assistant/library/libassistant_embedder.so: strtoull_l: symbol not found
Error relocating /usr/lib/python3.6/site-packages/google/assistant/library/libassistant_embedder.so: __rawmemchr: symbol not found
Error relocating /usr/lib/python3.6/site-packages/google/assistant/library/libassistant_embedder.so: secure_getenv: symbol not found
Error relocating /usr/lib/python3.6/site-packages/google/assistant/library/libassistant_embedder.so: __strtok_r: symbol not found
Error relocating /usr/lib/python3.6/site-packages/google/assistant/library/libassistant_embedder.so: isnan: symbol not found

Looks like it can't find these symbols in the c lib. Seems this libc6-compat only provide limited compatibility.

Now I don't know how to proceed anymore. Is it possible for google to build another "libassistant_embedder.so" with musl libc, and dynamically install the right one corresponding to the installed c lib?

Thanks

Fleker commented 6 years ago

The libassistant_embedder.so code is not open source, so it would not be possible to rebuild it with a different set of symbols.

subjectxbj commented 6 years ago

I did not mean rebuild it by myself. I mean is it possible for google to add the support of musl libc?

Fleker commented 6 years ago

I'll pass along the request, although it probably won't be added in the short-term.

hkwan72 commented 6 years ago

is there any updated on this issue? now i'm experiencing the same issue as below;

googlesamples-assistant-hotword Traceback (most recent call last): File "/usr/bin/googlesamples-assistant-hotword", line 11, in sys.exit(main()) File "/usr/lib/python2.7/site-packages/googlesamples/assistant/library/hotword.py", line 136, in main with Assistant(credentials, args.device_model_id) as assistant: File "/usr/lib/python2.7/site-packages/google/assistant/library/assistant.py", line 90, in init self._load_lib() File "/usr/lib/python2.7/site-packages/google/assistant/library/assistant.py", line 251, in _load_lib self._lib = cdll.LoadLibrary(lib_path) File "/usr/lib/python2.7/ctypes/init.py", line 443, in LoadLibrary return self._dlltype(name) File "/usr/lib/python2.7/ctypes/init.py", line 365, in init self._handle = _dlopen(self._name, mode) OSError: /usr/lib/python2.7/site-packages/google/assistant/library/libassistant_embedder.so: internal error

ls /usr/lib/python2.7/site-packages/google/assistant/lib rary/ LICENSE.third_party assistant.pyc file_helpers.pyc init.py auth_helpers.py libassistant_embedder.so init.pyc auth_helpers.pyc version.py main.py event.py version.pyc main.pyc event.pyc assistant.py file_helpers.py

stat /usr/lib/python2.7/site-packages/google/assistant/l ibrary/libassistant_embedder.so File: /usr/lib/python2.7/site-packages/google/assistant/library/libassistant_embedder.so Size: 11504740 Blocks: 22472 IO Block: 4096 regular file Device: ch/12d Inode: 8375 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 1980-01-06 15:00:21.000000000 Modify: 1980-01-06 15:00:20.000000000 Change: 1980-01-06 15:00:22.000000000

please let me know if there is a way to fix this matter . thanks.

Fleker commented 6 years ago

Right now the hotword sample seems like it won't compile on Alpine Linux, so it'll probably make more sense to move to a supported platform or switch to using the service api.

Fleker commented 6 years ago

Right now the hotword sample seems like it won't compile on Alpine Linux, so it'll probably make more sense to move to a supported platform or switch to using the service api.

hkwan72 commented 6 years ago

Thanks for your comments. i'm using device which is based on MDM9307 arm and i'm used below cases and got the same error. 1)google_assistant_library-1.0.0-py2.py3-none-linux_armv7l.whl google_assistant_sdk-0.5.0-py2.py3-none-any.whl 2)google_assistant_library-0.1.1-py2.py3-none-linux_armv7l.whl google_assistant_sdk-0.4.4-py2.py3-none-any.whl

based on your comments, the python version of google assistant does not support on arm Linux platform as like our device( MDM9307), my understanding is right?

if possible, could you let me know more detail explanation regard to " switch to using the service api. " please? actually i'm looking forward to get a solution to fix this issue on arm v7 linux platform environment. does google assistant c++ version working on arm v7 linux platform environment? is it possible to integration c++ version on armv7 linux platform by using cross compiler? can we preload the google assistant hotword package on the device that use arm platform without using apt get install or pip tool? if possible, please let us know how to get the package and preload them on the device.

thanks.

Fleker commented 6 years ago

The service API is a lightweight set of gRPC calls. This gives greater flexibility, albeit with fewer client features.

The library is more of a thicker client which includes the built-in hotword detection. This hotword detection has been tested and works on Ubuntu and Raspbian, but may end up having some issues and hasn't been tested on these other platforms.

The C++ sample should work on armv7, but it uses the service API.

hkwan72 commented 6 years ago

thanks for the feedback. if so, do you have a plan to support python version on arm Linux platform as like our device( MDM9307)? what do we have to do in order to get technical support for this matter from google?

Regarding C++ is it possible to integrate c++ version on the armv7 linux platform device by using cross compiler without using apt-get tool? if so, could you let us know a kind of porting guide regard to how to integrate it please?

in addition for python version i got the below error when ran pushtotalk.

=== log ====== googlesamples-assistant-pushtotalk --project_id xxxxxx --devic e_model_id xxxxxxxxxxxxxxxxxx Traceback (most recent call last): File "/usr/bin/googlesamples-assistant-pushtotalk", line 7, in from googlesamples.assistant.grpc.pushtotalk import main File "/usr/lib/python2.7/site-packages/googlesamples/assistant/grpc/pushtotalk.py", line 28, in import grpc File "/usr/lib/python2.7/site-packages/grpc/init.py", line 22, in from grpc._cython import cygrpc as _cygrpc ImportError: /usr/lib/python2.7/site-packages/grpc/_cython/cygrpc.so: wrong ELF class: ELFCLASS64

thanks.

Fleker commented 6 years ago

I can't comment on what the roadmap looks like.

I suppose you don't necessarily need apt-get to run the C++ sample as long as you have all the dependencies set up.

It looks like your error seems to be related to a 32-bit/64-bit conflict.

hkwan72 commented 6 years ago

thanks for the feedback.

1)regarding Python version, now i'm using toolchain "arm-oe-linux-gnueabi ". as below informs; export SDKTARGETSYSROOT=/usr/local/oecore-x86_64/sysroots/armv7a-vfp-neon-oe-linux-gnueabi export CONFIGURE_FLAGS="--target=arm-oe-linux-gnueabi --host=arm-oe-linux-gnueabi --build=x86_64-linux --with-libtool-sysroot=$SDKTARGETSYSROOT export KCFLAGS="--sysroot=$SDKTARGETSYSROOT" export OECORE_DISTRO_VERSION="LE.UM.1.1-11700-9x07" export OECORE_SDK_VERSION="nodistro.0" export ARCH=arm export CROSS_COMPILE=arm-oe-linux-gnueabi-

i guess that hotword could be work if we get the ibassistant_embedder.so which could be generated by using our arm toolchain. also cygrpc.so error ,too. if my guess is available, is it possible for us to get the libassistant_embedder.so which could be generated by using our arm toolchain from your side? if possible, please let me know how to proceed to get them.

2) regard to c++ version based on your comments, my understanding is that i could be possible to build c++ sample by using our toolchains if all the dependencies is ready. am i right? if so, what i'm wondering is how to build below dependencies by using our toolchains. sudo apt-get install autoconf automake libtool build-essential curl unzip sudo apt-get install libasound2-dev # For ALSA sound output sudo apt-get install libcurl4-openssl-dev # CURL development library

i guess that i need get the full source code for above dependency modules and build them by using my toolchains and install the generated libraries & execute binary on my target(MDM9307) and after ready them, then could try to build c++ sample.

if possible, could you please let me know how to compile all of them in order to run c++ sample on my target( MDM9307) as like more detailed porting guide (ex: iOS cross compile instruction )?

thanks.

Fleker commented 6 years ago

The libassistant_embedder.so is not open source.

I don't really know your target well enough to suggest how to build the essential libraries.

hkwan72 commented 6 years ago

as i mentioned on previous comments, if we provide out toolchain to your side, is it possible for us to get the libassistant_embedder.so which could be generated by using our arm toolchain from your side? actually we really need to get your help to address this matter in order to use python version on our device. please give more helpful instruction regard to how to integrate python version on arm device ( arm-oe-linux-gnueabi), if possible. also c++ version, too. thanks.

Fleker commented 6 years ago

I'm probably not going to be familiar enough with your toolchain to be of much help.

hkwan72 commented 6 years ago

as you mentioned, i think i couldn't use python version without getting libassistant_embedder.so which could be generated by using our arm toolchain because the libassistant_embedder.so is not open source. as i mentioned on previous, i really need to it to use the python on my device. isn't there a way to get libassistant_embedder.so ? for the purpose of testing, if possible, i really want to get libassistant_embedder.so which is generated by using arm-linux-gnueabi-gcc from your side. also, if possible, could you provide me an instruction to compile c++ version by using arm-linux-gnueabi-gcc?

please get feedback to me.

thanks.

Fleker commented 6 years ago

No, the source code is not open.

hkwan72 commented 6 years ago

Thanks for the feedback. in addition to C++ version, does SDK C++ support some event which can be used in python version as like ;EventType.ON_CONVERSATION_TURN_STARTED/EventType.ON_START_FINISHED/EventType.ON_RECOGNIZING_SPEECH_FINISHED/EventType.ON_CONVERSATION_TURN_FINISHED/EventType.ON_DEVICE_ACTION; ? what i want is to detect a predefined special word or phrase by using google assistant SDK C++ version as like below; "ok google", " music play / stop / pause/ next /previous", " set volume up/ down/high/medium/low" " bluetooth on/off" in order to implement them as like the process_event(self, event) implemented in hotword.py of python version, i guess below several events provided in python version could be supported in C++ version,too. if so, how can i use those event in C++ version? is there something example code in C++ version ? if possible, please let me know some guide to implement them in C++ version.

thanks

Fleker commented 6 years ago

This project is for Python, not for C++. I'm going to close this issue. New issues can be created here or in the C++ project if needed.