Introduction: An Android library module to Mozilla's Speech-To-Text services
More: Author   ReportBugs   

This is an Android library containing an API to Mozilla's speech recognition services.


dependencies { 
      implementation 'com.github.mozilla:mozillaspeechlibrary:2.0.0'
      implementation 'com.github.mozilla:mozillaspeechutils:2.0.0'      // Just in case you want to use the utils for downloading/unzipping

Demo app

Just run the demo application inside the folder app


The API encapsulates the microphone capture, audio encoding, voice activity detection and network communication. So for this reason its integration is very simple: just call start() and handle the events in your frontend.

First define a listener to capture the events:

SpeechResultCallback mVoiceSearchListener = new SpeechResultCallback() {

    public void onStartListen() {
        // Handle when the api successfully opened the microphone and started listening

    public void onMicActivity(double fftsum) {
        // Captures the activity from the microphone

    public void onDecoding() {
        // Handle when the speech object changes to decoding state

    public void onSTTResult(@Nullable STTResult result) {
        // When the api finished processing and returned a hypothesis

    public void onNoVoice() {
        // Handle when the api didn't detect any voice

    public void onError(@SpeechResultCallback.ErrorType int errorType, @Nullable String error) {
        // Handle when any error occurred


Create an instance of the Speech Service:

    mSpeechService = new SpeechService(this);

Start a request:

    SpeechServiceSettings.Builder builder = new SpeechServiceSettings.Builder()
        .withUseDeepSpeech(true)            // If using DeepSpeech
        .withModelPath("path/to/model");    // If using DeepSpeech
    mSpeechService.start(, mVoiceSearchListener);

In the case you want to cancel a progressing operation:


Note: Your app will need RECORD_AUDIO, WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions to be set in AndroidManifest.xml manifest and requested at runtime.

About Me
GitHub: Trinea
Facebook: Dev Tools