SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Add Speech-to-Text to Your Chatbot (with recorder)

Let users talk with your SAP Conversational AI chatbot inside an SAPUI5 app using the speech-to-text APIs of the Web Client bridge, including the media recorder feature, and an external speech-to-text service.

Overview

🎓 beginner 20 min. SAP Conversational AiBeginnerSapui5JavascriptMachine LearningArtificial IntelligenceSAP Business Technology Platform

You will learn

  • How to add speech-to-text to your chatbot inside SAPUI5
  • How to use the built-in media recorder functionality of the chatbot
Unknown U Unknown November 4, 2022
Created by March 23, 2022
Contributors

Prerequisites

Prerequisites

Steps

Intro

The speech-to-text capabilities of SAP Conversational AI include:

  • Adding a microphone button and capturing the user’s click.
  • Automatically handling capturing voice from the browser (Media Record)
  • Creating a small area to view in real-time the transcription of the voice
  • Enabling developers to add the interim transcription to this transcription area
  • Adding hooks for, among other events, recognizing when the speech has stopped and adding the transcribed text as a message in the chatbot conversation

Example chatbot
Example chatbot
 

Ways to implement speech to text

Basically, there are 4 ways to implement speech to text for SAP Conversational AI:

  • Without using the speech-to-text features of the chatbot, handling the voice recognition outside the chatbot, and sending a message to the chatbot using the Web Client APIs.
  • Using the speech-to-text features, but without the Media Recorder and interim text features.
  • Using the speech-to-text features, but without the Media Recorder feature.
  • Using all the speech-to-text features.

This tutorial will show an example of #4 – all the features from SAP Conversational AI, including having the chatbot handle capturing the audio via the browser.

The speech-to-text APIs are documented in the SAPConversationalAI / WebClientDevGuide GitHub repo.


Step 1 Understand the speech-to-text features

The speech-to-text features include displaying a microphone within the chatbot in order to start talking with the bot (1).

Starting microphone
Starting microphone

SAP Conversational AI lets you capture when a user clicks on the microphone, and lets you start the speech recognition and send interim transcriptions to the temporary transcription area of the chatbot (2).

While talking, the user can either end the session and keep the text or abort and throw away the transcription.

Once the session is over, because the user stopped talking long enough or because the user clicked the microphone button again, the text is sent as an utterance into the conversation. (3)

Other features
Other features

Step 2 Add Web Client script
+
Step 3 Add base class for speech-to-text functions
+
Step 4 Add implementation
+
Step 5 Add URL and token
+
Step 6 Add references to JavaScript files
+
Step 7 Try out the app
+
Step 8 Test yourself
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 8
1. Understand the speech-to-text features 2. Add Web Client script 3. Add base class for speech-to-text functions 4. Add implementation 5. Add URL and token 6. Add references to JavaScript files 7. Try out the app 8. Test yourself

Learn more →