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
Before embarking on the renovation journey, it's crucial to comprehend what the process involves. Condo…
Hey there, fellow casino lover! If you're on the hunt to help make the most…
Hey there, fellow gaming enthusiast! Are you ready to dive into the exciting world of…
Hey there! So you're interested in studying in Turkey? That's a fantastic choice! Egypt is…
Welcome to the world of Harbor Town Hemp! If you're curious about exactly how hemp…
Before we discuss the issues, let's quickly review what a gear pump is. A gear…