Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the Google speech recognizer on Android need internet?

I use the following code to invoke the voice recognizer by google:

// This is a demonstration of Android's built in speech recognizer

package com.example.voiceinputbuiltintest;

import java.util.ArrayList;
import java.util.Locale;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.speech.RecognizerIntent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

    private static final int VOICE_RECOGNITION = 1;
    Button speakButton ;
    TextView spokenWords; 

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        speakButton = (Button) findViewById(R.id.button1);  
        spokenWords = (TextView)findViewById(R.id.textView1);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    protected void onActivityResult(int requestCode,
            int resultCode,
            Intent data) {
        if (requestCode == VOICE_RECOGNITION && resultCode == RESULT_OK) {
            ArrayList<String> results;
            results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            // TODO Do something with the recognized voice strings

            Toast.makeText(this, results.get(0), Toast.LENGTH_SHORT).show();
            spokenWords.setText(results.get(0));
        }
        super.onActivityResult(requestCode, resultCode, data);
    }

    public void btnSpeak(View view){
        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        // Specify free form input
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
        RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_PROMPT,"Please start speaking");
        intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.ENGLISH);
        startActivityForResult(intent, VOICE_RECOGNITION);
    }


}  

This works without network connection in my test machine which is Nexus 7 with Android 4.3. I thought it would work the same on any android device. However, when I try it on Samsung Galaxy S2 with Android version gingerbread.el21, the voice recogniser activity shows up, but says it needs network connection and refuses to work. Why does it work in Nexus 7 and not in Galaxy S2? Does it work offline or does it need network connection? It works in the Nexus 7 even when I stop the wifi.

like image 253
user13267 Avatar asked Oct 24 '13 11:10

user13267


People also ask

Does speech recognition require Internet connection?

Depending on the app you are using, speech recognition sometimes requires an internet connection to work. Please note that some apps require to send your speech to a server in order to convert it to text.

Is Google text to speech offline?

The Speech-to-Text On-Prem allows you to deploy the Speech to Text API through a container or any GKE cluster, but that doesn't mean you can do it in your local desktop. On Android the Google's Speech-To-Text is working offline...

How does Google's voice recognition work?

A Speech-to-Text API synchronous recognition request is the simplest method for performing recognition on speech audio data. Speech-to-Text can process up to 1 minute of speech audio data sent in a synchronous request. After Speech-to-Text processes and recognizes all of the audio, it returns a response.

What is Google speech services and do I need it?

Speech Services is a screen reader application developed by Google for its Android operating system. It powers applications to read aloud (speak) the text on the screen with support for many languages.


1 Answers

In jellybean the user needs to download the offline speech recognition package.

This article sais:

Previously, when you pressed the voice icon and spoke a command or query, Android had to digitize your voice, upload it to the cloud, process the waveform, turn it into text, and send the text back down to your phone. Now the phones are powerful enough that this can be built into the device, with no extra network I/O needed. As you can imagine this results in much faster voice recognition than previous versions.

The app user will have to do this:

  1. Go to “Language and Input” in the Setting
  2. Tap on "Download offline speech recognition" under the "Voice Search"
  3. Choose the language pack you want your Android device to recognize
  4. Download the pack and enjoy the offline voice typing

Another helper link:

Google have restricted certain Jelly Bean devices from using the offline recognition due to hardware constraints.

like image 102
Dyna Avatar answered Nov 08 '22 08:11

Dyna