none
Problème avec la reconnaissance vocale RRS feed

  • Question

  • Bonjour,

    Voilà désormais une semaine que je suis concentré sur un problème sur le programme que je développe. En effet, je dispose de la reconnaissance vocale pour les langues suivantes :
    - en-US
    - en-UK
    - fr-FR

    Or actuellement, le programme que je développe est par défaut en Anglais (aucun problème de ce côté là), mais aussi en français-canadien. Par conséquent, lorsque je lance l'application, il génère une exception me disant : "La langue de la grammaire ne correspond pas à celle du module de reconnaissance vocale."

    A l'heure actuelle, je n'ai pas trouvé la reconnaissance vocale Français - Canada. 

    Merci pour votre aide,

    Pierre

    lundi 27 mai 2013 18:36

Réponses

  • Finalement, j'ai trouvé la solution. Lorsque votre application est dans une variante de langue (français-canadien par exemple), et que votre moteur de reconnaissance vocale est dans une langue générale (Français-français), lors du chargement de votre grammaire, une exception sera généré.

    Pour pallier à cette exception, l'objet grammarBuilder que vous avez utilisé détient une culture, qu'il faut obligatoirement affecter à celle du moteur de reconnaissance vocale. Car par défaut, il prend la culture de l'application. De cette manière, l'exception n'est plus généré. Il faut procéder comme ceci : 

    Choices choices = new Choices();
    choices.Add(new string[] {"a", "b"});
    
    GrammarBuilder grammarBuilder = new GrammarBuilder();
    CultureInfo culture = new CultureInfo("fr-FR");
    grammarBuilder.Culture = culture;
    grammarBuilder.Append(choices);
    
    Grammar grammar = new Grammar(grammarBuilder);
    _speechRecognizerEngine.LoadGrammar(grammar);




    • Marqué comme réponse Aurel Bera lundi 3 juin 2013 06:59
    • Modifié Pierre-msdn lundi 3 juin 2013 17:06 Complément d'information
    vendredi 31 mai 2013 18:20

