int main(int argc, char **argv) { OSErr rc; SpeechChannel channel; VoiceSpec vs; int voice; char *text = "What do you want to say?"; if (!argv[1]) { voice = 1; } else { voice = atoi(argv[1]); } if (argc == 3) { text = argv[2]; } // GetIndVoice gets the voice define by the (positive) index rc = GetIndVoice(voice, // SInt16 index, &vs); // VoiceSpec *voice // NewSpeechChannel basically makes the voice usable rc = NewSpeechChannel(&vs, // VoiceSpec *voice, &channel); // Can be NULL CFStringRef string = CFStringCreateWithCString(NULL, text, kCFStringEncodingUTF8); rc = SpeakCFString(channel, string, NULL); if (rc) { fprintf(stderr, "unable to speak!\n"); exit(1); } while (SpeechBusy()) sleep(1); exit(0); }
// ---------------------------------------------------------- void ofxAudioUnitSpeechSynth::say(const std::string &phrase) // ---------------------------------------------------------- { CFStringRef string = CFStringCreateWithCString(kCFAllocatorDefault, phrase.c_str(), kCFStringEncodingUTF8); SpeakCFString(_channel, string, NULL); CFRelease(string); }
void say(const char* words) { while (SpeechBusy()) { QGC::SLEEP::msleep(100); } NewSpeechChannel(NULL, &sc); SetSpeechInfo(sc, soVolume, &volume); SetSpeechInfo(sc, soSpeechDoneCallBack, reinterpret_cast<void *>(speechDone)); CFStringRef cfstr = CFStringCreateWithCString(NULL, words, kCFStringEncodingUTF8); SpeakCFString(sc, cfstr, NULL); }
void PrepareSpeechAU(MyAUGraphPlayer *player) { SpeechChannel chan; UInt32 propsize = sizeof(SpeechChannel); CheckError(AudioUnitGetProperty(player->speechAU, kAudioUnitProperty_SpeechChannel, kAudioUnitScope_Global, 0, &chan, &propsize), "AudioUnitGetProperty[kAudioUnitProperty_SpeechChannel] failed"); SpeakCFString(chan, CFSTR("hello world"), NULL); }
void QtSpeech::tell(QString text, QObject* obj, const char* slot) const { d->onFinishObj = obj; d->onFinishSlot = slot; if (obj && slot) { connect(const_cast<QtSpeech*>(this), SIGNAL(finished()), obj, slot); } CFStringRef cf_text = CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>( text.unicode()), text.length()); OSErr ok = SpeakCFString(d->channel, cf_text, NULL); CFRelease(cf_text); if (ok != noErr) { throw LogicError(Where + "SpeakCFString()"); } }