Categories: ANDROID APP

The right way to give voice command to your cellphone out of your {custom} Android App to carry out sure operations?



This video exhibits the steps to create a voice enter or Audio recorder App utilizing Speech Recognizer API in Android. This idea can be utilized to design your {custom} App in such a method that it takes voice command as an enter to carry out sure operations akin to opening a file, beginning one other App like WhatsApp or calling a cellphone quantity or sending an SMS.

On this App it creates an ACTION_RECOGNIZE_SPEECH intent used to pay attention on a SpeechRecognizer API. It creates a easy Structure with a textView to point out the phrases spoken and begin/ cease button to start out and cease listening the SpeechRecognizer. The testing of this App could not be proven within the Emulator because the enter supply(microphone) of the Emulator typically does not works with the Laptop computer. So, the testing throughout this video was completed on an actual cellphone related to the laptop computer by way of USB cable.

The screenshots of the check outcomes together with the entire supply code with will be discovered within the beneath webpage:
https://programmerworld.co/android/how-to-give-voice-command-to-your-phone-from-your-custom-android-app-to-perform-certain-operations/

We hope you want this video. For any question, strategies or appreciations we will probably be glad to listen to from you at: programmerworld1990@gmail.com or go to us at: https://programmerworld.co

Java Code:

package deal com.instance.myvoicecommandapp;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;

import android.Manifest;
import android.content material.Intent;
import android.content material.pm.PackageManager;
import android.os.Bundle;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.view.View;
import android.widget.TextView;

import java.util.ArrayList;

import static android.Manifest.permission.RECORD_AUDIO;

public class MainActivity extends AppCompatActivity {

non-public SpeechRecognizer speechRecognizer;
non-public Intent intentRecognizer;
non-public TextView textView;

@Override
protected void onCreate(Bundle savedInstanceState) {
tremendous.onCreate(savedInstanceState);
setContentView(R.format.activity_main);

ActivityCompat.requestPermissions(this, new String[]{RECORD_AUDIO}, PackageManager.PERMISSION_GRANTED);

textView = findViewById(R.id.textView);
intentRecognizer = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intentRecognizer.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);

speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
speechRecognizer.setRecognitionListener(new RecognitionListener() {
@Override
public void onReadyForSpeech(Bundle bundle) {

}

@Override
public void onBeginningOfSpeech() {

}

@Override
public void onRmsChanged(float v) {

}

@Override
public void onBufferReceived(byte[] bytes) {

}

@Override
public void onEndOfSpeech() {

}

@Override
public void onError(int i) {

}

@Override
public void onResults(Bundle bundle) {
ArrayList ANGULAR_BRACKET String ANGULAR_BRACKET matches = bundle.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
String string = “”;
if(matches!=null){
string = matches.get(0);
textView.setText(string);
}

}

@Override
public void onPartialResults(Bundle bundle) {

}

@Override
public void onEvent(int i, Bundle bundle) {

}
});
}

public void StartButton(View view){
speechRecognizer.startListening(intentRecognizer);
}

public void StopButton(View view){

speechRecognizer.stopListening();
}
}

source

linda

Recent Posts

Essential Tips for Successful Condo Renovation

Before embarking on the renovation journey, it's crucial to comprehend what the process involves. Condo…

20 hours ago

Tips on how to Maximize Your Glory Casino Benefit

Hey there, fellow casino lover! If you're on the hunt to help make the most…

1 day ago

How to Maximize Wins on Glory Casino

Hey there, fellow gaming enthusiast! Are you ready to dive into the exciting world of…

2 days ago

Best Private Universities to Consider throughout Turkey

Hey there! So you're interested in studying in Turkey? That's a fantastic choice! Egypt is…

2 days ago

Best Benefits of Harbor City Hemp

Welcome to the world of Harbor Town Hemp! If you're curious about exactly how hemp…

4 days ago

Common Issues with Gear Pumps and Solutions

Before we discuss the issues, let's quickly review what a gear pump is. A gear…

4 days ago