SlideShare une entreprise Scribd logo
1  sur  9
Développer sur Android
Android Lab Test
www.AndroidLabTest.com
Facebook
Par Bruno Delb
www.youtube.com/androidlabtest
www.twitter.com/brunodelb | www.facebook.com/brunodelb | blog.brunodelb.com
www.facebook.com/Androidlabtest
Youtube
Siteofficiel
Leçon : La reconnaissance vocale
La reconnaissance vocale
• Dans cette leçon, vous allez apprendre à utiliser la
reconnaissance vocale.
• Pour cela, vous allez utiliser l’Intent
ACTION_RECOGNIZE_SPEECH.
La reconnaissance vocale
• Pour utiliser le système de reconnaissance vocale, utilisez l’intent ACTION_RECOGNIZE_SPEECH.
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Talk now !");
try {
startActivityForResult(intent, 123);
} catch (ActivityNotFoundException e) {
// Logiciel de reconnaissance vocale non installé
}
• Une fois que le moteur a analysé le son, il renvoie le résultat via l’intent.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 123) && resultCode == Activity.RESULT_OK) {
// Analyse du résultat
}
}
}
La reconnaissance vocale
• Si le logiciel de reconnaissance vocale n’a pas pu être trouvé, il peut être
installé automatiquement :
Intent intentInstall = new Intent(
Intent.ACTION_VIEW,
Uri.parse("market://details?id=com.google.android.voicesearch")
);
• Dans la méthode onActivityResult, le résultat de l’analyse se
trouve dans l’argument data sous forme d’ArrayList de String :
ArrayList<String> results =
data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
String text = "";
for (String result : results) {
text += result + "n";
}
et_output.setText (text);
Layout main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:id="@+id/et_output"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="Enter a value" />
</LinearLayout>
Fichier Main.javapublic class Main extends Activity {
private static final int REQUEST_CODE = 1;
EditText et_output;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
et_output = (EditText)findViewById (R.id.et_output);
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Talk now !");
try {
startActivityForResult(intent, REQUEST_CODE);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, "No recognition software installed. Download it.",
Toast.LENGTH_SHORT).show();
Intent intentInstall = new Intent(
Intent.ACTION_VIEW,
Uri.parse("market://details?id=com.google.android.voicesearch")
);
}
}
Fichier Main.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
ArrayList<String> results =
data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
String text = "";
for (String result : results) {
text += result + "n";
}
et_output.setText (text);
} else {
Toast.makeText(this, "Operation failed", Toast.LENGTH_SHORT).show();
}
}
}
}
Testez sur votre mobile
Media_VoiceRecognition
Retrouvez-moi sur ma chaîne AndroidLabTest …
Sur ma chaîne Youtube
https://www.youtube.com/user/mobiledevlabtest
Qui suis-je ?
Bruno Delb,
auteur du 1er livre francophone de développement d’application Java sur mobile (2002),
développeur d’applications mobiles & sociales,
parlez-moi de vos projets.
Et bien sûr sur mon site Web :
http://blog.brunodelb.com

Contenu connexe

Similaire à Android Lab Test : La reconnaissance vocale (français)

Android Lab Test : La prévisualisation de la caméra (français)
Android Lab Test : La prévisualisation de la caméra (français)Android Lab Test : La prévisualisation de la caméra (français)
Android Lab Test : La prévisualisation de la caméra (français)Bruno Delb
 
Devops for mobile iOS/Android
Devops for mobile iOS/AndroidDevops for mobile iOS/Android
Devops for mobile iOS/AndroidCedric Gatay
 
Déploiement automatique d'app iOS et/ou Android
Déploiement automatique d'app iOS et/ou AndroidDéploiement automatique d'app iOS et/ou Android
Déploiement automatique d'app iOS et/ou AndroidFlorian Chauveau
 
Android Lab Test : Le capteur gyroscope (français)
Android Lab Test : Le capteur gyroscope (français)Android Lab Test : Le capteur gyroscope (français)
Android Lab Test : Le capteur gyroscope (français)Bruno Delb
 
Soutenance Zend Framework vs Symfony
Soutenance Zend Framework vs SymfonySoutenance Zend Framework vs Symfony
Soutenance Zend Framework vs SymfonyVincent Composieux
 
Nouveautés JavaScript dans le monde Microsoft
Nouveautés JavaScript dans le monde MicrosoftNouveautés JavaScript dans le monde Microsoft
Nouveautés JavaScript dans le monde Microsoftdavrous
 
