Add dependencies for RASA framework
[AGL/meta-agl-devel.git] / meta-offline-voice-agent / README.md
1 # Offline Speech Recognition and Command Execution
2 The `meta-offline-voice-agent` is an AGL Layer that enables Offline Speech Recognition and Command Execution capabilities for Automotive Grade Linux.
3
4 ## Table of Contents
5 - [Introduction](#introduction)
6 - [Layer Status](#layer-status)
7 - [Working Features](#working-features)
8 - [Testing Features on AGL](#testing-features-on-agl)
9     - [Build Layer](#build-layer)
10     - [Test Vosk](#test-vosk)
11     - [Test Snips](#test-snips)
12     - [Test RASA](#test-rasa)
13 - [Supported Targets](#supported-targets)
14 - [Maintainers](#maintainers)
15
16 ## Introduction
17 The `meta-offline-voice-agent` layer integrates the Vosk API, Snips (Inference Only), and RASA to provide offline speech recognition and command execution for Automotive Grade Linux. The layer is based on the Kaldi ASR Toolkit, which allows for accurate and efficient speech recognition in the AGL platform, Snips which provides us with a lightweight Natural Language Intent Engine, and RASA a complete end-to-end ML framework for developing and creating chatbots and voice assistants.
18
19 ## Layer Status
20 **Status**: *WIP (Work In Progress)*
21
22 This layer is currently in development and integrates the Vosk, Snips (Inference Only), and RASA libraries. Speech recognition has been verified using test scripts from the [vosk-api python examples](https://github.com/alphacep/vosk-api/tree/master/python/example). Additionally, both Snips and RASA have undergone testing and verification to ensure their functionality. Currently, work on command execution is still in progress.
23
24 ## External Dependencies
25 This layer depends on the following external layers:
26 - [meta-tensorflow](https://git.yoctoproject.org/meta-tensorflow)
27
28 ## Working Features
29 The following features are currently working in the `meta-offline-voice-agent` layer:
30 - [Vosk API (Python)](https://github.com/alphacep/vosk-api/tree/master/python)
31 - [Vosk Websocket Server](https://github.com/alphacep/vosk-server/tree/master/websocket)
32 - [Snips Inference](https://github.com/malik727/snips-inference-agl)
33 - [RASA](https://github.com/RasaHQ/rasa)
34
35 ## Testing Features on AGL
36     
37 ### Build Layer
38 In order to test the features of this layer you first need to build it as part of your final AGL image. First of all ensure that you have all the external layer dependencies included. Then you can use the following set of commands to initialize and build this layer into the `agl-demo-platform` qemux86_64 image:
39 ```shell
40 $ source master/meta-agl/scripts/aglsetup.sh -m qemux86-64 -b build-master agl-demo agl-devel agl-offline-voice-agent
41 $ source agl-init-build-env
42 $ bitbake agl-demo-platform
43 ```
44
45 The build can take anywhere from 6 hours to 24 hours or even more depending upon compute power of your machine. After the build completes you can use the following command to boot into your AGL image: (you need to install QEMU if not already for the command to work)
46 ```shell
47 $ runqemu tmp/deploy/images/qemux86-64/agl-demo-platform-qemux86-64.qemuboot.conf kvm serialstdio slirp publicvnc audio
48 ```
49
50 ### Test Vosk
51 (**Not Recommended**) The simplest way to test Vosk API is by using the following command: 
52 ```shell
53 $ ptest-runner python3-vosk-api
54 ```
55
56 In order for the above command to work you need to turn on `ptests` by adding the following lines to your `local.conf` that can be found at `meta-agl-devel/templates/feature/agl-offline-voice-agent/50_local.conf.inc`:
57 ```shell
58 DISTRO_FEATURES:append = " ptest"
59 EXTRA_IMAGE_FEATURES += "ptest-pkgs"
60 ```
61
62 The above method may be the easiest one but it's not recommended because `ptests` increase the image build times by a substantial amount. You can look into the official [vosk-api docs](https://alphacephei.com/vosk/install) for usage and other ways of testing.
63
64 ### Test Snips
65 In order to test the Snips NLU Intent Engine you can use the sample [pre-trained model](https://github.com/malik727/snips-model-agl), by default it automatically gets built into the target image when you include this layer. To perform inference using this model you can run the following command inside your target image:
66 ```shell
67 $ snips-inference parse /usr/share/nlu/snips/model/ -q "your command here"
68 ```
69
70 This is just a sample model and may not be able to handle all types of commands. You can always train your own intent engine model using your custom dataset, for more details on how to do that you can look into the README files of [snips-sdk-agl](https://github.com/malik727/snips-sdk-agl), [snips-model-agl](https://github.com/malik727/snips-model-agl), and [snips-inference-agl](https://github.com/malik727/snips-inference-agl).
71
72 ### Test RASA
73 In order to test the RASA NLU Intent Engine you can use the sample [pre-trained model](https://github.com/malik727/rasa-model-agl), by default it automatically gets built into the target image when you include this layer. To perform inference using this model you can run the following command inside your target image:
74 ```shell
75 $ rasa shell -m /usr/share/nlu/rasa/models/
76 ```
77
78 This will open an interactive shell where you can issue commands and get related results. This is just a sample model and may not be able to handle all types of commands. You can always train your own RASA intent engine model using your custom dataset by following the official [RASA docs](https://rasa.com/docs/rasa/).
79
80 ## Supported Targets
81 Currently, the following targets are fully supported:
82 - QEMU x86-64 (work in progress)
83
84 ## Maintainers
85 - Malik Talha <talhamalik727x@gmail.com>
86 - Aman Arora <aman.arora9848@gmail.com>
87