Fixed infinite loop with short recordings
This commit is contained in:
parent
78027ea63c
commit
81111ef96a
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "ProgressBar.h"
|
#include "ProgressBar.h"
|
||||||
#include <boost/optional/optional.hpp>
|
|
||||||
#include <gsl_util.h>
|
#include <gsl_util.h>
|
||||||
|
|
||||||
template<typename TCollection>
|
template<typename TCollection>
|
||||||
|
@ -11,6 +10,18 @@ void runParallel(
|
||||||
TCollection& collection,
|
TCollection& collection,
|
||||||
int maxThreadCount)
|
int maxThreadCount)
|
||||||
{
|
{
|
||||||
|
if (maxThreadCount < 1) {
|
||||||
|
throw std::invalid_argument(fmt::format("maxThreadCount cannot be {}.", maxThreadCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxThreadCount == 1) {
|
||||||
|
// Process synchronously
|
||||||
|
for (auto& element : collection) {
|
||||||
|
processElement(element);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
using future_type = std::future<void>;
|
using future_type = std::future<void>;
|
||||||
|
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
|
|
|
@ -444,7 +444,10 @@ BoundedTimeline<Phone> detectPhones(
|
||||||
// Don't waste time creating additional threads (and decoders!) if the recording is short
|
// Don't waste time creating additional threads (and decoders!) if the recording is short
|
||||||
static_cast<int>(duration_cast<std::chrono::seconds>(audioClip->getTruncatedRange().getLength()).count() / 5)
|
static_cast<int>(duration_cast<std::chrono::seconds>(audioClip->getTruncatedRange().getLength()).count() / 5)
|
||||||
});
|
});
|
||||||
logging::debug("Speech recognition -- start");
|
if (threadCount < 1) {
|
||||||
|
threadCount = 1;
|
||||||
|
}
|
||||||
|
logging::debugFormat("Speech recognition using {} threads -- start", threadCount);
|
||||||
runParallel(processUtterance, utterances, threadCount, dialogProgressSink, getUtteranceProgressWeight);
|
runParallel(processUtterance, utterances, threadCount, dialogProgressSink, getUtteranceProgressWeight);
|
||||||
logging::debug("Speech recognition -- end");
|
logging::debug("Speech recognition -- end");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue