This week, we focussed on refactoring and testing code for both AskBob and the configuration generator web app.
Speech module refactoring
In our integration meetings, the video conferencing team requested the ability to upload audio files of speech to AskBob in order to produce a response. This new requirement guided the restructuring of the AskBob speech module.
First, the utterance service – responsible for collecting audio frames comprising spoken utterances – was wholly decoupled from the transcriber: the utterance service dependency in the transcriber is now addressed via constructor injection at runtime.
From here, the utterance service, which previously was responsible for compiling audio frames from both live (via the microphone) and prerecorded (via .wav
files) sources, was split into three:
askbob.speech.listener.mic.MicUtteranceService
- audio from the user’s microphoneaskbob.speech.listener.file.FileUtteranceService
- audio from a.wav
fileaskbob.speech.listener.listener.UtteranceService
- a base class with methods shared by both theMicUtteranceService
and theFileUtteranceService
(most importantly, theutterances()
generator method
/voicequery endpoint
The refactoring of the AskBob speech module allowed us to add a /voicequery
RESTful API endpoint to which 16000Hz single-channel RIFF .wav
files may be uploaded. If valid, AskBob transcribes the first complete line of speech contained within .wav
file and produces a JSON response in the normal fashion.
This has allowed the video conferencing team to use AskBob to take over speech-to-text from IBM Watson to provide a more private querying experience for their users.
Slots
Rasa slots – a form of ‘short-term memory’ for the voice assistant – were implemented this week as well. They may be declared using the following format in JSON configuration files.
{
"slots" : [
{
"slot_id" : "slot_id",
"type": "text",
"influence_conversation": false
}
]
}
There is support for the following slot types:
text
bool
categorical
(also adds thevalues
option, a list of acceptable values for the type)float
(also addsmin_value
andmax_value
options, which are0.0
and1.1
by default)list
any
Additional information on the usage of slots may be found at the Rasa documentation.
Configuration generator web app
We also looked into testing using Jest
: a JavaScript testing framework. We have been using it to test whether the correct items are correctly rendered on the screen and determine whether only valid nodes are present in the DOM.
Unit testing using Jest will be useful to ensure that the configuration generator web app is working as expected, especially the reducer and actions. Furthermore, emulating user actions, such as entering form data, will allow us to model the whole user experience as part of our testing strategy.
We have also written a form factory to reduce code reduplication. Instead, similar forms – namely, the intent, synonym, regex, lookup, and response forms – can be made using the same base component that takes in different props as arguments.
Next week, tests will be written for reducer.