Coder Social home page Coder Social logo

sample-googleassistant's Introduction

Google Assistant SDK for devices - Android Things

This sample shows how to call the Google Assistant Service from Android Things using gRPC. It records a spoken request from the connected microphones, sends it to the Google Assistant API and plays back the Assistant's spoken response on the connected speaker.

Note: The Android Things Console will be turned down for non-commercial use on January 5, 2022. For more details, see the FAQ page.

Pre-requisites

Run the sample

  1. Create or open a project in the Actions Console
  2. Follow the instructions to register a device model
  3. Download client_secret_XXXX.json
  4. Configure the OAuth consent screen for your project
  5. Install the google-oauthlib-tool in a Python 3 virtual environment:
python3 -m venv env
env/bin/python -m pip install --upgrade pip setuptools
env/bin/pip install --upgrade google-auth-oauthlib[tool]
source env/bin/activate
google-oauthlib-tool --client-secrets client_secret_XXXX.json \
                     --credentials app/src/main/res/raw/credentials.json \
                     --scope https://www.googleapis.com/auth/assistant-sdk-prototype \
                     --save
  • Make sure to set the Activity Controls for the Google Account using the application.
  • On the first install, grant the sample required permissions for audio and internet access:
./gradlew assembleDebug
adb install -g app/build/outputs/apk/debug/app-debug.apk
  • On Android Studio, click on the "Run" button or on the command line, type:
./gradlew installDebug
adb shell am start com.example.androidthings.assistant/.AssistantActivity
  • Try the assistant demo:

    • Press the button: recording starts.
    • Ask a question in the microphone. After your question is finished, recording will end.
    • The Google Assistant answer should playback on the speaker.

Audio Configuration

By default the sample routes audio to the I2S Voice Hat on Raspberry Pi 3 and default audio on other boards (on-board Line out or HDMI/USB if connected).

You can change those mappings by changing the USE_VOICEHAT_I2S_DAC constant or replacing the audio configuration in the onCreate method of AssistantActivity with one of the following:

// Force using on-board Line out:
audioInputDevice = findAudioDevice(AudioManager.GET_DEVICES_INPUTS, AudioDeviceInfo.TYPE_BUILTIN_MIC);
audioOutputDevice = findAudioDevice(AudioManager.GET_DEVICES_OUTPUTS, AudioDeviceInfo.TYPE_BUILTIN_SPEAKER);

// Force using USB:
audioInputDevice = findAudioDevice(AudioManager.GET_DEVICES_INPUTS, AudioDeviceInfo.TYPE_USB_DEVICE);
audioOutputDevice = findAudioDevice(AudioManager.GET_DEVICES_OUTPUTS, AudioDeviceInfo.TYPE_USB_DEVICE);

// Force using I2S:
audioInputDevice = findAudioDevice(AudioManager.GET_DEVICES_INPUTS, AudioDeviceInfo.TYPE_BUS);
audioOutputDevice = findAudioDevice(AudioManager.GET_DEVICES_OUTPUTS, AudioDeviceInfo.TYPE_BUS);

Device Actions

With Device Actions, you can control hardware connected to your device. In this sample, you can turn on and off the LED attached to your Android Things board.

Follow the guide here to learn how to register your device.

  • After you register your device model and id, replace the device model and instance PLACEHOLDER values in AssistantActivity:
private static final String DEVICE_MODEL_ID = "my-device-model-id";
private static final String DEVICE_INSTANCE_ID = "my-device-instance-id";
  • Handle a Device Actions response if you get one.
