LoginSignup
3
3

More than 5 years have passed since last update.

Voice Control Using Win10-MS Speech Platform-RaspberryPi in Hackster.io

Voice Control Using Win10-MS Speech Platform-RaspberryPi - Hackster.io

音声認識の API Windows.Media.SpeechRecognition を使って、LED を点灯したり、部屋の明かりをつけたりするサンプルです。音声認識自体は、Windows 10 に含まれているので通常の PC でも動作します。

あらかじめ、認識する単語を grammar.xml な形で用意しておいて、音声認識をさせる方式ですね。日本語が通るのかはわからないのですが、英語の例があります。

naadydev/Voice-Control-IOT-RaspberryPi-Win10-MS-Speech-Platform: Simple Example for Control Anything Using Voice Control ( WIn10 IOT - MS Speech Platform - RaspberryPi )

// Initialize Speech Recognizer and start async recognition
private async void initializeSpeechRecognizer()
{
    // Initialize recognizer
    recognizer = new SpeechRecognizer();

    #region Create Events
    // Set event handlers
    recognizer.StateChanged += RecognizerStateChanged;
    recognizer.ContinuousRecognitionSession.ResultGenerated += RecognizerResultGenerated;
    #endregion

    #region Load Grammer

    // Load Grammer file constraint
    string fileName = String.Format(SRGS_FILE);
    StorageFile grammarContentFile = await Package.Current.InstalledLocation.GetFileAsync(fileName);

    SpeechRecognitionGrammarFileConstraint grammarConstraint = new SpeechRecognitionGrammarFileConstraint(grammarContentFile);

    // Add to grammer constraint
    recognizer.Constraints.Add(grammarConstraint);
    #endregion

    #region Compile grammer
    SpeechRecognitionCompilationResult compilationResult = await recognizer.CompileConstraintsAsync();
    Debug.WriteLine("Status: " + compilationResult.Status.ToString());

    // If successful, display the recognition result.
    if (compilationResult.Status == SpeechRecognitionResultStatus.Success)
    {
        Debug.WriteLine("Result: " + compilationResult.ToString());

        await recognizer.ContinuousRecognitionSession.StartAsync();
    }
    else
    {
        Debug.WriteLine("Status: " + compilationResult.Status);
    }
    #endregion
}

これも PC にマイクをつけて常時起動しておけば済むはなしですが、Raspberry Pi で Windows IoT Core を使うことで電力量を減らすことができます。

サンプルに GPIO へ ON/OFF を流すほかにも、WiFi で飛ばしたり、Bluetooth を使ったり、赤外線を使ったりすることができるでしょう。

3
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3