Hi guys.
I’m trying to create a voice recognition in android. I read some topics about this topic Speech recognition for android mode and then I read about “developers documentation” SpeechRecognizer but it has no sense when I apply my knowledge about Oriented Object Programming to create own speech recognition like google assistant
I started to create the speech recognizer sp object from the class android.speech.SpeechRecognizer and then call the method sp.startListening(intent) but it collapsed
My code is here:
import android.view.View;
import android.content.Context;
import android.app.Activity;
import android.view.Gravity;
import android.graphics.Color;
import android.speech.RecognizerIntent;
import android.content.Intent;
import android.os.Vibrator;///let us take problems one after the other!!!!!
import android.os.VibrationEffect;
import android.service.voice.AlwaysOnHotwordDetector;
import android.speech.SpeechRecognizer;
import android.widget.Toast;
import java.lang.Throwable;
import java.lang.Exception;
import java.lang.RuntimeException;
import android.content.ActivityNotFoundException;
import java.util.Locale;
import android.view.ViewGroup.LayoutParams;
import android.content.Context;
///////////////////////////////////////////////////////////////////////////////////////
//variales
//OBJETOS CLASES CREADAS
Activity act;
Intent intent;
Context context;
SpeechRecognizer sp;
public void onStart()
{
act = this.getActivity();
context = act.getApplicationContext();
}
void setup()
{
fullScreen();
act = this.getActivity();
//SpeechRecognizer sp = SpeechRecognizer.createSpeechRecognizer(getActivity());
sp = SpeechRecognizer.createSpeechRecognizer(getActivity());
}
void draw() {
background(0);
sp.startListening(intent);
delay(2000);
sp.stopListening();
delay(2000);
}
I realized that with some hotwords the libraries could activate the speech, but if I don´t create the object speech recognizer, i could not follow the next step…
could you please help me?