Comment convertir la parole en texte

Dans cette section vous avez les codes pour la vidéo sur comment créer une application qui convertit une parole en texte avec sketchware. Pour cela il faut ajouter un bouton "button1", un edittext "edittext1", un moreblock "extra" et un filepicker "file" puis on utilise les codes suivants comme suite:

 Pour onButtonClick : 


 👉 Intent intent = new Intent(android.speech.RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(android.speech.RecognizerIntent.EXTRA_LANGUAGE_MODEL, android.speech.RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(android.speech.RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); intent.putExtra(android.speech.RecognizerIntent.EXTRA_PROMPT, "Speak Now"); try { startActivityForResult(intent, REQ_CODE_SPEECH_INPUT); } catch (ActivityNotFoundException a) { Toast.makeText(getApplicationContext(), "There was an error", Toast.LENGTH_SHORT).show(); } 


 Pour moreblock : 

 👉 } public static final int REQ_CODE_SPEECH_INPUT = 1; { 

 Pour filepicker onFilePicked: 


 👉 } break; case REQ_CODE_SPEECH_INPUT: if (_resultCode == RESULT_OK && null != _data) { ArrayList result = _data.getStringArrayListExtra(android.speech.RecognizerIntent.EXTRA_RESULTS); edittext1.setText(result.get(0));

Commentaires

Posts les plus consultés de ce blog

Comment créer une application qui convertit un texte en parole

Afficher le pourcentage de la batterie dans votre application

Comment créer une application d'envoi de messages SMS