¿Cómo puedo utilizar el reconocimiento de voz sin el diálogo molesto en los teléfonos Android

¿Es esto posible sin modificar las API de Android? He encontrado un artículo sobre esto. Hay un comentario que debo hacer modificaciones a las API de Android. Pero no dijo cómo hacer la modificación. ¿Puede alguien darme algunas sugerencias sobre cómo hacer eso? ¡Gracias!


He encontrado este artículo; SpeechRecognizer Sus necesidades son casi las mismas que las mías. Es una buena referencia para mí!


He resuelto totalmente este problema.
Busqué en Google un código de ejemplo útil de este sitio web de China Aquí está mi código fuente

package voice.recognition.test; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.speech.RecognitionListener; import android.speech.RecognizerIntent; import android.speech.SpeechRecognizer; import android.widget.Button; import android.widget.TextView; import java.util.ArrayList; import android.util.Log; public class voiceRecognitionTest extends Activity implements OnClickListener { private TextView mText; private SpeechRecognizer sr; private static final String TAG = "MyStt3Activity"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button speakButton = (Button) findViewById(R.id.btn_speak); mText = (TextView) findViewById(R.id.textView1); speakButton.setOnClickListener(this); sr = SpeechRecognizer.createSpeechRecognizer(this); sr.setRecognitionListener(new listener()); } class listener implements RecognitionListener { public void onReadyForSpeech(Bundle params) { Log.d(TAG, "onReadyForSpeech"); } public void onBeginningOfSpeech() { Log.d(TAG, "onBeginningOfSpeech"); } public void onRmsChanged(float rmsdB) { Log.d(TAG, "onRmsChanged"); } public void onBufferReceived(byte[] buffer) { Log.d(TAG, "onBufferReceived"); } public void onEndOfSpeech() { Log.d(TAG, "onEndofSpeech"); } public void onError(int error) { Log.d(TAG, "error " + error); mText.setText("error " + error); } public void onResults(Bundle results) { String str = new String(); Log.d(TAG, "onResults " + results); ArrayList data = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); for (int i = 0; i < data.size(); i++) { Log.d(TAG, "result " + data.get(i)); str += data.get(i); } mText.setText("results: "+String.valueOf(data.size())); } public void onPartialResults(Bundle partialResults) { Log.d(TAG, "onPartialResults"); } public void onEvent(int eventType, Bundle params) { Log.d(TAG, "onEvent " + eventType); } } public void onClick(View v) { if (v.getId() == R.id.btn_speak) { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"voice.recognition.test"); intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,5); sr.startListening(intent); Log.i("111111","11111111"); } } } 

Asegúrese de eliminar los molestos registros después de depurar!

Utilice la interfaz de SpeechRecognizer . Su aplicación necesita tener el permiso RECORD_AUDIO y, a continuación, puede crear un SpeechRecognizer, darle un RecognitionListener y luego llamar a su método startListening . Obtendrá devoluciones de llamada al oyente cuando el reconocedor de voz esté listo para comenzar a escuchar el habla y cuando reciba el habla y lo convierta al texto.

GAST tiene una práctica clase abstracta que puedes usar para usar la clase SpeechRecognizer con muy poco código nuevo. También hay un ejemplo de ejecución de SpeechRecognizer como un servicio de fondo utilizando esto y esto

¡Gracias por publicar esto! Me pareció útil para definir el oyente onclick en oncreate:

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mText = (TextView) findViewById(R.id.textView1); MyRecognitionListener listener = new MyRecognitionListener(); sr = SpeechRecognizer.createSpeechRecognizer(this); sr.setRecognitionListener(listener); findViewById(R.id.button1).setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US"); intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,1); intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"voice.recognition.test"); sr.startListening(intent); } }); } 

He tratado de almacenar todo mi aprendizaje de TTS y STT en este Repo Github . Si te gustan los forros, entonces puedes usar mi proyecto.

Utilizó el patrón de fábrica para convertir el discurso al texto en línea sin el diálogo molesto

SpeechToText (STT) .

  TranslatorFactory.getInstance().getTranslator(TranslatorFactory.TRANSLATOR_TYPE.SPEECH_TO_TEXT, HomeActivity.this) .initialize("Hello There", HomeActivity.this); 

Salida : –

Introduzca aquí la descripción de la imagen

TextToSpeech (TTS)

 TranslatorFactory.getInstance().getTranslator(TranslatorFactory.TRANSLATOR_TYPE.TEXT_TO_SPEECH, HomeActivity.this) .initialize((null != message && !message ? message : "Invalid Input"), HomeActivity.this); 

Salida : –

Introduzca aquí la descripción de la imagen

  • Biometría de voz para Android
  • Guardar la entrada de audio del motor de reconocimiento de voz de Android Stock
  • ¿Inicia Google Now o la búsqueda por voz por defecto del teléfono?
  • Tiempo de espera del reconocimiento de voz de Google
  • Tiempo de espera del reconocimiento de voz de Google
  • Integre el reconocimiento de voz de Google en la aplicación para Android
  • Birmana discurso a la conversión de texto en android?
  • SpeechRecognizer sin conexión ERROR_NO_MATCH
  • Reconocimiento de voz como servicio de fondo
  • Cómo leer mensajes de voz por programación en Android
  • Cómo construir BufferReceived () para capturar la voz usando RecognizerIntent?
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.