Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
res/ | 06-Sep-2024 | - | 99 | 38 | ||
src/com/example/android/voiceinteractor/ | 06-Sep-2024 | - | 1,048 | 745 | ||
Android.bp | D | 06-Sep-2024 | 575 | 26 | 23 | |
AndroidManifest.xml | D | 06-Sep-2024 | 2.1 KiB | 49 | 45 | |
README.md | D | 06-Sep-2024 | 4.1 KiB | 93 | 85 | |
com.example.android.voiceinteractor.xml | D | 06-Sep-2024 | 1,018 | 25 | 8 | |
lint-baseline.xml | D | 06-Sep-2024 | 17.6 KiB | 367 | 333 |
README.md
1 setup: 2 3 (If a log error "VisualQueryDetector is only available if multiple detectors are allowed" , set target_sdk_version: "10000" in Android.bp for now.) 4 1. Set the KEYPHRASE constant in SampleVoiceInteractionService.java to something the device's 5 default assistant supports. 6 2. m -j SampleVoiceInteractor 7 4. adb root; adb remount 8 5. adb push development/samples/VoiceInteractionService/com.example.android.voiceinteractor.xml /system/etc/permissions/com.example.android.voiceinteractor.xml 9 6. adb shell mkdir /system/priv-app/SampleVoiceInteractor 10 7. adb push out/target/product/$TARGET_PRODUCT/system/priv-app/SampleVoiceInteractor/SampleVoiceInteractor.apk /system/priv-app/SampleVoiceInteractor/ 11 8. adb reboot 12 9. Go to the sample app info/settings. 13 10. Tap on Permissions and grant Mic access. 14 11. Reboot. 15 12. Set the "Digital assistant app" to "Sample Voice Interactor" in the Android settings 16 13. Check for this in the logs to make sure it worked: 17 com.example.android.voiceinteractor I/VIS: onAvailabilityChanged: 2 18 14. If it didn't, check if the pregrant worked: 19 adb shell dumpsys package com.example.android.voiceinteractor | grep CAPTURE_AUDIO_HOTWORD 20 21 Iterating: 22 * adb install like usual 23 * If syncing changes to the system image, either first copy the permissions file into 24 out/target/product/system/etc/permissions/ or push it again after syncing. Sometimes you might 25 need to uninstall the app (go to the sample app info/settings -> 3 dots menu -> uninstall 26 updates). 27 28 to test: 29 1. Say "1,2,Ok Poodle,3,4.." 30 2. Check the logs for the app and wait till it finishes recording. 31 3. Either check the logs for the sampled bytes to match, e.g. "sample=[95, 2, 97, ...]" should 32 appear twice; or open the sample app activity and click the button to play back the recorded 33 audio. 34 Tap directRecord to simulate the non-DSP case (must be done after a dsp trigger since it 35 reuses the previous data). 36 37 Debugging: 38 * Set DEBUG to true in AlwaysOnHotwordDetector 39 * uncomment LOG_NDEBUG lines at the top in AudioFlinger.cpp, Threads.cpp, Tracks.cpp, 40 AudioPolicyInterfaceImpl.cpp, AudioPolicyService.cpp 41 * Use this logcat filter: 42 com.example.android.voiceinteractor|AlwaysOnHotword|SoundTrigger|RecordingActivityMonitor|soundtrigger|AudioPolicyManager|AudioFlinger|AudioPolicyIntefaceImpl|AudioPolicyService|VIS|SHotwordDetectionSrvc|Hotword-AudioUtils 43 44 Collecting trace events: \ 45 Trace events are used throughout the test app to measure the time it takes to read the AudioRecord 46 data in both the VoiceInteractionService and the trusted HotwordDetectionService. This section can 47 be used as a guide to collect and observe this trace data. 48 49 * Trace events: 50 * 'VIS.onDetected' and 'HDS.onDetected' 51 * 'VIS.createAudioRecord' and 'HDS.createAudioRecord' 52 * 'VIS.startRecording' and 'HDS.startRecording' 53 * 'AudioUtils.read' and 'AudioRecord.read' 54 * 'AudioUtils.bytesRead' 55 * Counter trace value increasing as the AudioUtils.read call progresses. This value is reset after each new call. 56 57 * How to capture a trace: 58 * Follow this guide or a similar one: https://developer.android.com/topic/performance/tracing/on-device 59 * Open https://perfetto.dev/#/running.md and upload a trace report 60 * Search for the events manually or run the below example SQL query to pull out the events. 61 62 * Perfetto trace SQL query 63 * How to run a SQL query: https://perfetto.dev/docs/quickstart/trace-analysis 64 * Covers both command line and HTML implementations 65 ``` 66 WITH 67 audio_events AS ( 68 SELECT 69 ts, 70 (dur / 1000000) as dur_ms, 71 name 72 FROM 73 slice 74 WHERE 75 (name LIKE "%AudioUtils.read%" 76 OR name LIKE "%AudioRecord.read%" 77 OR name LIKE "%onDetected%" 78 OR name LIKE "%startRecording%" 79 OR name LIKE "%createAudioRecord%") 80 ), 81 audio_counters AS ( 82 SELECT ts, name, value 83 FROM counter 84 INNER JOIN track ON counter.track_id = track.id 85 WHERE name LIKE "%AudioUtils.bytesRead%" 86 ) 87 SELECT ts, 'event' as type, name, dur_ms as value 88 FROM audio_events 89 UNION ALL 90 SELECT ts, 'counter' as type, name, value 91 FROM audio_counters 92 ORDER BY ts 93 ```