Développer une application android en 2015
Développer une application android  en 2015Développer une application android  en 2015
Développer une application android en 2015Florent Champigny
 
Les intents sous Android
Les intents sous Android Les intents sous Android
Les intents sous Android Houssem Lahiani
 
Node.js, le pavé dans la mare
Node.js, le pavé dans la mareNode.js, le pavé dans la mare
Node.js, le pavé dans la mareValtech
 
Patterns et bonnes pratiques autour de JavaScript
Patterns et bonnes pratiques autour de JavaScriptPatterns et bonnes pratiques autour de JavaScript
Patterns et bonnes pratiques autour de JavaScriptMicrosoft Technet France
 
Android Lab Test : La connectivité réseau avec HTTP (français)
Android Lab Test : La connectivité réseau avec HTTP (français)Android Lab Test : La connectivité réseau avec HTTP (français)
Android Lab Test : La connectivité réseau avec HTTP (français)Bruno Delb
 
Tutorial android - créer des apps
Tutorial android - créer des appsTutorial android - créer des apps
Tutorial android - créer des appsNoé Breiss
 
Débuter avec phonegap (APACHE CORDOVA) dans eclipse pour android
Débuter avec phonegap (APACHE CORDOVA) dans eclipse pour androidDébuter avec phonegap (APACHE CORDOVA) dans eclipse pour android
Débuter avec phonegap (APACHE CORDOVA) dans eclipse pour androidBosco Basabana
 
Initiation au développement mobile sous Android
Initiation au développement mobile sous AndroidInitiation au développement mobile sous Android
Initiation au développement mobile sous AndroidAbdelkader Rhouati
 

Similaire à Android Lab Test : La reconnaissance vocale (français) (20)

Android Lab Test : La prévisualisation de la caméra (français)
Android Lab Test : La prévisualisation de la caméra (français)Android Lab Test : La prévisualisation de la caméra (français)
Android Lab Test : La prévisualisation de la caméra (français)
 
Devops for mobile iOS/Android
Devops for mobile iOS/AndroidDevops for mobile iOS/Android
Devops for mobile iOS/Android
 
Déploiement automatique d'app iOS et/ou Android
Déploiement automatique d'app iOS et/ou AndroidDéploiement automatique d'app iOS et/ou Android
Déploiement automatique d'app iOS et/ou Android
 
Android Lab Test : Le capteur gyroscope (français)
Android Lab Test : Le capteur gyroscope (français)Android Lab Test : Le capteur gyroscope (français)
Android Lab Test : Le capteur gyroscope (français)
 
Android introvf
Android introvfAndroid introvf
Android introvf
 
TP_1.pdf
TP_1.pdfTP_1.pdf
TP_1.pdf
 
Soutenance Zend Framework vs Symfony
Soutenance Zend Framework vs SymfonySoutenance Zend Framework vs Symfony
Soutenance Zend Framework vs Symfony
 
Nouveautés JavaScript dans le monde Microsoft
Nouveautés JavaScript dans le monde MicrosoftNouveautés JavaScript dans le monde Microsoft
Nouveautés JavaScript dans le monde Microsoft
 
5.ateliers avancés
5.ateliers avancés5.ateliers avancés
5.ateliers avancés
 
Self-programming Software
Self-programming SoftwareSelf-programming Software
Self-programming Software
 
Développer une application android en 2015
Développer une application android  en 2015Développer une application android  en 2015
Développer une application android en 2015
 
Les intents sous Android
Les intents sous Android Les intents sous Android
Les intents sous Android
 
Node.js, le pavé dans la mare
Node.js, le pavé dans la mareNode.js, le pavé dans la mare
Node.js, le pavé dans la mare
 
Patterns et bonnes pratiques autour de JavaScript
Patterns et bonnes pratiques autour de JavaScriptPatterns et bonnes pratiques autour de JavaScript
Patterns et bonnes pratiques autour de JavaScript
 
Android Lab Test : La connectivité réseau avec HTTP (français)
Android Lab Test : La connectivité réseau avec HTTP (français)Android Lab Test : La connectivité réseau avec HTTP (français)
Android Lab Test : La connectivité réseau avec HTTP (français)
 
Tutorial android - créer des apps
Tutorial android - créer des appsTutorial android - créer des apps
Tutorial android - créer des apps
 
Tutorial android
Tutorial androidTutorial android
Tutorial android
 
Débuter avec phonegap (APACHE CORDOVA) dans eclipse pour android
Débuter avec phonegap (APACHE CORDOVA) dans eclipse pour androidDébuter avec phonegap (APACHE CORDOVA) dans eclipse pour android
Débuter avec phonegap (APACHE CORDOVA) dans eclipse pour android
 
Initiation au développement mobile sous Android
Initiation au développement mobile sous AndroidInitiation au développement mobile sous Android
Initiation au développement mobile sous Android
 
Des tests modernes pour Drupal
Des tests modernes pour DrupalDes tests modernes pour Drupal
Des tests modernes pour Drupal
 

Plus de Bruno Delb

Introduction to Swift (tutorial)
Introduction to Swift (tutorial)Introduction to Swift (tutorial)
Introduction to Swift (tutorial)Bruno Delb
 
Android Lab Test : Storage of data with SharedPreferences (english)
Android Lab Test : Storage of data with SharedPreferences (english)Android Lab Test : Storage of data with SharedPreferences (english)
Android Lab Test : Storage of data with SharedPreferences (english)Bruno Delb
 
Android Lab Test : Using the sensor gyroscope (english)
Android Lab Test : Using the sensor gyroscope (english)Android Lab Test : Using the sensor gyroscope (english)
Android Lab Test : Using the sensor gyroscope (english)Bruno Delb
 
Android Lab Test : Using the network with HTTP (english)
Android Lab Test : Using the network with HTTP (english)Android Lab Test : Using the network with HTTP (english)
Android Lab Test : Using the network with HTTP (english)Bruno Delb
 
Android Lab Test : Managing sounds with SoundPool (english)
Android Lab Test : Managing sounds with SoundPool (english)Android Lab Test : Managing sounds with SoundPool (english)
Android Lab Test : Managing sounds with SoundPool (english)Bruno Delb
 
Android Lab Test : Using the text-to-speech (english)
Android Lab Test : Using the text-to-speech (english)Android Lab Test : Using the text-to-speech (english)
Android Lab Test : Using the text-to-speech (english)Bruno Delb
 
Android Lab Test : Reading the foot file list (english)
Android Lab Test : Reading the foot file list (english)Android Lab Test : Reading the foot file list (english)
Android Lab Test : Reading the foot file list (english)Bruno Delb
 
Android Lab Test : Creating a menu dynamically (english)
Android Lab Test : Creating a menu dynamically (english)Android Lab Test : Creating a menu dynamically (english)
Android Lab Test : Creating a menu dynamically (english)Bruno Delb
 
Android Lab Test : Creating a dialog Yes/No (english)
Android Lab Test : Creating a dialog Yes/No (english)Android Lab Test : Creating a dialog Yes/No (english)
Android Lab Test : Creating a dialog Yes/No (english)Bruno Delb
 
Android Lab Test : The styles of views (english)
Android Lab Test : The styles of views (english)Android Lab Test : The styles of views (english)
Android Lab Test : The styles of views (english)Bruno Delb
 
Android Lab Test : Creating a menu context (english)
Android Lab Test : Creating a menu context (english)Android Lab Test : Creating a menu context (english)
Android Lab Test : Creating a menu context (english)Bruno Delb
 
Android Lab Test : Using the camera preview (english)
Android Lab Test : Using the camera preview (english)Android Lab Test : Using the camera preview (english)
Android Lab Test : Using the camera preview (english)Bruno Delb
 
Android Lab Test : The views, the Gallery (english)
Android Lab Test : The views, the Gallery (english)Android Lab Test : The views, the Gallery (english)
Android Lab Test : The views, the Gallery (english)Bruno Delb
 
Android Lab Test : Using the WIFI (english)
Android Lab Test : Using the WIFI (english)Android Lab Test : Using the WIFI (english)
Android Lab Test : Using the WIFI (english)Bruno Delb
 
Android Lab Test : Managing the telephone calls (english)
Android Lab Test : Managing the telephone calls (english)Android Lab Test : Managing the telephone calls (english)
Android Lab Test : Managing the telephone calls (english)Bruno Delb
 
Android Lab Test : Reading the SMS-inbox (english)
Android Lab Test : Reading the SMS-inbox (english)Android Lab Test : Reading the SMS-inbox (english)
Android Lab Test : Reading the SMS-inbox (english)Bruno Delb
 
Android Lab Test : Installation of application in Java (english)
Android Lab Test : Installation of application in Java (english)Android Lab Test : Installation of application in Java (english)
Android Lab Test : Installation of application in Java (english)Bruno Delb
 
