NSSpeechRecognizer: sending text message

Discussion in 'Mac Programming' started by moonman239, Apr 29, 2016.

  1. moonman239 macrumors 68000

    Mar 27, 2009
    I'm creating a program that uses NSSpeechRecognizer, and what I'd like to do is have the program respond to commands like "Tell Darian I love her". The only way I can think of is populate the commands array with every word in the English language.
  2. 0d085d macrumors regular

    Apr 23, 2015
    I don't think NSSpeechRecognizer is the appropriate class for this. It recognises predefined words and phrases, whereas you don't know what you're going to get. What you're looking for is speech to text, ie. dictation.

    After a quick hunt around, this is the only suitable looking SDK I can find for recognising speech. You'd have to handle recording the speech and sending it through the API yourself. You'll then get back plain text which you can interpret in whatever way you like. There may be better libraries - I haven't looked too hard.

    Or, yes, I suppose you could configure NSSpeechRecognizer to recognise every English word and then add recognised words to a list on every call of didRecognizeCommand. It might be worth a try, but it wouldn't surprise me if it didn't work too well as you wouldn't be using it as designed. It might miss words immediately following a recognised word, or maybe it'll spend so long searching the enormous dictionary that it'll be impractically slow.

Share This Page