Giter VIP home page Giter VIP logo

csharp_speechrecognition's Introduction

C# Speech Recognition

Meta

This program is written by Gary Wee.

Date: 2022 Jul 26

Description

This program uses System.Speech Nuget package for speech recognition and speech synthesis, it is based on .NET 6.
For older .NET version, you have to select the System.Speech reference in "Add Reference >> Aseemblies".

Remark: System.Speech is different from Microsoft.Speech.

Basic Codes

  1. Set Speech Synthesizer (Text-to-Speech)
    You can ask the computer to speak a string using the voice installed in your computer.
    How to get installed voice >> Microsoft Docs
SpeechSynthesizer speaker = new SpeechSynthesizer();
speaker.SelectVoice("Microsoft Zira Desktop"); //David, Zira, Hanhan, Huihui
speaker.SpeakAsync("hello gary, how are you doing?");
  1. Set Speech Recognition Engine (Speech-to-Text)
    You can add some words into Choices, and append all the Choices into GrammarBuilder, then convert it into Grammar.
    The SpeechRecognitionEngine can load the grammar you created using LoadGrammar().
    Remember to plug in your microphone so that SetInputToDefaultAudioDevice() can search the input device.
    Remark: SpeechRecognitionEngine is different from SpeechRecognizer.
SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();
Choices choice_01 = new Choices(new string[] { "謝謝", "哈咯", "現在幾點", "我是克禮", "我好累", "看影片", "谷歌搜尋", "今晚我想來點", "再見" });
Choices choice_02 = new Choices(new string[] { "Thanks", "Hello", "What time is it", "I am Gary", "I am tired", "Watch YouTube", "Google Search", "Tonight I would like to have", "Bye" });
GrammarBuilder grammar_builder = new GrammarBuilder();
grammar_builder.Append(choice_01);
grammar_builder.Append(choice_02);
grammar_builder.Culture = recognizer.RecognizerInfo.Culture;
Grammar grammar = new Grammar(grammar_builder);
recognizer.LoadGrammar(grammar);
recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
recognizer.SetInputToDefaultAudioDevice();
recognizer.RecognizeAsync(RecognizeMode.Multiple);

csharp_speechrecognition's People

Contributors

weegary avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.