Android Lab Test : Ecrire un texte sur le canevas (français)
Android Lab Test : Ecrire un texte sur le canevas (français)Android Lab Test : Ecrire un texte sur le canevas (français)
Android Lab Test : Ecrire un texte sur le canevas (français)Bruno Delb
 
Android Lab Test : Les threads (français)
Android Lab Test : Les threads (français)Android Lab Test : Les threads (français)
Android Lab Test : Les threads (français)Bruno Delb
 
Android Lab Test : Le stockage avec SharedPreferences (français)
Android Lab Test : Le stockage avec SharedPreferences (français)Android Lab Test : Le stockage avec SharedPreferences (français)
Android Lab Test : Le stockage avec SharedPreferences (français)Bruno Delb
 

Plus de Bruno Delb (20)

Introduction to Swift (tutorial)
Introduction to Swift (tutorial)Introduction to Swift (tutorial)
Introduction to Swift (tutorial)
 
Android Lab Test : Storage of data with SharedPreferences (english)
Android Lab Test : Storage of data with SharedPreferences (english)Android Lab Test : Storage of data with SharedPreferences (english)
Android Lab Test : Storage of data with SharedPreferences (english)
 
Android Lab Test : Using the sensor gyroscope (english)
Android Lab Test : Using the sensor gyroscope (english)Android Lab Test : Using the sensor gyroscope (english)
Android Lab Test : Using the sensor gyroscope (english)
 
Android Lab Test : Using the network with HTTP (english)
Android Lab Test : Using the network with HTTP (english)Android Lab Test : Using the network with HTTP (english)
Android Lab Test : Using the network with HTTP (english)
 
Android Lab Test : Managing sounds with SoundPool (english)
Android Lab Test : Managing sounds with SoundPool (english)Android Lab Test : Managing sounds with SoundPool (english)
Android Lab Test : Managing sounds with SoundPool (english)
 
Android Lab Test : Using the text-to-speech (english)
Android Lab Test : Using the text-to-speech (english)Android Lab Test : Using the text-to-speech (english)
Android Lab Test : Using the text-to-speech (english)
 
Android Lab Test : Reading the foot file list (english)
Android Lab Test : Reading the foot file list (english)Android Lab Test : Reading the foot file list (english)
Android Lab Test : Reading the foot file list (english)
 
Android Lab Test : Creating a menu dynamically (english)
Android Lab Test : Creating a menu dynamically (english)Android Lab Test : Creating a menu dynamically (english)
Android Lab Test : Creating a menu dynamically (english)
 
Android Lab Test : Creating a dialog Yes/No (english)
Android Lab Test : Creating a dialog Yes/No (english)Android Lab Test : Creating a dialog Yes/No (english)
Android Lab Test : Creating a dialog Yes/No (english)
 
Android Lab Test : The styles of views (english)
Android Lab Test : The styles of views (english)Android Lab Test : The styles of views (english)
Android Lab Test : The styles of views (english)
 
Android Lab Test : Creating a menu context (english)
Android Lab Test : Creating a menu context (english)Android Lab Test : Creating a menu context (english)
Android Lab Test : Creating a menu context (english)
 
Android Lab Test : Using the camera preview (english)
Android Lab Test : Using the camera preview (english)Android Lab Test : Using the camera preview (english)
Android Lab Test : Using the camera preview (english)
 
Android Lab Test : The views, the Gallery (english)
Android Lab Test : The views, the Gallery (english)Android Lab Test : The views, the Gallery (english)
Android Lab Test : The views, the Gallery (english)
 
Android Lab Test : Using the WIFI (english)
Android Lab Test : Using the WIFI (english)Android Lab Test : Using the WIFI (english)
Android Lab Test : Using the WIFI (english)
 
Android Lab Test : Managing the telephone calls (english)
Android Lab Test : Managing the telephone calls (english)Android Lab Test : Managing the telephone calls (english)
Android Lab Test : Managing the telephone calls (english)
 
Android Lab Test : Reading the SMS-inbox (english)
Android Lab Test : Reading the SMS-inbox (english)Android Lab Test : Reading the SMS-inbox (english)
Android Lab Test : Reading the SMS-inbox (english)
 
Android Lab Test : Installation of application in Java (english)
Android Lab Test : Installation of application in Java (english)Android Lab Test : Installation of application in Java (english)
Android Lab Test : Installation of application in Java (english)
 