mEmbeddedAssistant = new EmbeddedAssistant.Builder()
    ...
    .setConversationCallback(new ConversationCallback() {
        ...
        @Override
        public void onDeviceAction(String intentName, JSONObject parameters) {
            // Check the type of command
            if (intentName.equals("action.devices.commands.OnOff")) {
                try {
                    boolean turnOn = parameters.getBoolean("on");
                    mLed.setValue(turnOn);
                } catch (JSONException e) {
                    Log.e(TAG, "Cannot get value of command", e);
                } catch (IOException e) {
                    Log.e(TAG, "Cannot set value of LED", e);
                }
            }
        }
    }
    ...
...

Try it:

  • "Turn on"
  • "Turn off"

The LED should change states based on your command.

Enable auto-launch behavior

This sample app is currently configured to launch only when deployed from your development machine. To enable the main activity to launch automatically on boot, add the following intent-filter to the app's manifest file:

<activity ...>

    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.HOME"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>

</activity>

License

Copyright 2017 The Android Open Source Project, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

sample-googleassistant's People

Contributors

atn832 avatar blundell avatar canain avatar danicat avatar drigz avatar elms avatar fleker avatar hskang9 avatar kokoro-team avatar mangini avatar mopemope avatar proppy avatar terryheo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sample-googleassistant's Issues

Low volume on 100%

After testing the original implementation of the Voice AIY project I am wondering why the volume is so low even with 100 volume set in this project

It is about 50% weaker when compared to the Voice Hat driver implementation in the original project.
Is this the Audio manager or the VoiceHat driver issue in this Android Things implementation?
I tried to change the stream volume but it did not help.

 AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

  int amStreamMusicMaxVol = (int) (am.getStreamMaxVolume(am.STREAM_MUSIC) * (volume / 100f));

  am.setStreamVolume(am.STREAM_MUSIC, amStreamMusicMaxVol, 0);

Run on Android smartphone

Hi, thanks for the great work!

I'm trying to run this on an Android smartphone and I'm getting the error:

Installation failed with message INSTALL_FAILED_MISSING_SHARED_LIBRARY: Package couldn't be installed in /data/app/com.example.androidthings.assistant-1: Package com.example.androidthings.assistant requires unavailable shared library com.google.android.things; failing!.

Is it easily possible to modify the app to run on an Android smartphone?

Never responds again after network error

Last night I was working with this, and found once there is a network error, button presses are ignored from that point on. If I can replicate it tonight, I will add an exception trace to this issue, and see if I can see where the code is actually failing.

I found an old USB plantronics headset was sufficient as a single-input single-output device for Audio. This also allows me to talk to the Assistant without anyone else getting too annoyed with me, which is nice. I was pushing the button described in https://github.com/androidthings/sample-button and after only a few tries, sometimes after 20 or so questions answered, the assistant service would throw an exception, and then I'd have to reboot the device.

After reboot, I would have to wait several minutes before the Pi3 board had a correct System Time (it starts off with EPOCH time, Jan 1, 1970) and the SSL connection fails.

Then I'd be able to push the button again for a little while before the first exception would cause the button to become non-responsive.

I'll look into this more, this evening, and add to this report.

if apk(this source) install on the Mobile phone(Emulator), is it available?

if apk(this source) install on the Mobile phone(Emulator), is it available?

Before when I build this source, I have a problem with this link. (#38)
And then I fixed it.

A lot of time to try open again, but this application is not a operated at the emulator. and both of mobile phone(Oreo)
but I can`t use anything which I want.
when I try to open, I can see this log.

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.androidthings.assistant, PID: 3549
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/things/pio/PeripheralManager;
at com.example.androidthings.assistant.AssistantActivity.onCreate(AssistantActivity.java:126)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.things.pio.PeripheralManager" on path: DexPathList[[zip file "/data/app/com.example.androidthings.assistant-meprfKZXTXvjk5Mb2Xe0RQ==/base.apk", zip file "/data/app/com.example.androidthings.assistant-meprfKZXTXvjk5Mb2Xe0RQ==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.androidthings.assistant-meprfKZXTXvjk5Mb2Xe0RQ==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.androidthings.assistant-meprfKZXTXvjk5Mb2Xe0RQ==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.androidthings.assistant-meprfKZXTXvjk5Mb2Xe0RQ==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.androidthings.assistant-meprfKZXTXvjk5Mb2Xe0RQ==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.androidthings.assistant-meprfKZXTXvjk5Mb2Xe0RQ==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.androidthings.assistant-meprfKZXTXvjk5Mb2Xe0RQ==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.androidthings.assistant-meprfKZXTXvjk5Mb2Xe0RQ==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.androidthings.assistant-meprfKZXTXvjk5Mb2Xe0RQ==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.androidthings.assistant-meprfKZXTXvjk5Mb2Xe0RQ==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.androidthings.assistant-meprfKZXTXvjk5Mb2Xe0RQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.androidthings.assistant-meprfKZXTXvjk5Mb2Xe0RQ==/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.example.androidthings.assistant.AssistantActivity.onCreate(AssistantActivity.java:126) 
at android.app.Activity.performCreate(Activity.java:7009) 
at android.app.Activity.performCreate(Activity.java:7000) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6494) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
Application terminated.

How can I solve this problem ?
Somebody help me ~

Can't create credentials.json

I tried to create credentials.json from my ubuntu system.
But iam getting the following error.
Step i followed:

google-oauthlib-tool --client-secrets client_secret_181189387533-2oksu7u1qas4n65lgermqejhb2roj68m.apps.googleusercontent.com.json --credentials /home/ranjith/GoogleAssistant/add/credentials.json --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save

Error Occured :

Traceback (most recent call last):
File "/home/ranjith/env/bin/google-oauthlib-tool", line 11, in

sys.exit(main())
File "/home/ranjith/env/lib/python3.5/site-packages/click/core.py",
line 722, in call
return self.main(*args, **kwargs)
File "/home/ranjith/env/lib/python3.5/site-packages/click/core.py",
line 697, in main
rv = self.invoke(ctx)
File "/home/ranjith/env/lib/python3.5/site-packages/click/core.py",
line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/ranjith/env/lib/python3.5/site-packages/click/core.py",
line 535, in invoke
return callback(*args, **kwargs)
File "/home/ranjith/env/lib/python3.5/site-
packages/google_auth_oauthlib/tool/main.py", line 104, in main
creds = flow.run_local_server()
File "/home/ranjith/env/lib/python3.5/site-
packages/google_auth_oauthlib/flow.py", line 414, in run_local_server
self.fetch_token(authorization_response=authorization_response)
File "/home/ranjith/env/lib/python3.5/site-
packages/google_auth_oauthlib/flow.py", line 234, in fetch_token
client_secret=self.client_config['client_secret'],
KeyError: 'client_secret'

Kindly help me to resolve this issue.

Minimum SDK to run project

What is the minimum SDK required to run this project? Would I be able to run it on a 22 or 23 SDK? Or does the project require at least a 26 minimum SDK due to library requirements.

Log in issue in android smart phone

I created a sample google assinstant app for android smart phone by referring this code.
But if i want to login from another Google account i need to change the credential.json file.
How i can overcome this?
There anyway to prompt Google account login for grpc authentication?

Null pointer moving from v1alpha1 to v1alpha2

Thanks for update to new endpoints. Having issue running the sample app with latest update to v1alpha2 though. There's a null pointer issue...

Caused by: java.lang.NullPointerException 
   at com.google.assistant.embedded.v1alpha2.DeviceConfig.setDeviceId(DeviceConfig.java:73)
   at com.google.assistant.embedded.v1alpha2.DeviceConfig.access$100(DeviceConfig.java:13)
   at com.google.assistant.embedded.v1alpha2.DeviceConfig$Builder.setDeviceId(DeviceConfig.java:356)
   at com.example.androidthings.assistant.EmbeddedAssistant$Builder.build(EmbeddedAssistant.java:622)
   at com.example.androidthings.assistant.AssistantActivity.onCreate(AssistantActivity.java:211)
   at android.app.Activity.performCreate(Activity.java:7000)
   at android.app.Activity.performCreate(Activity.java:6991)

DeviceConfig.java 73, 13 & 356 are build files & as per studio shouldn't be edited. For EmbeddedAssitant.java:622, is it related to lines 524 (setDeviceModelId) & 535 (setDeviceInstanceId)? For me both of those methods are greyed out; when I hover over them studio tells me

Method 'setDeviceModelId(java.lang.String)' is never used

and I'm not really certain how to call them in AssistantActivity.java somewhere ~line 152. Made certain to recreate res > raw > credentials.json & when I run the old sample (v1alpha1) it still works so I think everything is OK as far as project settings. As best I can tell, I added everything necessary for the move to alpha2?

gRPC error after END_OF_UTTERANCE

Here's the error -


09-21 20:04:29.944 2165-2293/com.example.androidthings.assistant D/AssistantActivity: converse response event: END_OF_UTTERANCE
09-21 20:04:31.151 2165-2175/com.example.androidthings.assistant I/zygote: Waiting for a blocking GC ObjectsAllocated
09-21 20:04:31.187 2165-2175/com.example.androidthings.assistant I/zygote: Waiting for a blocking GC ObjectsAllocated
09-21 20:04:31.187 2165-2175/com.example.androidthings.assistant I/zygote: WaitForGcToComplete blocked for 36.391ms for cause ObjectsAllocated
09-21 20:04:46.733 2165-2173/com.example.androidthings.assistant I/zygote: Do partial code cache collection, code=62KB, data=58KB
09-21 20:04:46.735 2165-2173/com.example.androidthings.assistant I/zygote: After code cache collection, code=62KB, data=58KB
09-21 20:04:46.735 2165-2173/com.example.androidthings.assistant I/zygote: Increasing code cache capacity to 256KB
09-21 20:05:29.866 2165-2293/com.example.androidthings.assistant E/AssistantActivity: converse error:
                                                                                      io.grpc.StatusRuntimeException: INTERNAL: Received unexpected EOS on DATA frame from server.
                                                                                          at io.grpc.Status.asRuntimeException(Status.java:540)
                                                                                          at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:392)
                                                                                          at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:428)
                                                                                          at io.grpc.internal.ClientCallImpl.access$100(ClientCallImpl.java:76)
                                                                                          at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:514)
                                                                                          at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$700(ClientCallImpl.java:431)
                                                                                          at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:546)
                                                                                          at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:52)
                                                                                          at io.grpc.internal.SerializingExecutor$TaskRunner.run(SerializingExecutor.java:152)
                                                                                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                                                                                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                                                                                          at java.lang.Thread.run(Thread.java:764)

I get it after I've spoken and then become quiet (it understands END_OF_UTTERANCE), then starts uploading the speech to Googel Cloud ( I can see in network monitor), and it then shows this stacktrace. App doesn't crash, but it stops working after this point

Build takes a lot of time "like a build after clean" with jackOptions

Hi,

Ever, with each compilation the project take the same time like a build after clean. The solution take from ~4 min to 15 secs with each build. The solution is comment the next options:

jackOptions {
            enabled true
}
compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
}

Tools:
AndroidStudio 2.3.3 stable channel. Repository same to master.

How to find the end of audio response ?

I want to know the end of audio response(audio out) to start a new session.
Use case:
User : Set alarm
Response : what time ?

User : 6:30
Response : Ok,Setting alarm to 6:30

For this case, i need to know audio finish status after the response "what time ?" to start new session.

Kindly help .

windows10 system can't create credentials.json

I tried to create credentials.json from my windows10 system. And I already rename the file to client_secret_NNNN.json and copy to the project root directory
But i am getting the following error.
Step i followed:

google-oauthlib-tool --client-secrets client_secret_NNNN.json --credentials app/src/main/res/raw/credentials.json --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save

Error Occured :

Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=1052286463727-729o0p80qtcekjkcvsc86m5u3vbggbdo.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fassistant-sdk-prototype&state=BgxGivn1AW3gKttg1rOJLNpngvz8i9&access_type=offline
Traceback (most recent call last):
File "c:\users\yaohj\appdata\local\programs\python\python36\lib\runpy.py", line 193, in run_module_as_main
"main", mod_spec)
File "c:\users\yaohj\appdata\local\programs\python\python36\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\yaohj\AppData\Local\Programs\Python\Python36\Scripts\google-oauthlib-tool.exe_main
.py", line 9, in
File "c:\users\yaohj\appdata\local\programs\python\python36\lib\site-packages\click\core.py", line 722, in call
return self.main(*args, **kwargs)
File "c:\users\yaohj\appdata\local\programs\python\python36\lib\site-packages\click\core.py", line 697, in main
rv = self.invoke(ctx)
File "c:\users\yaohj\appdata\local\programs\python\python36\lib\site-packages\click\core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\yaohj\appdata\local\programs\python\python36\lib\site-packages\click\core.py", line 535, in invoke
return callback(*args, **kwargs)
File "c:\users\yaohj\appdata\local\programs\python\python36\lib\site-packages\google_auth_oauthlib\tool_main
.py", line 104, in main
creds = flow.run_local_server()
File "c:\users\yaohj\appdata\local\programs\python\python36\lib\site-packages\google_auth_oauthlib\flow.py", line 414, in run_local_server
self.fetch_token(authorization_response=authorization_response)
File "c:\users\yaohj\appdata\local\programs\python\python36\lib\site-packages\google_auth_oauthlib\flow.py", line 234, in fetch_token
client_secret=self.client_config['client_secret'],
KeyError: 'client_secret'

Kindly help me to resolve this issue.

Hot word detection

Add support for hot word detection like "Okay Google" instead of pressing any physical button

Android Studio error run project

When I click Run in android studio the following error occurs: Error: (143, 66) error: can not find symbol variable raw
File: sample-googleassistant-master /app/src/main/java/com/example/androidthings/assistant/AssistantActivity.java line 143.
Android Studio Version: 3.0.1.

I tried to sync the project in: Tools> Android> Sync Project with Grade Files
and then click "Run" again. But the error persists.

How to solve this?
thanks

How to stop Assistant answer

Hello guys,

I'm implementing some custom actions for my application, example, when I say "Who is your boss?", I want to do some actions.
That's the easy part.. just doing stuff at "onSpeechRecognition" based on the string.
However, I need to stop any response from Assistant.

What's the correct way to do that?
If I just call a mAudioTrack.stop() is enough? or should I change anything else?

Thanks in advance!
Danilo

AudioTrack releaseBuffer warning

I have this app running on my Android Things Rpi3 (Dev Preview 4.1). When I click the button to record, I get a warning:
com.example.androidthings.assistant W/AudioTrack: releaseBuffer() track 0xa71ecf00 disabled due to previous underrun, restarting

I can't get the demo to work...Could this warning be the reason? Thanks!

assistant response shouldn't be allowed to play concurrently

Currently if pressing the button while the assistant response is playing, a new request will be recorded and there is a possibility that the response audio will play on top of each other.

We should either interrupt the assistant response playback or queue them.

@Fleker what do you think?

Google Assistant Android APP

Hi Everyone,

I need to Android Application that it has integration with google assistant.

For example;
there is a button on the page and when I click on it and say something. This app recognize my voice an then get the text and answer me?

is it possible?

# can someone help me in this matter?

Add button widget

To allow starting a new assistant query w/o wiring a GPIO button when a screen is connected.

AndroidThings disk image might be corrupt

I tried to burn the image into a sd card, an usb disk and I got always the same message saying "The disk you inserted was not readable by this computer".

Despite the message, I took the sdcard and I inserted it into the raspberry pi, with no success. It didn't boot at all and it got stuck on a rainbow screen.

I tried multiple times with preview v3.1 and v4. Alternatively, It worked with the same sdcard and the raspbian version with google assistant on it, so I Imagine there must be something wrong with the latest preview of androidThings disk image.

Import of ConverseConfig

Add a step to import

import com.google.assistant.embedded.v1alpha1.ConverseConfig;
and hot key for new users to Android Studio

No error: A GRPC status of OK should have been sent Rst Stream

After configure the project I have launched the application and say my first command "Hello", the assistant returns No error: A GRPC status of OK should have been sent Rst Stream. I've checked Google APIs Console and I saw that the error is google.assistant.embedded.v1alpha2.EmbeddedAssistant.Assist Code 499

What is the problem? Because with the previous version of the API, it works.

Getting converse error everytime.

Please find logs.

01-11 11:03:25.330 15138-15138/? I/zygote: Late-enabling -Xcheck:jni
01-11 11:03:25.479 15138-15138/? W/zygote: Using default instruction set features for ARM CPU variant (generic) using conservative defaults
01-11 11:03:26.879 15138-15138/com.example.androidthings.assistant I/InstantRun: starting instant run server: is main process
01-11 11:03:27.027 15138-15138/com.example.androidthings.assistant I/AssistantActivity: starting assistant demo
01-11 11:03:27.499 15138-15138/com.example.androidthings.assistant I/AssistantActivity: initializing DAC trigger
01-11 11:03:27.581 15138-15138/com.example.androidthings.assistant I/AssistantActivity: setting audio track volume to: 100
01-11 11:03:28.064 15138-15138/com.example.androidthings.assistant D/NetworkSecurityConfig: No Network Security Config specified, using platform default
01-11 11:03:28.543 15138-15138/com.example.androidthings.assistant D/vndksupport: Loading /vendor/lib/hw/[email protected] from current namespace instead of sphal namespace.
01-11 11:03:28.689 15138-15138/com.example.androidthings.assistant D/OpenGLRenderer: HWUI GL Pipeline
01-11 11:03:50.730 15138-15144/com.example.androidthings.assistant I/zygote: Do partial code cache collection, code=29KB, data=29KB
01-11 11:03:50.744 15138-15144/com.example.androidthings.assistant I/zygote: After code cache collection, code=29KB, data=29KB
01-11 11:03:50.744 15138-15144/com.example.androidthings.assistant I/zygote: Increasing code cache capacity to 128KB
01-11 11:03:51.678 15138-15138/com.example.androidthings.assistant I/AssistantActivity: starting assistant request, enable microphones
01-11 11:04:00.277 15138-15138/com.example.androidthings.assistant D/AssistantActivity: converse response event: END_OF_UTTERANCE
01-11 11:04:00.559 15138-15144/com.example.androidthings.assistant I/zygote: Do partial code cache collection, code=60KB, data=61KB
01-11 11:04:00.563 15138-15144/com.example.androidthings.assistant I/zygote: After code cache collection, code=60KB, data=61KB
01-11 11:04:00.563 15138-15144/com.example.androidthings.assistant I/zygote: Increasing code cache capacity to 256KB
01-11 11:05:00.228 15138-15138/com.example.androidthings.assistant E/AssistantActivity: converse error
io.grpc.StatusRuntimeException: INTERNAL: Received unexpected EOS on DATA frame from server.
at io.grpc.Status.asRuntimeException(Status.java:540)
at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:392)
at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:428)
at io.grpc.internal.ClientCallImpl.access$100(ClientCallImpl.java:76)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:514)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$700(ClientCallImpl.java:431)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:546)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:52)
at io.grpc.internal.SerializingExecutor$TaskRunner.run(SerializingExecutor.java:152)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
01-11 11:05:00.345 15138-15144/com.example.androidthings.assistant I/zygote: Do full code cache collection, code=124KB, data=99KB
01-11 11:05:00.349 15138-15144/com.example.androidthings.assistant I/zygote: After code cache collection, code=98KB, data=63KB

App Stuck at Title Bar

App installs fine, but when started it hangs on loading. Only the title bar text is displayed on the top area and a blank rectangle for the main UI area.

$ adb logcat *:E

10-06 18:02:34.060   172  1230 E AudioFlinger: Error when setting parameters on exit: -61
10-06 18:02:37.444   316   416 E TaskPersister: File error accessing recents directory (directory doesn't exist?).

No stack trace is printed in unfiltered logcat output.
The problem persists through multiple restarts.

UnsupportedOperationException: Cannot create AudioRecord

Something wents wrong when I install it according to your tutorial I get the following LogCat Error and the App just crashes:

05-10 15:11:28.191 1794-1807/com.example.androidthings.assistant D/VoiceHatDriver: turning voice hat DAC on
05-10 15:11:28.200 1794-1794/com.example.androidthings.assistant E/AudioRecord: AudioFlinger could not create record track, status: -1
05-10 15:11:28.206 1794-1794/com.example.androidthings.assistant E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -1.
05-10 15:11:28.206 1794-1794/com.example.androidthings.assistant E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.
05-10 15:11:28.208 1794-1794/com.example.androidthings.assistant D/AndroidRuntime: Shutting down VM
                                                                                   
                                                                                   
                                                                                   --------- beginning of crash
05-10 15:11:28.210 1794-1794/com.example.androidthings.assistant E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                   Process: com.example.androidthings.assistant, PID: 1794
                                                                                   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidthings.assistant/com.example.androidthings.assistant.AssistantActivity}: java.lang.UnsupportedOperationException: Cannot create AudioRecord
                                                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
                                                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
                                                                                       at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
                                                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                       at android.os.Looper.loop(Looper.java:154)
                                                                                       at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                                                                                    Caused by: java.lang.UnsupportedOperationException: Cannot create AudioRecord
                                                                                       at android.media.AudioRecord$Builder.build(AudioRecord.java:626)
                                                                                       at com.example.androidthings.assistant.AssistantActivity.onCreate(AssistantActivity.java:277)
                                                                                       at android.app.Activity.performCreate(Activity.java:6662)
                                                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
                                                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) 
                                                                                       at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                                                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) 
                                                                                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                       at android.os.Looper.loop(Looper.java:154) 
                                                                                       at android.app.ActivityThread.main(ActivityThread.java:6077) 
                                                                                       at java.lang.reflect.Method.invoke(Native Method) 
                                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
                                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Can you give me a clue where I am wrong?

After I opened this project, android studio reported this error

Error:Could not resolve all files for configuration ':grpc:protobufToolsLocator_protoc'.

Could not resolve com.google.protobuf:protoc:3.2.0.
Required by:
project :grpc
Could not resolve com.google.protobuf:protoc:3.2.0.
> Could not get resource 'https://jcenter.bintray.com/com/google/protobuf/protoc/3.2.0/protoc-3.2.0.pom'.
> Could not GET 'https://jcenter.bintray.com/com/google/protobuf/protoc/3.2.0/protoc-3.2.0.pom'. Received status code 502 from server: Bad Gateway

BUILD FAILED

Hi, I am facing this issue here. The old sample app used to build without any issues and I can see now the voicehat directory and gRPC directories are added. Please advice.

Error:Execution failed for task ':grpc:generateReleaseProto'.

protoc: stdout: . stderr: /Users/Documents/DEVWorskspace/ANDROID THINGS/ANDROID THINGS PROJECTS/Google Assistant/sample-googleassistant/grpc/build/extracted-protos/main: warning: directory does not exist.
/Users/Documents/DEVWorskspace/ANDROID THINGS/ANDROID THINGS PROJECTS/Google Assistant/sample-googleassistant/grpc/build/extracted-include-protos/main: warning: directory does not exist.
/Users/Documents/DEVWorskspace/ANDROID THINGS/ANDROID THINGS PROJECTS/Google Assistant/sample-googleassistant/grpc/src/release/proto: warning: directory does not exist.
/Users/Documents/DEVWorskspace/ANDROID THINGS/ANDROID THINGS PROJECTS/Google Assistant/sample-googleassistant/grpc/build/extracted-protos/release: warning: directory does not exist.
/Users/Documents/DEVWorskspace/ANDROID THINGS/ANDROID THINGS PROJECTS/Google Assistant/sample-googleassistant/grpc/build/extracted-include-protos/release: warning: directory does not exist.
/Users/Documents/DEVWorskspace/ANDROID THINGS/ANDROID THINGS PROJECTS/Google Assistant/sample-googleassistant/grpc/src/release/proto: warning: directory does not exist.
/Users/Documents/DEVWorskspace/ANDROID THINGS/ANDROID THINGS PROJECTS/Google Assistant/sample-googleassistant/grpc/build/extracted-protos/release: warning: directory does not exist.
/Users/Documents/DEVWorskspace/ANDROID THINGS/ANDROID THINGS PROJECTS/Google Assistant/sample-googleassistant/grpc/build/extracted-include-protos/release: warning: directory does not exist.
google/api/http.proto: File not found.
google/protobuf/descriptor.proto: File not found.
api/annotations.proto: Import "google/api/http.proto" was not found or had errors.
api/annotations.proto: Import "google/protobuf/descriptor.proto" was not found or had errors.
api/annotations.proto:28:8: "google.protobuf.MethodOptions" is not defined.

Can I use 3.5mm jack earphone or Speakers as output device(Board: PI3)

Hi guys,
USE_VOICEHAT_I2S_DAC has been set false.
I tried to use USB audio card, everything is OK.
Now I'm trying to use a USB microphone to record voice and use 3.5mm cable on PI3 to output.
System can record voice and do recognition but there is no output on 3.5mm cable.
When I tried to use findAudioDevice to get output device, return value is always null.
Thanks
o.O

Assistant won't recognize device traits

Using a python3 virtualenv & I registered several device traits. The model info returns:

(venv3) cartier@cartier-VirtualBox:~/venv3$ googlesamples-assistant-devicetool get --model my-model
Device Model Id: my-model
Project Id: my-id
Device Type: action.devices.types.LIGHT
Trait action.devices.traits.Brightness
Trait action.devices.traits.ColorTemperature
Trait action.devices.traits.OnOff

The device info returns:

(venv3) cartier@cartier-VirtualBox:~/venv3$ googlesamples-assistant-devicetool get --device my-id
Device Instance Id: my-id
Nickname: Assistant SDK light
Model: my-model

However, when I say "Ok Google, turn on." the assistant replies "Sorry, power controls is not yet supported." Is there some change/update I need to make to the credentials.json or somewhere else within the sample app? As best I can tell, the traits look OK, I haven't seen anything in the terminal of concern & the assistant responds fine to most requests...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.