Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open Microsoft.Speech.Synthesis
- open Microsoft.Speech.Recognition
- [<EntryPoint>]
- let main argv =
- let synth = new SpeechSynthesizer()
- let polishVoiceName =
- synth.GetInstalledVoices()
- |> Seq.find (fun v -> v.VoiceInfo.Culture.TwoLetterISOLanguageName = "pl")
- |> (fun v -> v.VoiceInfo.Name)
- synth.SelectVoice polishVoiceName
- synth.SetOutputToDefaultAudioDevice()
- synth.Speak("cześć")
- let polishRecognizer =
- SpeechRecognitionEngine.InstalledRecognizers()
- |> Seq.find (fun r -> r.Culture.TwoLetterISOLanguageName = "pl")
- let recog = new SpeechRecognitionEngine(polishRecognizer)
- let grammarBuilder = new GrammarBuilder("cześć")
- let grammar = new Grammar(grammarBuilder)
- recog.LoadGrammar(grammar)
- recog.SpeechRecognized.Add (fun e ->
- printfn "You responded!"
- printfn "%A" e.Result.Text
- )
- recog.SetInputToDefaultAudioDevice()
- recog.Recognize() |> ignore
- System.Console.ReadKey() |> ignore
- 0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement