Mac OS X speech to text API. Howto?

我怕爱的太早我们不能终老 提交于 2019-11-28 19:47:53

There's a number of examples that get copied under /Developer/Examples/Speech/Recognition when you install XCode.

Cocoa class for speech recognition is NSSpeechRecognizer. I've not used it but as far as I know speech recognition requires you to build a grammar to help the engine choose from a number of choices rather then allowing you to pass free-form input. This is all explained in the examples referred above.

Latrokles

This comes a bit late perhaps, but I'll chime in anyway.

The speech recognition facilities in OS X (on both the Carbon and Cocoa side of things) are for speech command recognition, which means that they will recognize words (or phrases, commands) that have been loaded into the speech system language model. I've done some stuff with small dictionaries and it works pretty well, but if you want to recognize arbitrary speech things may turn hairier.

Something else to keep in mind is that the functionality that the speech APIs in OS X provide is not one to one. The Carbon stuff provides functionality that has not made it to NSSpeechRecognizer (the docs make some mention of this).

I don't know about Cocoa, but the Carbon Speech Recognition Manager does allow you to specify inputs other than a microphone so a sound stream would work just fine.

Here's a good O'Reilly article to get you started.

You can use either ApplicationServices's SpeechSynthesis (10.0+)

CFStringRef cfstr = CFStringCreateWithCString(NULL,"Hello World!", kCFStringEncodingMacRoman);
Str255 pstr;    
CFStringGetPascalString(cfstr, pstr, 255, kCFStringEncodingMacRoman);   
SpeakString(pstr);

or AppKit's NSSpeechSynthesizer (10.3+)

NSSpeechSynthesizer *synth = [[NSSpeechSynthesizer alloc] initWithVoice:@"com.apple.speech.synthesis.voice.Alex"];
[synth startSpeakingString:@"Hello world!"];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!