void OkularTTS::slotSpeechStateChanged(QTextToSpeech::State state) { if (state == QTextToSpeech::Speaking) emit isSpeaking(true); else emit isSpeaking(false); }
bool speakText(std::vector<std::string> text, int speechID) { if(!isSpeaking()) { speechIDStatic = speechID; JniMethodInfo minfo; jobject instance = getInstance(); bool functionExist = JniHelper::getMethodInfo(minfo, CLASS_NAME,"speakText", "([Ljava/lang/String;)Z"); CCAssert(functionExist, "Function doesn't exist"); minfo.env->DeleteLocalRef(minfo.classID); //Not required, we call the method directly on the instance jclass jStringCls = minfo.env->FindClass("java/lang/String"); jstring string = minfo.env->NewStringUTF(""); jobjectArray ret = (jobjectArray)minfo.env->NewObjectArray(text.size(), jStringCls, string); minfo.env->DeleteLocalRef(jStringCls); minfo.env->DeleteLocalRef(string); for(int i = 0; i < text.size(); i++) { string = minfo.env->NewStringUTF(text[i].c_str()); minfo.env->SetObjectArrayElement(ret, i, string); minfo.env->DeleteLocalRef(string); } minfo.env->CallBooleanMethod(instance, minfo.methodID, ret); minfo.env->DeleteLocalRef(instance); minfo.env->DeleteLocalRef(ret); } return false; }
void Transmitter::send(float *sample, int samples) { if (isSpeaking(sample, samples)) { if (status == TRANSMITTER_STATUS_WAITING) status = TRANSMITTER_STATUS_START; speak = stoptx; // To guarantee stream even for small speech pauses } switch (status) { case TRANSMITTER_STATUS_START: sendAudioPacket(prebuffer, frame_size); status = TRANSMITTER_STATUS_NORMAL; case TRANSMITTER_STATUS_NORMAL: if (speak > 0) { sendAudioPacket(sample, samples); speak--; break; } else { status = TRANSMITTER_STATUS_WAITING; } case TRANSMITTER_STATUS_WAITING: // It keeps the previous buffer to anticipate a little the speech memcpy(prebuffer, sample, samples*sizeof(float)); case TRANSMITTER_STATUS_MUTE: ledOn(false); break; } }
void Phone::sendAudioData(float *sample, int samples) { if (isSpeaking(sample, samples)) { if (rec_status == RECORDER_STATUS_WAITING) rec_status = RECORDER_STATUS_START; speak = stoptx; // To guarantee stream even for small speech pauses } switch (rec_status) { case RECORDER_STATUS_START: send(prebuffer, frame_size); rec_status = RECORDER_STATUS_RUNNING; case RECORDER_STATUS_RUNNING: if (speak > 0) { send(sample, samples); break; } else { rec_status = RECORDER_STATUS_WAITING; } case RECORDER_STATUS_WAITING: // It keeps the previous buffer to anticipate a little the speech memcpy(prebuffer, sample, samples*sizeof(float)); case RECORDER_STATUS_MUTE: case RECORDER_STATUS_STOP: break; } }
void Monster::speak(std::string soundFile, bool shouldInterrupt) { if(isSpeaking() == NULL) { mVoice = game->getSoundEngine()->play3DSoundKeep(soundFile, mPosition, 1.0f, randomFloat(0.75f, 2.0f)); } else if(mVoice->isFinished() || shouldInterrupt) { mVoice->stop(); mVoice->drop(); mVoice = game->getSoundEngine()->play3DSoundKeep(soundFile, mPosition, 1.0f, randomFloat(0.75f, 2.0f)); } }