Android Lab Test : Ecrire un texte sur le canevas (français)
Android Lab Test : Ecrire un texte sur le canevas (français)Android Lab Test : Ecrire un texte sur le canevas (français)
Android Lab Test : Ecrire un texte sur le canevas (français)
 
Android Lab Test : Les threads (français)
Android Lab Test : Les threads (français)Android Lab Test : Les threads (français)
Android Lab Test : Les threads (français)
 
Android Lab Test : Le stockage avec SharedPreferences (français)
Android Lab Test : Le stockage avec SharedPreferences (français)Android Lab Test : Le stockage avec SharedPreferences (français)
Android Lab Test : Le stockage avec SharedPreferences (français)
 

Dernier

Présentation_ Didactique 1_SVT (S4) complet.pptx
Présentation_ Didactique 1_SVT (S4) complet.pptxPrésentation_ Didactique 1_SVT (S4) complet.pptx
Présentation_ Didactique 1_SVT (S4) complet.pptxrababouerdighi
 
systeme expert_systeme expert_systeme expert
systeme expert_systeme expert_systeme expertsysteme expert_systeme expert_systeme expert
systeme expert_systeme expert_systeme expertChristianMbip
 
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .
Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .Txaruka
 
Cours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSETCours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSETMedBechir
 
Saint Georges, martyr, et la lègend du dragon.pptx
Saint Georges, martyr, et la lègend du dragon.pptxSaint Georges, martyr, et la lègend du dragon.pptx
Saint Georges, martyr, et la lègend du dragon.pptxMartin M Flynn
 
666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptx
666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptx666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptx
666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptxSAID MASHATE
 
Guide Final de rédaction de mémoire de fin d'étude
Guide Final de rédaction de mémoire de fin d'étudeGuide Final de rédaction de mémoire de fin d'étude
Guide Final de rédaction de mémoire de fin d'étudeBenamraneMarwa
 
Fondation Louis Vuitton. pptx
Fondation      Louis      Vuitton.   pptxFondation      Louis      Vuitton.   pptx
Fondation Louis Vuitton. pptxTxaruka
 
A3iFormations, organisme de formations certifié qualiopi.
A3iFormations, organisme de formations certifié qualiopi.A3iFormations, organisme de formations certifié qualiopi.
A3iFormations, organisme de formations certifié qualiopi.Franck Apolis
 
Cours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSETCours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSETMedBechir
 
Evaluation du systeme d'Education. Marocpptx
Evaluation du systeme d'Education. MarocpptxEvaluation du systeme d'Education. Marocpptx
Evaluation du systeme d'Education. MarocpptxAsmaa105193
 
7 PPT sue le project de fin d'étude.pptx
7 PPT sue le project de fin d'étude.pptx7 PPT sue le project de fin d'étude.pptx
7 PPT sue le project de fin d'étude.pptxrababouerdighi
 
Formation M2i - Comprendre les neurosciences pour développer son leadership
Formation M2i - Comprendre les neurosciences pour développer son leadershipFormation M2i - Comprendre les neurosciences pour développer son leadership
Formation M2i - Comprendre les neurosciences pour développer son leadershipM2i Formation
 

Dernier (15)

Présentation_ Didactique 1_SVT (S4) complet.pptx
Présentation_ Didactique 1_SVT (S4) complet.pptxPrésentation_ Didactique 1_SVT (S4) complet.pptx
Présentation_ Didactique 1_SVT (S4) complet.pptx
 
systeme expert_systeme expert_systeme expert
systeme expert_systeme expert_systeme expertsysteme expert_systeme expert_systeme expert
systeme expert_systeme expert_systeme expert
 
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .
Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .
 
Cours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSETCours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSET
 
Saint Georges, martyr, et la lègend du dragon.pptx
Saint Georges, martyr, et la lègend du dragon.pptxSaint Georges, martyr, et la lègend du dragon.pptx
Saint Georges, martyr, et la lègend du dragon.pptx
 
Evaluación Alumnos de Ecole Victor Hugo
Evaluación Alumnos de Ecole  Victor HugoEvaluación Alumnos de Ecole  Victor Hugo
Evaluación Alumnos de Ecole Victor Hugo
 
666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptx
666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptx666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptx
666148532-Formation-Habilitation-ELECTRIQUE-ENTREPRISE-MARS-2017.pptx
 
Guide Final de rédaction de mémoire de fin d'étude
Guide Final de rédaction de mémoire de fin d'étudeGuide Final de rédaction de mémoire de fin d'étude
Guide Final de rédaction de mémoire de fin d'étude
 
