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 TextToSpeechPrivate::ProcessSpeech() { QByteArray ba; qmLock.lock(); ba = qlMessages.takeFirst(); qmLock.unlock(); NewSpeechChannel(NULL, &scChannel); SetSpeechInfo(scChannel, soVolume, &fVolume); SetSpeechInfo(scChannel, soRefCon, this); SetSpeechInfo(scChannel, soSpeechDoneCallBack, reinterpret_cast<void *>(speech_done_cb)); SpeakText(scChannel, ba.constData(), ba.size()); }
void Speak(const void *text, long size) { SpeechChannel chan; NewSpeechChannel (NULL, &chan); SetSpeechInfo(chan, soSpeechDoneCallBack, (void*)&SpeakingDone); SpeakText (chan, text, size); }
int prInitSpeech(struct VMGlobals *g, int numArgsPushed){ OSErr theErr = noErr; //PyrSlot *a = g->sp-1; PyrSlot *b = g->sp; int chan; slotIntVal(b, &chan); if (chan < 0 || chan >= kMaxSpeechChannels) return errIndexOutOfRange; for (int i=0; i<chan; ++i) { if(fCurSpeechChannel[i]) DisposeSpeechChannel(fCurSpeechChannel[i]); NewSpeechChannel( NULL, fCurSpeechChannel+i ); theErr = SetSpeechInfo (fCurSpeechChannel[i], soSpeechDoneCallBack, (const void*)OurSpeechDoneCallBackProc); theErr = SetSpeechInfo (fCurSpeechChannel[i], soWordCallBack, (const void*)OurWordCallBackProc); theErr = SetSpeechInfo (fCurSpeechChannel[i], soRefCon, (void*) i); } return errNone; }
void ofxSpeechSynthesizer::setCharacterByCharacter(bool enable) { OSErr errorStatus; OSType theMode; if(enable) theMode = modeLiteral; else theMode = modeNormal; errorStatus = SetSpeechInfo(speechChannel, soCharacterMode, &theMode); }
/* * Allocate speech channel and setup callbacks */ static SpeechChannel createNewSpeechChannel(VoiceSpec *voiceSpec) { SpeechChannel channel = NULL; OSErr theErr = noErr; theErr = NewSpeechChannel(voiceSpec, &channel); if (theErr != noErr) { errorMsg("NewSpeechChannel failed", theErr); } else { theErr = SetSpeechInfo(channel, soErrorCallBack, OurErrorCallBackProc); if (theErr != noErr) { errorMsg("SetSpeechInfo(soErrorCallBack) failed", theErr); } theErr = SetSpeechInfo(channel, soSpeechDoneCallBack, OurSpeechDoneCallBackProc); if (theErr != noErr) { errorMsg("SetSpeechInfo(soSpeechDoneCallBack) failed", theErr); } } return channel; }
// ---------------------------------------------------------- bool ofxAudioUnitSpeechSynth::setVoice(int voiceIndex) // ---------------------------------------------------------- { VoiceSpec vSpec; OSErr err; err = GetIndVoice(voiceIndex, &vSpec); if(!err) { StopSpeech(_channel); err = SetSpeechInfo(_channel, soCurrentVoice, &vSpec); } return (err == 0); }
int prSetSpeechVolume(struct VMGlobals *g, int numArgsPushed) { OSErr theErr = noErr; //PyrSlot *a = g->sp-2; PyrSlot *b = g->sp-1; PyrSlot *c = g->sp; double val; int chan; slotIntVal(b, &chan); slotDoubleVal(c, &val); Fixed newVal = (Fixed)(val * 65536.0); // if(!fCurSpeechChannel) theErr = NewSpeechChannel( NULL, &fCurSpeechChannel ); theErr = SetSpeechInfo (fCurSpeechChannel[chan], soVolume, &newVal); return errNone; }
int prSetSpeechVoice(struct VMGlobals *g, int numArgsPushed){ OSErr theErr = noErr; //PyrSlot *a = g->sp-2; PyrSlot *b = g->sp-1; PyrSlot *c = g->sp; int val; int chan; VoiceSpec theVoiceSpec; slotIntVal(b, &chan); slotIntVal(c, &val); theErr = GetIndVoice (val, &theVoiceSpec); if (SetSpeechInfo (fCurSpeechChannel[chan], soCurrentVoice, &theVoiceSpec) == incompatibleVoice) return (!errNone); return errNone; }