Mac OS X speech to text API. Howto?

前端 未结 4 996
时光取名叫无心
时光取名叫无心 2020-12-14 05:20

I have a program that receives an audio (mono) stream of bits from TCP/IP. I am wondering whether the speech (speech-recognition) API in Mac OS X would be able to do a speec

4条回答
  •  清歌不尽
    2020-12-14 05:31

    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!"];
    

提交回复
热议问题