GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - watson-developer-cloud/speech-android-sdk: DEPRECATED - Please use https://github.com/watson-developer-cloud/android-sdk

This repository was archived by the owner on Jul 20, 2019. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

114 Commits
114 Commits

Folders and files

NameName
Last commit message
Last commit date
examples
examples
 
 
gradle/wrapper
gradle/wrapper
 
 
speech-android-wrapper
speech-android-wrapper
 
 
.gitignore
.gitignore
 
 
.project
.project
 
 
CONTRIBUTIONS.txt
CONTRIBUTIONS.txt
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

Watson Speech Android SDK

The Watson Speech SDK for the Android platform enables an easy and lightweight interaction with the IBM's Watson Speech-To-Text (STT) and Text-To-Speech (TTS) services in Bluemix. The SDK includes support for recording and streaming audio in real time to the STT service while receiving a transcript of the audio as you speak. This project includes an example application that showcases the interaction with both the STT and TTS Watson services in the cloud.

The current version of the SDK uses a minSdkVersion of 9, while the example application uses a minSdkVersion of 16.

Table of Contents

  • Watson Developer Cloud Speech APIs

    • Installation

    • Getting Credentials

    • A Quick Start Guide

    • Speech To Text

      • Implement the delegates
      • Instantiate the SpeechToText instance
      • List supported models
      • Get model details
      • Start Audio Transcription
      • End Audio Transcription
      • Speech power levels
    • Text To Speech

      • Instantiate the TextToSpeech instance
      • List supported voices
      • Generate and play audio

Installation

Using the library

  1. Download the speech-android-wrapper.aar
  2. Once unzipped drag the speech-android-wrapper.aar file into your Android Studio project view under the libs folder.
  3. Go to build.gradle file of your app, then set the dependencies as below:
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile (name:'speech-android-wrapper',ext:'aar')
        compile 'com.android.support:appcompat-v7:22.0.0'
    }
    repositories{
        flatDir{
            dirs 'libs'
        }
    }
  1. Clean and run the Android Studio project

Getting credentials

  1. Create an account on Bluemix if you have not already.
  2. Follow instructions at Service credentials for Watson services to get service credentials.

A Quick Start Guide

To get started, you can also take a look at a quick start guide created by @KeyOnTech.

Speech To Text

Implement the ISpeechDelegate and SpeechRecorderDelegate in the MainActivity

These delegates implement the callbacks when a response from the server is received or when the recorder is sending back the audio data. SpeechRecorderDelegate is optional.

   public class MainActivity extends Activity implements ISpeechDelegate{}

Or with SpeechRecorderDelegate

   public class MainActivity extends Activity implements ISpeechDelegate, SpeechRecorderDelegate{}

Instantiate the SpeechToText instance

   SpeechToText.sharedInstance().initWithContext(new URI("wss://stream.watsonplatform.net/speech-to-text/api"), this.getApplicationContext(), new SpeechConfiguration());

Enabling audio compression

By default audio sent to the server is uncompressed PCM encoded data, compressed audio using the Opus codec can be enabled.

   SpeechToText.sharedInstance().initWithContext(this.getHost(STT_URL), this.getApplicationContext(), new SpeechConfiguration(SpeechConfiguration.AUDIO_FORMAT_OGGOPUS));

Or this way:

    // Configuration
    SpeechConfiguration sConfig = new SpeechConfiguration(SpeechConfiguration.AUDIO_FORMAT_OGGOPUS);
    // STT
    SpeechToText.sharedInstance().initWithContext(this.getHost(STT_URL), this.getApplicationContext(), sConfig);

Set the Credentials and the delegate

   SpeechToText.sharedInstance().setCredentials(this.USERNAME,this.PASSWORD);
   SpeechToText.sharedInstance().setDelegate(this);

Alternatively pass a token factory object to be used by the SDK to retrieve authentication tokens to authenticate against the STT service

   SpeechToText.sharedInstance().setTokenProvider(new MyTokenProvider(this.strSTTTokenFactoryURL));
   SpeechToText.sharedInstance().setDelegate(this);

Get a list of models supported by the service

   JSONObject models = getModels();

Get details of a particular model

   JSONObject model = getModelInfo("en-US_BroadbandModel");

Pick the model to be used

   SpeechToText.sharedInstance().setModel("en-US_BroadbandModel");

Start Audio Transcription

   SpeechToText.sharedInstance().recognize();

If you implemented SpeechRecorderDelegate, and needs to process the audio data which is recorded, you can use set the delegate.

   SpeechToText.sharedInstance().recognize();
   SpeechToText.sharedInstance().setRecorderDelegate(this);

Delegate methods to receive messages from the sdk

    public void onOpen() {
        // the  connection to the STT service is successfully opened
    }

    public void onError(String error) {
    	// error interacting with the STT service
    }

    public void onClose(int code, String reason, boolean remote) {
        // the connection with the STT service was just closed
    }

    public void onMessage(String message) {
        // a message comes from the STT service with recognition results
    }

End Audio Transcription

   SpeechRecognition.sharedInstance().stopRecording();

Receive speech power levels during the recognize

The amplitude is calculated from the audio data buffer, and the volume (in dB) is calculated based on it.

    @Override
    public void onAmplitude(double amplitude, double volume) {
        // your code here
    }

Text To Speech

Instantiate the TextToSpeech instance

   TextToSpeech.sharedInstance().initWithContext(this.getHost(TTS_URL));

Set the Credentials

   TextToSpeech.sharedInstance().setCredentials(this.USERNAME,this.PASSWORD);

Alternatively pass a token factory object to be used by the SDK to retrieve authentication tokens to authenticate against the TTS service

   TextToSpeech.sharedInstance().setTokenProvider(new MyTokenProvider(this.strTTSTokenFactoryURL));

Get a list of voices supported by the service

   TextToSpeech.sharedInstance().voices();

Pick the voice to be used

   TextToSpeech.sharedInstance().setVoice("en-US_MichaelVoice");

Generate and play audio

  TextToSpeech.sharedInstance().synthesize(ttsText);

Common issues

About

DEPRECATED - Please use https://github.com/watson-developer-cloud/android-sdk

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

66 stars

Watchers

2 watching

Forks

52 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.