Guide to Orbita Voice Mobile SDK (Android)
The Orbita Voice Android SDK will enable the integration of Orbita Voice services across Android apps. Development of services such as audio processing, speech to text conversion from scratch can be time-consuming. For this reason, Orbita has developed the SDK that can integrate all the voice-related services that a business requires, for easy and quick implementation.
Prerequisites
Android OS Version 21 or later (Lollipop or later)
Get started with Orbita Voice SDK Installation
Unzip the two SDK files named:
orbitaspeech (Voice SDK Package)
sdk (Web Service SDK Package)
Contact Orbita Support to access the above-mentioned files.
SDK installation in Android Studio
Open Android Studio.
Create or open a project in which the SDK has to be installed.
To import the unzipped files, select “Import Module” from the Main menu – File – New.
Browse the address where you unzipped the file orbitaspeech.
After selecting the directory, please make sure the module name is “:orbitaspeech”.
Click Finish.
Repeat Step 2 to import the next module.
Browse the address where you unzipped the file sdk.
After selecting the directory, please make sure the module name is “:sdk”.
Click Finish.
You should now see both orbitaspeech and sdk modules in the current project directory.
Error Handling
The Gradle plugin version that is used for Orbita SDK is 0.8.2
If the Gradle version in Android studio is 8.3 or newer, Gradle sync will fail.
We will have to change the latest version of the le plugin. For that, select “build.gradle” from <Project name> directory – orbitaspeech – src.
Select the code ‘google.protobuf:protobuf-gradle-plugin:0.8.2’ (shown in the screenshot below).
Press alt+enter to get a dropdown menu.
Select “Change to <new version number>”.
Click on the “Try Again” link at the top of the tab to run Gradle sync.
Using the SDK
Login to Orbita services
Req payload: {"password": " ","username": ""}
// Prepare the user info to get the user name and password
final User userInfo = new User();
userInfo.setUsername(email);
userInfo.setPassword(password);
// Start the login task
ApiService.login(getApplicationContext(), userInfo, new ApiService.AuthorizationCallback() {
@Override
public void onSuccess() {
// login sucess
}
@Override
public void onFailure(String info) {
//show error message
}
});
The SDK will decode the java web token and save the authorization token in the share preferences.
The response will be the decoded JWT.
Sample Response
{
"_id": "58v72a68434f94a80803f3bc",
"roles": [
"admin"
],
"firstName": "John",
"lastName": "Smith",
"avatarSrc": "img/avatar0.jpg",
"attributes": {
"oauthSettings": {
"alexa": {
"userId": "G2M740NPXVIGU5",
"access": {
"expiresAt": "2018-05-15T18:36:55+05:30",
"tokenSecret": "",
"token": ""
}
}
},
"email": "johnsmith@example.com",
"title": "Patient",
"pinSecurityExpired": "2018-05-03T12:07:46.586Z"
},
"token": "",
"personaType": "655f9e309g0h67381784i15j",
"personaProfile": {
"username": "johnsmith@example.com",
"firstName": "John",
"lastName": "smith",
"securityPin": "1234",
"securityPinInterval": "1",
"timezone": "America/Chicago"
},
"iat": 1526480494,
"exp": 1526494894
}
Using OrbitaSpeechRecognizer Class for Audio Processing
Post Utterance to Orbita Voice server
Instantiate the OrbitaSpeechRecognizer class.
private OrbitaSpeechRecognizer mRecognizer;
mRecognizer = new OrbitaSpeechRecognizer(context.getApplicationContext());
Instantiate the OrbitaSpeechRecognizerListener class.
Set Listener to the Speech Recognizer
To Start recognizing use this code
Once we start recognition session it will be stopped automatically on speech end, if you want to stop recognition manually use this method.
We get the partial result of the Speech in onPartialResult method, this method is used to display the text while the user is speaking.
onResult is the final text output of recognizer class.
We send the request with the final result text to the server.
Sample Request:
Response :
Play Audio Content
To play the audio content from Orbita voice service.
serviceResponse - Response from orbita voice service.
audioContent - property name for audio file in response JSON.
We will be receiving a byte array of string which needs to be base 64 decoded.
The Delegate method AudioFileDidFinishPlaying will be called after the audio has finished playing.
We can use StopAudio to stop audio player anytime while the audio player is playing.
To synthesize the text from Orbita voice service to speech (TTS)
To stop the Utterance manually you can call this method.
In android, TTS is not part of the SDK, user have to write code for speech synthesis.