RecognizerIntent.ACTION_RECOGNIZE_SPEECH not working in new android devices
Asked Answered
O

3

5

Following is my code for voice recognition, its saying "Recogniser not present" for latest devices and tablets.Please help me how to fix it.

public void startMyVoice()
{   
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);   
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, sayClose);   
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");

try 
{
    startActivityForResult(intent, RESULT_SPEECH);      
} 
catch (ActivityNotFoundException a) 
{                   
    Toast.makeText(getApplicationContext(), "Recogniser not present", Toast.LENGTH_SHORT).show();      
}

}
Oviposit answered 14/1, 2014 at 10:23 Comment(3)
Specifically, which devices & tablets are you referring to ?Encephalogram
Device is Galaxy-S3. Rom is Slimbean (custom Rom) 4.3. Based on CM 10.Oviposit
Same issue with Galaxy-S2 Custom Rom. mostly with Custom ROMs. is there anythin i can do or it is limitation of Custom ROMsOviposit
C
6

According to this documentation:

When an app targets Android 11 (API level 30) or higher ... To view other packages, declare your app's need for increased package visibility using the <queries> element.

So if you are using RecognizerIntent.ACTION_RECOGNIZE_SPEECH, then you will need to declare the same intent in AndroidManifest.xml outside <application> tag like this:

<manifest>

    ...

    <queries>
        <intent>
            <action android:name="android.speech.action.RECOGNIZE_SPEECH" />
        </intent>
    </queries>
</manifest>

Otherwise pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0); will always return an empty list.

Cleasta answered 19/1, 2022 at 18:48 Comment(4)
How can I find more apps that support it, to see that it indeed works? I tried to install various, but I don't think the query can find them even with the QUERY_ALL_PACKAGES permissionOdaniel
@androiddeveloper I think it is essentially for the android built-in recognizer. To see it works, try to request speech recognition in Android >=30 with and without declaring it in you manifest file.Cleasta
I mean which other apps have this ability? I tried many apps on the Play Store, and I don't think any app there supports this action.Odaniel
I didn't come across one as well. Maybe, because most Andoid phones have this built-in.Cleasta
W
1

From: Speech To Text Recognizer not found

I am not sure why the recognizer functionality is not available on all devices. Make sure you install and update the latest Google Voice Search for Android. I believe it installs the latest recognizer. See http://www.google.com/mobile/voice-actions/ it may be helpful.

As Dante Jiang said in Converting speech to text, According to this article, Google Voice Search is what you actually need.

The Android SDK makes it easy to integrate speech input directly into your own application—just copy and paste from this sample application to get started. Android is an open platform, so your application can potentially make use of any speech recognition service on the device that's registered to receive a RecognizerIntent. Google's Voice Search application, which is pre-installed on many Android devices, responds to a RecognizerIntent by displaying the "Speak now" dialog and streaming audio to Google's servers—the same servers used when a user taps the microphone button on the search widget or the voice-enabled keyboard. (You can check if Voice Search is installed in Settings ➝ Applications ➝ Manage applications.)

Witherite answered 14/1, 2014 at 10:27 Comment(1)
This Settings ➝ Applications ➝ Manage applications path does not exist on Pixel4a running Android 11. The closest I have been able to find is Apps & notifications > Apps info and in there, despite recognizer working perfectly, there is no "Google Voice Search application". The closest I have been able to find is Speech Services by Google. Is that the direct replacement for com.google.android.voicesearch?Gerber
E
1

Add Below Code In Your AndroidManifest.xml File And It Will Work.

<queries>
   <intent>
     <action
        android:name="android.speech.RecognitionService" />
   </intent>
 </queries>
Engelhart answered 10/8, 2021 at 8:5 Comment(3)
it's "android.speech.action.RECOGNIZE_SPEECH". developer.android.com/reference/android/speech/…Cleasta
The answer by @FaisalKhan is the correct one, works on Android 11, and explains the why.Gerber
@FaisalKhan @Gerber Both answers work for me. "android.speech.RecognitionService" is even used by the SpeechRecognizer.isRecognitionAvailable method if you check Android sources. It's the value of RecognitionService.SERVICE_INTERFACE.Waylen

© 2022 - 2024 — McMap. All rights reserved.