bool success = false;
};
-class DlogTTS : public PredicateWaitInterface
+class WaitDlog : public PredicateWaitInterface
{
public:
- DlogTTS(BatchExecutor *executor, std::chrono::milliseconds timeout, std::string pattern)
+ WaitDlog(BatchExecutor *executor, std::chrono::milliseconds timeout, std::string pattern)
: PredicateWaitInterface(executor, timeout)
{
{
class WaitTTS : public PredicateWaitInterface
{
public:
- WaitTTS(BatchExecutor *executor, std::chrono::milliseconds timeout, std::string pattern)
+ WaitTTS(BatchExecutor *executor, std::chrono::milliseconds timeout, std::string pattern, bool exact)
: PredicateWaitInterface(executor, timeout)
{
this->pattern = pattern;
auto h = self->ttsInfo.lock();
if (!pattern.empty())
h->searchLine = std::move(pattern);
+ else
+ h->searchLine = {};
+ h->exact = exact;
h->mode = BatchExecutor::TTSInfo::Mode::search;
}
}
void BatchExecutor::insertWaits()
{
auto dlogTTS = [&](std::string pattern, double timeout) -> EvaluationValue {
- auto impl = std::make_shared<DlogTTS>(this, std::chrono::milliseconds{ static_cast<size_t>(timeout * 1000) }, std::move(pattern));
+ auto impl = std::make_shared<WaitDlog>(this, std::chrono::milliseconds{ static_cast<size_t>(timeout * 1000) }, std::move(pattern));
return EvaluationValue{ impl };
};
variables["dlog"] = EvaluationValueFunction{ std::move(dlogTTS), { { "pattern" }, { "timeout", 5.0 } } };
- auto waitTTS = [&](std::string pattern, double timeout) -> EvaluationValue {
- auto impl = std::make_shared<WaitTTS>(this, std::chrono::milliseconds{ static_cast<size_t>(timeout * 1000) }, std::move(pattern));
+ auto waitTTS = [&](std::string pattern, double timeout, bool exact) -> EvaluationValue {
+ auto impl = std::make_shared<WaitTTS>(this, std::chrono::milliseconds{ static_cast<size_t>(timeout * 1000) }, std::move(pattern), exact);
return EvaluationValue{ impl };
};
- variables["tts"] = EvaluationValueFunction{ std::move(waitTTS), { { "pattern", "" }, { "timeout", 5.0 } } };
+ variables["tts"] = EvaluationValueFunction{ std::move(waitTTS), { { "pattern", "" }, { "timeout", 5.0 }, { "exact", true } } };
auto waitGui = [&](std::string name, double timeout) -> EvaluationValue {
auto impl = std::make_shared<WaitGui>(this, std::chrono::milliseconds{ static_cast<size_t>(timeout * 1000) }, std::move(name));
if (!h->searchLine) {
h->mode = BatchExecutor::TTSInfo::Mode::found;
} else {
- if (txt.find("(tts_speak_do)") != std::string::npos) {
- auto z = txt.rfind(", text ");
+ if (txt.find("(send_chunk_to_tts)") != std::string::npos) {
+ static const auto prefix = std::string{ "Passing TEXT: " };
+ static const auto postfix = std::string{ " to TTS" };
+
+ auto z = txt.find(prefix);
if (z != std::string::npos) {
- z += 7;
- auto z2 = txt.rfind("))");
- if (z2 != std::string::npos) {
+ z += prefix.size();
+ auto z2 = txt.rfind(postfix);
+ if (z2 != std::string::npos && z2 > z) {
auto sub = txt.substr(z, z2 - z);
exec->outputStream() << "TTS: '" << sub << "'\n";
- if (sub.find(*h->searchLine) != std::string::npos) {
+ if ((h->exact && sub == *h->searchLine) || (!h->exact && sub.find(*h->searchLine) != std::string::npos)) {
h->mode = BatchExecutor::TTSInfo::Mode::found;
}
}