Fondation Louis Vuitton. pptx
Fondation      Louis      Vuitton.   pptxFondation      Louis      Vuitton.   pptx
Fondation Louis Vuitton. pptx
 
A3iFormations, organisme de formations certifié qualiopi.
A3iFormations, organisme de formations certifié qualiopi.A3iFormations, organisme de formations certifié qualiopi.
A3iFormations, organisme de formations certifié qualiopi.
 
Cours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSETCours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSET
 
Pâques de Sainte Marie-Euphrasie Pelletier
Pâques de Sainte Marie-Euphrasie PelletierPâques de Sainte Marie-Euphrasie Pelletier
Pâques de Sainte Marie-Euphrasie Pelletier
 
Evaluation du systeme d'Education. Marocpptx
Evaluation du systeme d'Education. MarocpptxEvaluation du systeme d'Education. Marocpptx
Evaluation du systeme d'Education. Marocpptx
 
7 PPT sue le project de fin d'étude.pptx
7 PPT sue le project de fin d'étude.pptx7 PPT sue le project de fin d'étude.pptx
7 PPT sue le project de fin d'étude.pptx
 
Formation M2i - Comprendre les neurosciences pour développer son leadership
Formation M2i - Comprendre les neurosciences pour développer son leadershipFormation M2i - Comprendre les neurosciences pour développer son leadership
Formation M2i - Comprendre les neurosciences pour développer son leadership
 

Android Lab Test : La reconnaissance vocale (français)

  • 1. Développer sur Android Android Lab Test www.AndroidLabTest.com Facebook Par Bruno Delb www.youtube.com/androidlabtest www.twitter.com/brunodelb | www.facebook.com/brunodelb | blog.brunodelb.com www.facebook.com/Androidlabtest Youtube Siteofficiel Leçon : La reconnaissance vocale
  • 2. La reconnaissance vocale • Dans cette leçon, vous allez apprendre à utiliser la reconnaissance vocale. • Pour cela, vous allez utiliser l’Intent ACTION_RECOGNIZE_SPEECH.
  • 3. La reconnaissance vocale • Pour utiliser le système de reconnaissance vocale, utilisez l’intent ACTION_RECOGNIZE_SPEECH. Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Talk now !"); try { startActivityForResult(intent, 123); } catch (ActivityNotFoundException e) { // Logiciel de reconnaissance vocale non installé } • Une fois que le moteur a analysé le son, il renvoie le résultat via l’intent. protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode == 123) && resultCode == Activity.RESULT_OK) { // Analyse du résultat } } }
  • 4. La reconnaissance vocale • Si le logiciel de reconnaissance vocale n’a pas pu être trouvé, il peut être installé automatiquement : Intent intentInstall = new Intent( Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.voicesearch") ); • Dans la méthode onActivityResult, le résultat de l’analyse se trouve dans l’argument data sous forme d’ArrayList de String : ArrayList<String> results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); String text = ""; for (String result : results) { text += result + "n"; } et_output.setText (text);
  • 5. Layout main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <EditText android:id="@+id/et_output" android:layout_width="fill_parent" android:layout_height="match_parent" android:text="Enter a value" /> </LinearLayout>
  • 6. Fichier Main.javapublic class Main extends Activity { private static final int REQUEST_CODE = 1; EditText et_output; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); et_output = (EditText)findViewById (R.id.et_output); Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Talk now !"); try { startActivityForResult(intent, REQUEST_CODE); } catch (ActivityNotFoundException e) { Toast.makeText(this, "No recognition software installed. Download it.", Toast.LENGTH_SHORT).show(); Intent intentInstall = new Intent( Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.voicesearch") ); } }
  • 7. Fichier Main.java protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode == REQUEST_CODE) { if (resultCode == Activity.RESULT_OK) { ArrayList<String> results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); String text = ""; for (String result : results) { text += result + "n"; } et_output.setText (text); } else { Toast.makeText(this, "Operation failed", Toast.LENGTH_SHORT).show(); } } } }
  • 8. Testez sur votre mobile Media_VoiceRecognition
  • 9. Retrouvez-moi sur ma chaîne AndroidLabTest … Sur ma chaîne Youtube https://www.youtube.com/user/mobiledevlabtest Qui suis-je ? Bruno Delb, auteur du 1er livre francophone de développement d’application Java sur mobile (2002), développeur d’applications mobiles & sociales, parlez-moi de vos projets. Et bien sûr sur mon site Web : http://blog.brunodelb.com