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);
 }
示例#2
0
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());
}
示例#3
0
void Speak(const void *text, long size)
{
    SpeechChannel chan;
    NewSpeechChannel (NULL, &chan);
    SetSpeechInfo(chan, soSpeechDoneCallBack, (void*)&SpeakingDone); 
    SpeakText (chan, text, size);
}
示例#4
0
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);
}
示例#6
0
文件: tts.c 项目: wdebeaum/cabot
/*
 * 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);
}
示例#8
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;
}
示例#9
0
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;
}