Toutes les réponses

  • Bonjour Aurel,

    J'ai effectué les mises à jour, installé les packages de langues concernés, seulement la reconnaissance vocale française ne connais qu'une seule variante : French - France.

    Par conséquent, comme la l'application que je développe est en Français - Canadien, cela pose problème.

    Si vous avez d'autres propositions, je suis ouvert.

    Cordialement,

    Pierre

    mardi 28 mai 2013 14:14
  • Bonjour Aurel,

    Je suis actuellement sur windows 7 (Un sur Ultimate et l'autre sur Professionnel).

    J'avais exploré cette voix, installé le "MSSpeech_SR_fr-CA_TELE.msi". Et ensuite ? Après l'installation, le redémarrage de l'ordinateur, le package fr-CA ne s'est pas ajouté à la liste des langues de la reconnaissance vocale. 

    J'ai suivi les instructions d'installation, ce qui m'a indiqué d'installer Microsoft Speech Platform - Runtime(version 11), que j'ai installé également. Seulement après l'installation, je fais quoi ? Car cela n'a strictement rien changé, je n'ai vu aucune différence. Au passage, j'ai également installé Microsoft Speech Platform SDK.

    Pourriez-vous m'indiquer la prochaine étape ?

    Merci de me porter secours Aurel, j'apprécie le geste.

    Cordialement,

    Pierre



    mercredi 29 mai 2013 12:13
  • Dans les instructions d'installation c'est écrit que vous devez installer le Langage Pack après avoir installée Microsoft Speech Platform.
    Si vous n'avez pas fait les installations dans cette ordre essayez de les désinstaller les deux et les réinstaller dans l'ordre correcte.

    Cordialement,


    Aurel BERA, Microsoft
    Microsoft propose ce service gratuitement, dans le but d'aider les utilisateurs et d'élargir les connaissances générales liées aux produits et technologies Microsoft. Ce contenu est fourni "tel quel" et il n'implique aucune responsabilité de la part de Microsoft.

    mercredi 29 mai 2013 12:31
  • J'ai tout réinstallé dans l'ordre. Désormais, je peux changé la configuration du SDK (passer de la version 7.0 à 7.1).

    Seulement l'exception est toujours présente. Je n'ai pas la possibilité de voir les langages disponibles, ou alors je ne vois pas où cela se situe. Par conséquent je ne peux pas le modifier.

    Sinon, avez vous des exemples d'utilisations ? Ou sinon je peux vous poster le les deux classes que j'utilise pour générer l'exception ?

    Cordialement,

    Pierre

    mercredi 29 mai 2013 15:15
  • Bonjour Aurel,

    Les exemples fournis n'utilisent pas le Microsoft Speech Platform SDK 11.

    La documentation est très peu claire pour le sdk, et de plus j'ai trouvé un seul exemple sur Internet, mais qui ne fonctionne pas. J'aimerai juste un mini projet, juste pour faire fonctionner la reconnaissance du SDK.

    J'ai tout installé, je peux inclure les librairies sans problèmes, mais la documentation n'offre pas d'exemple d'utilisation. Du coup je suis bloqué, je ne sais pas m'en servir.

    Voici mon code :

    Program.cs :

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows.Forms;
    using System.Threading;
    using System.Globalization;

    namespace ProtoUI
    {
    static class Program
    {
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
    Application.CurrentCulture = new CultureInfo("fr-CA");
    Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-CA");
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());
    }
    }
    }

    Form1.cs :

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Speech.Recognition;
    
    
    namespace ProtoUI
    {
    	public partial class Form1 : Form
    	{
    		SpeechRecognitionEngine recognizer;
    
    	 public Form1()
    		{
    			InitializeComponent();
    			labelRegonizerLangue.Text += Application.CurrentCulture.Name.ToString(); 
    		}
        
        private void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
    		txtBoxSpeechRecognized.Text = e.Result.Text;
        }
    
    	private void checkBoxActivateSpeechRecogninzer_CheckedChanged(object sender, EventArgs e)
    	{
    		if (checkBoxActivateSpeechRecogninzer.Checked)
    		{
    			InitSpeechRecognition();
    		}
    		else
    		{
    			StopSpeechRecognition();
    		}
    	}
    	private void StopSpeechRecognition()
    	{
    		textBoxRecognizerState.Text = recognizer.AudioState.ToString();
    		recognizer.UnloadAllGrammars();
    		recognizer.SpeechRecognized -= new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
    		recognizer = null;
    	}
    
    	 private void InitSpeechRecognition()
    	 {
    
    		 recognizer = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("fr-CA"));
    		 recognizer.SpeechRecognized +=	new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
    
    		 Choices termList = new Choices();
    		 termList.Add(new string[] { "Green, Blue, Red, Vert, Bleu, Rouge" });
    					 		
    		 //Create grammar builder.
    		 GrammarBuilder grammarBuilder = new GrammarBuilder();
    		 grammarBuilder.Append(termList);
    
    		 // Create and load a dictation grammar.
    		 Grammar grammar = new Grammar(grammarBuilder);
    		 recognizer.LoadGrammar(grammar);
    
    		// Configure input to the speech recognizer.
    		recognizer.SetInputToDefaultAudioDevice();
    
    		// Start asynchronous, continuous speech recognition.
    		recognizer.RecognizeAsync(RecognizeMode.Multiple);
    		textBoxRecognizerState.Text = recognizer.AudioState.ToString();
      }
    
    }
    }
    		

    Form1.designer.cs : 

    namespace ProtoUI
    {
    	partial class Form1
    	{
    		/// <summary>
    		/// Required designer variable.
    		/// </summary>
    		private System.ComponentModel.IContainer components = null;
    
    		/// <summary>
    		/// Clean up any resources being used.
    		/// </summary>
    		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    		protected override void Dispose(bool disposing)
    		{
    			if (disposing && (components != null))
    			{
    				components.Dispose();
    			}
    			base.Dispose(disposing);
    		}
    
    		#region Windows Form Designer generated code
    
    		/// <summary>
    		/// Required method for Designer support - do not modify
    		/// the contents of this method with the code editor.
    		/// </summary>
    		private void InitializeComponent()
    		{
    			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
    			this.txtBoxSpeechRecognized = new System.Windows.Forms.TextBox();
    			this.label2 = new System.Windows.Forms.Label();
    			this.textBoxRecognizerState = new System.Windows.Forms.TextBox();
    			this.label1 = new System.Windows.Forms.Label();
    			this.labelRegonizerLangue = new System.Windows.Forms.Label();
    			this.checkBoxActivateSpeechRecogninzer = new System.Windows.Forms.CheckBox();
    			this.SuspendLayout();
    			// 
    			// txtBoxSpeechRecognized
    			// 
    			this.txtBoxSpeechRecognized.AccessibleDescription = null;
    			this.txtBoxSpeechRecognized.AccessibleName = null;
    			resources.ApplyResources(this.txtBoxSpeechRecognized, "txtBoxSpeechRecognized");
    			this.txtBoxSpeechRecognized.BackgroundImage = null;
    			this.txtBoxSpeechRecognized.Font = null;
    			this.txtBoxSpeechRecognized.Name = "txtBoxSpeechRecognized";
    			// 
    			// label2
    			// 
    			this.label2.AccessibleDescription = null;
    			this.label2.AccessibleName = null;
    			resources.ApplyResources(this.label2, "label2");
    			this.label2.Font = null;
    			this.label2.Name = "label2";
    			// 
    			// textBoxRecognizerState
    			// 
    			this.textBoxRecognizerState.AccessibleDescription = null;
    			this.textBoxRecognizerState.AccessibleName = null;
    			resources.ApplyResources(this.textBoxRecognizerState, "textBoxRecognizerState");
    			this.textBoxRecognizerState.BackgroundImage = null;
    			this.textBoxRecognizerState.Font = null;
    			this.textBoxRecognizerState.Name = "textBoxRecognizerState";
    			// 
    			// label1
    			// 
    			this.label1.AccessibleDescription = null;
    			this.label1.AccessibleName = null;
    			resources.ApplyResources(this.label1, "label1");
    			this.label1.Font = null;
    			this.label1.Name = "label1";
    			// 
    			// labelRegonizerLangue
    			// 
    			this.labelRegonizerLangue.AccessibleDescription = null;
    			this.labelRegonizerLangue.AccessibleName = null;
    			resources.ApplyResources(this.labelRegonizerLangue, "labelRegonizerLangue");
    			this.labelRegonizerLangue.Name = "labelRegonizerLangue";
    			// 
    			// checkBoxActivateSpeechRecogninzer
    			// 
    			this.checkBoxActivateSpeechRecogninzer.AccessibleDescription = null;
    			this.checkBoxActivateSpeechRecogninzer.AccessibleName = null;
    			resources.ApplyResources(this.checkBoxActivateSpeechRecogninzer, "checkBoxActivateSpeechRecogninzer");
    			this.checkBoxActivateSpeechRecogninzer.BackgroundImage = null;
    			this.checkBoxActivateSpeechRecogninzer.Font = null;
    			this.checkBoxActivateSpeechRecogninzer.Name = "checkBoxActivateSpeechRecogninzer";
    			this.checkBoxActivateSpeechRecogninzer.UseVisualStyleBackColor = true;
    			this.checkBoxActivateSpeechRecogninzer.CheckedChanged += new System.EventHandler(this.checkBoxActivateSpeechRecogninzer_CheckedChanged);
    			// 
    			// Form1
    			// 
    			this.AccessibleDescription = null;
    			this.AccessibleName = null;
    			resources.ApplyResources(this, "$this");
    			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    			this.BackgroundImage = null;
    			this.Controls.Add(this.checkBoxActivateSpeechRecogninzer);
    			this.Controls.Add(this.labelRegonizerLangue);
    			this.Controls.Add(this.label1);
    			this.Controls.Add(this.textBoxRecognizerState);
    			this.Controls.Add(this.txtBoxSpeechRecognized);
    			this.Controls.Add(this.label2);
    			this.Font = null;
    			this.Icon = null;
    			this.Name = "Form1";
    			this.ResumeLayout(false);
    			this.PerformLayout();
    
    		}
    
    		#endregion
    
    		private System.Windows.Forms.TextBox txtBoxSpeechRecognized;
    		private System.Windows.Forms.Label label2;
    		private System.Windows.Forms.TextBox textBoxRecognizerState;
    		private System.Windows.Forms.Label label1;
    		private System.Windows.Forms.Label labelRegonizerLangue;
    		private System.Windows.Forms.CheckBox checkBoxActivateSpeechRecogninzer;
    	}
    }
    

    Form1.resx :

    <?xml version="1.0" encoding="utf-8"?>
    <root>
      <!-- 
        Microsoft ResX Schema 
        
        Version 2.0
        
        The primary goals of this format is to allow a simple XML format 
        that is mostly human readable. The generation and parsing of the 
        various data types are done through the TypeConverter classes 
        associated with the data types.
        
        Example:
        
        ... ado.net/XML headers & schema ...
        <resheader name="resmimetype">text/microsoft-resx</resheader>
        <resheader name="version">2.0</resheader>
        <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
        <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
        <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
        <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
        <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
            <value>[base64 mime encoded serialized .NET Framework object]</value>
        </data>
        <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
            <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
            <comment>This is a comment</comment>
        </data>
                    
        There are any number of "resheader" rows that contain simple 
        name/value pairs.
        
        Each data row contains a name, and value. The row also contains a 
        type or mimetype. Type corresponds to a .NET class that support 
        text/value conversion through the TypeConverter architecture. 
        Classes that don't support this are serialized and stored with the 
        mimetype set.
        
        The mimetype is used for serialized objects, and tells the 
        ResXResourceReader how to depersist the object. This is currently not 
        extensible. For a given mimetype the value must be set accordingly:
        
        Note - application/x-microsoft.net.object.binary.base64 is the format 
        that the ResXResourceWriter will generate, however the reader can 
        read any of the formats listed below.
        
        mimetype: application/x-microsoft.net.object.binary.base64
        value   : The object must be serialized with 
                : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
                : and then encoded with base64 encoding.
        
        mimetype: application/x-microsoft.net.object.soap.base64
        value   : The object must be serialized with 
                : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
                : and then encoded with base64 encoding.
    
        mimetype: application/x-microsoft.net.object.bytearray.base64
        value   : The object must be serialized into a byte array 
                : using a System.ComponentModel.TypeConverter
                : and then encoded with base64 encoding.
        -->
      <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
        <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
        <xsd:element name="root" msdata:IsDataSet="true">
          <xsd:complexType>
            <xsd:choice maxOccurs="unbounded">
              <xsd:element name="metadata">
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element name="value" type="xsd:string" minOccurs="0" />
                  </xsd:sequence>
                  <xsd:attribute name="name" use="required" type="xsd:string" />
                  <xsd:attribute name="type" type="xsd:string" />
                  <xsd:attribute name="mimetype" type="xsd:string" />
                  <xsd:attribute ref="xml:space" />
                </xsd:complexType>
              </xsd:element>
              <xsd:element name="assembly">
                <xsd:complexType>
                  <xsd:attribute name="alias" type="xsd:string" />
                  <xsd:attribute name="name" type="xsd:string" />
                </xsd:complexType>
              </xsd:element>
              <xsd:element name="data">
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                    <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
                  </xsd:sequence>
                  <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
                  <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
                  <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
                  <xsd:attribute ref="xml:space" />
                </xsd:complexType>
              </xsd:element>
              <xsd:element name="resheader">
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                  </xsd:sequence>
                  <xsd:attribute name="name" type="xsd:string" use="required" />
                </xsd:complexType>
              </xsd:element>
            </xsd:choice>
          </xsd:complexType>
        </xsd:element>
      </xsd:schema>
      <resheader name="resmimetype">
        <value>text/microsoft-resx</value>
      </resheader>
      <resheader name="version">
        <value>2.0</value>
      </resheader>
      <resheader name="reader">
        <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
      </resheader>
      <resheader name="writer">
        <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
      </resheader>
      <assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <data name="checkBoxActivateSpeechRecogninzer.AutoSize" type="System.Boolean, mscorlib">
        <value>True</value>
      </data>
      <data name="&gt;&gt;label2.Name" xml:space="preserve">
        <value>label2</value>
      </data>
      <data name="&gt;&gt;$this.Name" xml:space="preserve">
        <value>Form1</value>
      </data>
      <data name="&gt;&gt;labelRegonizerLangue.Name" xml:space="preserve">
        <value>labelRegonizerLangue</value>
      </data>
      <data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
        <value>2</value>
      </data>
      <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <data name="labelRegonizerLangue.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
        <value>NoControl</value>
      </data>
      <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <data name="label1.Size" type="System.Drawing.Size, System.Drawing">
        <value>93, 13</value>
      </data>
      <data name="label2.Text" xml:space="preserve">
        <value>Text recognized :</value>
      </data>
      <data name="label2.TabIndex" type="System.Int32, mscorlib">
        <value>3</value>
      </data>
      <data name="label2.AutoSize" type="System.Boolean, mscorlib">
        <value>True</value>
      </data>
      <data name="txtBoxSpeechRecognized.Location" type="System.Drawing.Point, System.Drawing">
        <value>133, 253</value>
      </data>
      <data name="label1.Text" xml:space="preserve">
        <value>Recognizer state :</value>
      </data>
      <data name="&gt;&gt;textBoxRecognizerState.Name" xml:space="preserve">
        <value>textBoxRecognizerState</value>
      </data>
      <data name="label1.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
        <value>NoControl</value>
      </data>
      <data name="checkBoxActivateSpeechRecogninzer.Text" xml:space="preserve">
        <value>Active speech recognizer</value>
      </data>
      <data name="$this.Text" xml:space="preserve">
        <value>English window</value>
      </data>
      <data name="&gt;&gt;textBoxRecognizerState.Type" xml:space="preserve">
        <value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
      </data>
      <data name="label2.Location" type="System.Drawing.Point, System.Drawing">
        <value>148, 222</value>
      </data>
      <data name="&gt;&gt;txtBoxSpeechRecognized.ZOrder" xml:space="preserve">
        <value>4</value>
      </data>
      <data name="&gt;&gt;textBoxRecognizerState.ZOrder" xml:space="preserve">
        <value>3</value>
      </data>
      <data name="&gt;&gt;label2.Type" xml:space="preserve">
        <value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
      </data>
      <data name="&gt;&gt;checkBoxActivateSpeechRecogninzer.Type" xml:space="preserve">
        <value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
      </data>
      <data name="&gt;&gt;checkBoxActivateSpeechRecogninzer.ZOrder" xml:space="preserve">
        <value>0</value>
      </data>
      <data name="checkBoxActivateSpeechRecogninzer.TabIndex" type="System.Int32, mscorlib">
        <value>11</value>
      </data>
      <data name="&gt;&gt;txtBoxSpeechRecognized.Parent" xml:space="preserve">
        <value>$this</value>
      </data>
      <data name="&gt;&gt;$this.Type" xml:space="preserve">
        <value>System.Windows.Forms.Form, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
      </data>
      <data name="&gt;&gt;label1.Type" xml:space="preserve">
        <value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
      </data>
      <data name="&gt;&gt;labelRegonizerLangue.Parent" xml:space="preserve">
        <value>$this</value>
      </data>
      <data name="&gt;&gt;labelRegonizerLangue.Type" xml:space="preserve">
        <value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
      </data>
      <data name="textBoxRecognizerState.TabIndex" type="System.Int32, mscorlib">
        <value>7</value>
      </data>
      <data name="textBoxRecognizerState.Location" type="System.Drawing.Point, System.Drawing">
        <value>224, 155</value>
      </data>
      <data name="label1.TabIndex" type="System.Int32, mscorlib">
        <value>8</value>
      </data>
      <data name="labelRegonizerLangue.AutoSize" type="System.Boolean, mscorlib">
        <value>True</value>
      </data>
      <data name="labelRegonizerLangue.TabIndex" type="System.Int32, mscorlib">
        <value>10</value>
      </data>
      <data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
        <value>440, 320</value>
      </data>
      <data name="txtBoxSpeechRecognized.Size" type="System.Drawing.Size, System.Drawing">
        <value>120, 20</value>
      </data>
      <data name="checkBoxActivateSpeechRecogninzer.Size" type="System.Drawing.Size, System.Drawing">
        <value>146, 17</value>
      </data>
      <data name="&gt;&gt;label1.Parent" xml:space="preserve">
        <value>$this</value>
      </data>
      <data name="label1.Location" type="System.Drawing.Point, System.Drawing">
        <value>270, 128</value>
      </data>
      <data name="labelRegonizerLangue.Location" type="System.Drawing.Point, System.Drawing">
        <value>109, 42</value>
      </data>
      <data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
        <value>6, 13</value>
      </data>
      <data name="&gt;&gt;checkBoxActivateSpeechRecogninzer.Name" xml:space="preserve">
        <value>checkBoxActivateSpeechRecogninzer</value>
      </data>
      <data name="&gt;&gt;label1.Name" xml:space="preserve">
        <value>label1</value>
      </data>
      <data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
        <value>5</value>
      </data>
      <data name="labelRegonizerLangue.Size" type="System.Drawing.Size, System.Drawing">
        <value>176, 20</value>
      </data>
      <data name="&gt;&gt;txtBoxSpeechRecognized.Type" xml:space="preserve">
        <value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
      </data>
      <data name="label1.AutoSize" type="System.Boolean, mscorlib">
        <value>True</value>
      </data>
      <data name="labelRegonizerLangue.Font" type="System.Drawing.Font, System.Drawing">
        <value>Microsoft Sans Serif, 12.25pt</value>
      </data>
      <data name="textBoxRecognizerState.Size" type="System.Drawing.Size, System.Drawing">
        <value>176, 20</value>
      </data>
      <data name="&gt;&gt;txtBoxSpeechRecognized.Name" xml:space="preserve">
        <value>txtBoxSpeechRecognized</value>
      </data>
      <data name="checkBoxActivateSpeechRecogninzer.Location" type="System.Drawing.Point, System.Drawing">
        <value>25, 137</value>
      </data>
      <data name="txtBoxSpeechRecognized.TabIndex" type="System.Int32, mscorlib">
        <value>6</value>
      </data>
      <data name="labelRegonizerLangue.Text" xml:space="preserve">
        <value>Recognizer language :</value>
      </data>
      <data name="&gt;&gt;label2.Parent" xml:space="preserve">
        <value>$this</value>
      </data>
      <data name="&gt;&gt;checkBoxActivateSpeechRecogninzer.Parent" xml:space="preserve">
        <value>$this</value>
      </data>
      <data name="&gt;&gt;labelRegonizerLangue.ZOrder" xml:space="preserve">
        <value>1</value>
      </data>
      <data name="label2.Size" type="System.Drawing.Size, System.Drawing">
        <value>89, 13</value>
      </data>
      <data name="&gt;&gt;textBoxRecognizerState.Parent" xml:space="preserve">
        <value>$this</value>
      </data>
      <metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <value>True</value>
      </metadata>
      <metadata name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <value>French (Canada)</value>
      </metadata>
    </root>

    Form1.fr-ca.resx :

    <?xml version="1.0" encoding="utf-8"?>
    <root>
      <!-- 
        Microsoft ResX Schema 
        
        Version 2.0
        
        The primary goals of this format is to allow a simple XML format 
        that is mostly human readable. The generation and parsing of the 
        various data types are done through the TypeConverter classes 
        associated with the data types.
        
        Example:
        
        ... ado.net/XML headers & schema ...
        <resheader name="resmimetype">text/microsoft-resx</resheader>
        <resheader name="version">2.0</resheader>
        <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
        <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
        <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
        <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
        <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
            <value>[base64 mime encoded serialized .NET Framework object]</value>
        </data>
        <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
            <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
            <comment>This is a comment</comment>
        </data>
                    
        There are any number of "resheader" rows that contain simple 
        name/value pairs.
        
        Each data row contains a name, and value. The row also contains a 
        type or mimetype. Type corresponds to a .NET class that support 
        text/value conversion through the TypeConverter architecture. 
        Classes that don't support this are serialized and stored with the 
        mimetype set.
        
        The mimetype is used for serialized objects, and tells the 
        ResXResourceReader how to depersist the object. This is currently not 
        extensible. For a given mimetype the value must be set accordingly:
        
        Note - application/x-microsoft.net.object.binary.base64 is the format 
        that the ResXResourceWriter will generate, however the reader can 
        read any of the formats listed below.
        
        mimetype: application/x-microsoft.net.object.binary.base64
        value   : The object must be serialized with 
                : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
                : and then encoded with base64 encoding.
        
        mimetype: application/x-microsoft.net.object.soap.base64
        value   : The object must be serialized with 
                : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
                : and then encoded with base64 encoding.
    
        mimetype: application/x-microsoft.net.object.bytearray.base64
        value   : The object must be serialized into a byte array 
                : using a System.ComponentModel.TypeConverter
                : and then encoded with base64 encoding.
        -->
      <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
        <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
        <xsd:element name="root" msdata:IsDataSet="true">
          <xsd:complexType>
            <xsd:choice maxOccurs="unbounded">
              <xsd:element name="metadata">
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element name="value" type="xsd:string" minOccurs="0" />
                  </xsd:sequence>
                  <xsd:attribute name="name" use="required" type="xsd:string" />
                  <xsd:attribute name="type" type="xsd:string" />
                  <xsd:attribute name="mimetype" type="xsd:string" />
                  <xsd:attribute ref="xml:space" />
                </xsd:complexType>
              </xsd:element>
              <xsd:element name="assembly">
                <xsd:complexType>
                  <xsd:attribute name="alias" type="xsd:string" />
                  <xsd:attribute name="name" type="xsd:string" />
                </xsd:complexType>
              </xsd:element>
              <xsd:element name="data">
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                    <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
                  </xsd:sequence>
                  <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
                  <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
                  <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
                  <xsd:attribute ref="xml:space" />
                </xsd:complexType>
              </xsd:element>
              <xsd:element name="resheader">
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                  </xsd:sequence>
                  <xsd:attribute name="name" type="xsd:string" use="required" />
                </xsd:complexType>
              </xsd:element>
            </xsd:choice>
          </xsd:complexType>
        </xsd:element>
      </xsd:schema>
      <resheader name="resmimetype">
        <value>text/microsoft-resx</value>
      </resheader>
      <resheader name="version">
        <value>2.0</value>
      </resheader>
      <resheader name="reader">
        <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
      </resheader>
      <resheader name="writer">
        <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
      </resheader>
      <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <data name="label2.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
        <value>NoControl</value>
      </data>
      <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <data name="label2.Location" type="System.Drawing.Point, System.Drawing">
        <value>169, 222</value>
      </data>
      <data name="label2.Size" type="System.Drawing.Size, System.Drawing">
        <value>82, 13</value>
      </data>
      <data name="label2.Text" xml:space="preserve">
        <value>Texte reconnu :</value>
      </data>
      <data name="label1.Location" type="System.Drawing.Point, System.Drawing">
        <value>243, 125</value>
      </data>
      <data name="label1.Size" type="System.Drawing.Size, System.Drawing">
        <value>136, 13</value>
      </data>
      <data name="label1.Text" xml:space="preserve">
        <value>Etat de la reconnaissance :</value>
      </data>
      <data name="labelRegonizerLangue.Size" type="System.Drawing.Size, System.Drawing">
        <value>208, 20</value>
      </data>
      <data name="labelRegonizerLangue.Text" xml:space="preserve">
        <value>Language de l'application :</value>
      </data>
      <data name="checkBoxActivateSpeechRecogninzer.Size" type="System.Drawing.Size, System.Drawing">
        <value>183, 17</value>
      </data>
      <data name="checkBoxActivateSpeechRecogninzer.Text" xml:space="preserve">
        <value>Activer la reconnaissance vocale</value>
      </data>
      <data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
        <value>435, 332</value>
      </data>
      <data name="$this.Text" xml:space="preserve">
        <value>Canadian window</value>
      </data>
    </root>


    Cordialement,

    Pierre



    jeudi 30 mai 2013 14:30
  • Bonjour Aurel,

    Je veux juste savoir pourquoi lorsque mon application est en fr-CA, je ne peux pas utiliser la reconnaissance vocale, même française ?

    Cordialement,

    Pierre

    vendredi 31 mai 2013 15:25
  • Finalement, j'ai trouvé la solution. Lorsque votre application est dans une variante de langue (français-canadien par exemple), et que votre moteur de reconnaissance vocale est dans une langue générale (Français-français), lors du chargement de votre grammaire, une exception sera généré.

    Pour pallier à cette exception, l'objet grammarBuilder que vous avez utilisé détient une culture, qu'il faut obligatoirement affecter à celle du moteur de reconnaissance vocale. Car par défaut, il prend la culture de l'application. De cette manière, l'exception n'est plus généré. Il faut procéder comme ceci : 

    Choices choices = new Choices();
    choices.Add(new string[] {"a", "b"});
    
    GrammarBuilder grammarBuilder = new GrammarBuilder();
    CultureInfo culture = new CultureInfo("fr-FR");
    grammarBuilder.Culture = culture;
    grammarBuilder.Append(choices);
    
    Grammar grammar = new Grammar(grammarBuilder);
    _speechRecognizerEngine.LoadGrammar(grammar);




    • Marqué comme réponse Aurel Bera lundi 3 juin 2013 06:59
    • Modifié Pierre-msdn lundi 3 juin 2013 17:06 Complément d'information
    vendredi 31 mai 2013 18:20
  • Bonjour  Pierre-msdn

    On a marqué votre réponse, mais pouvez-vous partager avec nous la solution,  afin que d'autres personnes avec le même problème puissent profiter de cette solution?

    Merci

    Cordialement,


    Aurel BERA, Microsoft
    Microsoft propose ce service gratuitement, dans le but d'aider les utilisateurs et d'élargir les connaissances générales liées aux produits et technologies Microsoft. Ce contenu est fourni "tel quel" et il n'implique aucune responsabilité de la part de Microsoft.

    lundi 3 juin 2013 07:01