A bot based Voice Assistant (like Cortana) for Android using Azure Speech Service, DirectLine Speech and Bot Framework
- Visual Studio 2022
- Access to create resources in Azure and app registrations in Azure Active Directory
- Follow this instruction to have Azure Speech Service, Bot Framework Bot, DirectLine Speech installed and configured
- Keep note of where you download the custom keyword model file.
- Install Xamarin on your desktop
- Clone/download this project to your computer
- Open the
VoiceBotMobile.sln
in VS2022 - Click
Build Solution
from the Build menu to restore the nuget packages - Open
Constants.cs
file in the project..\VoiceBotMobile.Xamarin\VoiceBotMobile.Xamarin
- Paste the Azure Speech Service (that you created as part of Pre-requisites) Key for the variable
CognitiveServicesApiKey
- Paste the Azure Speech Service (that you created as part of Pre-requisites) Region/location for the variable
CognitiveServicesRegion
- Click Save
- Click on
Tools\Android\Android Device Manager
menu and create a profile forPixel
and model andx86
as the processor.- This is needed as the Speech SDK current version does not support other processor types yet.
- Open
MainPage.xaml.cs
file and update the value ofkwsModelFile
to the keyword model file that you downloaded as Pre-Requisite- Add the model file to the
Assets
folder insideVoiceBotMobile.Xamarin.Android\Assets
project and set its build action toAndroidAsset
- Add the model file to the
- Once create, click
Start
to start the emulator. - In VS 2022, select the profile you created in step 8 in the
Run
drop down tool bar and click F5- This will take few mins to build and run the app in the simulator
- When finished, you should see the app load with 2 buttons
- Click the
Enable Microphone
to allow microphone - Then in the emulator, click the
...
on the side bar to open settings - Click on
Settings
and underGeneral
make sure the toggle switch to use host audio input is selected- This is so that when you speak, the app will recognize it from the mic associated with you laptop
- Now, click
Start speech recognition
button to initiate voice chat - You should hear the bot say
Hello and welcome
. IT should also be displayed in a text area above the buttons - Now you can say into the mic of your system,
<<wake keyword that you configured as pre-requisite>> good morning
. - The app should now respond by echoing what you stated.