void initSpeechPrimitives () { int base, index; base = nextPrimitiveIndex(); index = 0; s_speechwordAction = getsym("doWordAction"); s_speechdoneAction = getsym("doSpeechDoneAction"); s_speech = getsym("Speech"); definePrimitive(base, index++, "_SpeakText", prSpeakText, 3, 0); definePrimitive(base, index++, "_InitSpeech", prInitSpeech, 2, 0); definePrimitive(base, index++, "_SetSpeechRate", prSetSpeechRate, 3, 0); definePrimitive(base, index++, "_SetSpeechPitch", prSetSpeechPitch, 3, 0); definePrimitive(base, index++, "_SetSpeechPitchMod", prSetSpeechPitchMod, 3, 0); definePrimitive(base, index++, "_SetSpeechVoice", prSetSpeechVoice, 3, 0); definePrimitive(base, index++, "_SetSpeechVolume", prSetSpeechVolume, 3, 0); definePrimitive(base, index++, "_SetSpeechPause", prSetSpeechPause, 3, 0); //0 pause, 1 continue definePrimitive(base, index++, "_SetSpeechStopAt", prSetSpeechStop, 3, 0); //0 kImmediate, 1 kEndOfWord, 2 kEndOfSentence definePrimitive(base, index++, "_SpeechVoiceIsSpeaking", prSpeechVoiceIsSpeaking, 2, 0); for(int i=0; i<kMaxSpeechChannels; ++i){ speechStrings[i] = NULL; if(fCurSpeechChannel[i]) DisposeSpeechChannel(fCurSpeechChannel[i]); fCurSpeechChannel[i] = NULL; } }
int SayTextInit(void) { OSErr err; long response; long mask; VoiceSpec defaultVoiceSpec; VoiceDescription voiceDesc; err = Gestalt(gestaltSpeechAttr, &response); if (err != noErr) { fprintf(stderr,"can't init Mac Speech Synthesis\n"); return(1); } mask = 1 << gestaltSpeechMgrPresent; if ((response & mask) == 0) { fprintf(stderr,"Mac Speech not supported\n"); return(1); } err = GetVoiceDescription(nil, &voiceDesc, sizeof(voiceDesc)); defaultVoiceSpec = voiceDesc.voice; err = NewSpeechChannel( &defaultVoiceSpec, &channel ); if (err != noErr) { DisposeSpeechChannel(channel); fprintf(stderr,"Failed to open a speech channel\n"); return(1); } last_speech_text[0] = '\0'; last_speech_time = (time_t)0; return(0); }
static void speech_done_cb(SpeechChannel scChannel, void *udata) { TextToSpeechPrivate *tts = reinterpret_cast<TextToSpeechPrivate *>(udata); Q_ASSERT(scChannel == tts->scChannel); DisposeSpeechChannel(tts->scChannel); if (tts->qlMessages.isEmpty()) tts->bRunning = false; else tts->ProcessSpeech(); }
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 SpeakingDone (SpeechChannel chan, long refCon) { DisposeSpeechChannel(chan); doneFlag++; }
static void speechDone(SpeechChannel sc2, void *) { if (sc2 == sc) { DisposeSpeechChannel(sc); } }
void tts_close() { sem_close(sem); DisposeSpeechChannel(channel); }
ofxSpeechSynthesizer::~ofxSpeechSynthesizer() { OSErr errorStatus; errorStatus = DisposeSpeechChannel(speechChannel); }