summaryrefslogtreecommitdiff
path: root/source/use_case/asr/src
diff options
context:
space:
mode:
Diffstat (limited to 'source/use_case/asr/src')
-rw-r--r--source/use_case/asr/src/UseCaseHandler.cc2
-rw-r--r--source/use_case/asr/src/Wav2LetterModel.cc12
-rw-r--r--source/use_case/asr/src/Wav2LetterPostprocess.cc32
-rw-r--r--source/use_case/asr/src/Wav2LetterPreprocess.cc66
4 files changed, 55 insertions, 57 deletions
diff --git a/source/use_case/asr/src/UseCaseHandler.cc b/source/use_case/asr/src/UseCaseHandler.cc
index 43b17dc..dcc879f 100644
--- a/source/use_case/asr/src/UseCaseHandler.cc
+++ b/source/use_case/asr/src/UseCaseHandler.cc
@@ -50,8 +50,6 @@ namespace app {
* object.
* @param[in] platform Reference to the hal platform object.
* @param[in] results Vector of classification results to be displayed.
- * @param[in] infTimeMs Inference time in milliseconds, if available
- * otherwise, this can be passed in as 0.
* @return true if successful, false otherwise.
**/
static bool PresentInferenceResult(
diff --git a/source/use_case/asr/src/Wav2LetterModel.cc b/source/use_case/asr/src/Wav2LetterModel.cc
index 5aefecd..6f87be8 100644
--- a/source/use_case/asr/src/Wav2LetterModel.cc
+++ b/source/use_case/asr/src/Wav2LetterModel.cc
@@ -20,18 +20,18 @@
const tflite::MicroOpResolver& arm::app::Wav2LetterModel::GetOpResolver()
{
- return this->_m_opResolver;
+ return this->m_opResolver;
}
bool arm::app::Wav2LetterModel::EnlistOperations()
{
- this->_m_opResolver.AddConv2D();
- this->_m_opResolver.AddMul();
- this->_m_opResolver.AddMaximum();
- this->_m_opResolver.AddReshape();
+ this->m_opResolver.AddConv2D();
+ this->m_opResolver.AddMul();
+ this->m_opResolver.AddMaximum();
+ this->m_opResolver.AddReshape();
#if defined(ARM_NPU)
- if (kTfLiteOk == this->_m_opResolver.AddEthosU()) {
+ if (kTfLiteOk == this->m_opResolver.AddEthosU()) {
info("Added %s support to op resolver\n",
tflite::GetString_ETHOSU());
} else {
diff --git a/source/use_case/asr/src/Wav2LetterPostprocess.cc b/source/use_case/asr/src/Wav2LetterPostprocess.cc
index b1bcdc8..fd11eef 100644
--- a/source/use_case/asr/src/Wav2LetterPostprocess.cc
+++ b/source/use_case/asr/src/Wav2LetterPostprocess.cc
@@ -27,11 +27,11 @@ namespace asr {
Postprocess::Postprocess(const uint32_t contextLen,
const uint32_t innerLen,
const uint32_t blankTokenIdx)
- : _m_contextLen(contextLen),
- _m_innerLen(innerLen),
- _m_totalLen(2 * this->_m_contextLen + this->_m_innerLen),
- _m_countIterations(0),
- _m_blankTokenIdx(blankTokenIdx)
+ : m_contextLen(contextLen),
+ m_innerLen(innerLen),
+ m_totalLen(2 * this->m_contextLen + this->m_innerLen),
+ m_countIterations(0),
+ m_blankTokenIdx(blankTokenIdx)
{}
bool Postprocess::Invoke(TfLiteTensor* tensor,
@@ -51,7 +51,7 @@ namespace asr {
if (0 == elemSz) {
printf_err("Tensor type not supported for post processing\n");
return false;
- } else if (elemSz * this->_m_totalLen > tensor->bytes) {
+ } else if (elemSz * this->m_totalLen > tensor->bytes) {
printf_err("Insufficient number of tensor bytes\n");
return false;
}
@@ -88,7 +88,7 @@ namespace asr {
return false;
}
- if (static_cast<int>(this->_m_totalLen) !=
+ if (static_cast<int>(this->m_totalLen) !=
tensor->dims->data[axisIdx]) {
printf_err("Unexpected tensor dimension for axis %d, \n",
tensor->dims->data[axisIdx]);
@@ -124,31 +124,31 @@ namespace asr {
{
/* In this case, the "zero-ing" is quite simple as the region
* to be zeroed sits in contiguous memory (row-major). */
- const uint32_t eraseLen = strideSzBytes * this->_m_contextLen;
+ const uint32_t eraseLen = strideSzBytes * this->m_contextLen;
/* Erase left context? */
- if (this->_m_countIterations > 0) {
+ if (this->m_countIterations > 0) {
/* Set output of each classification window to the blank token. */
std::memset(ptrData, 0, eraseLen);
- for (size_t windowIdx = 0; windowIdx < this->_m_contextLen; windowIdx++) {
- ptrData[windowIdx*strideSzBytes + this->_m_blankTokenIdx] = 1;
+ for (size_t windowIdx = 0; windowIdx < this->m_contextLen; windowIdx++) {
+ ptrData[windowIdx*strideSzBytes + this->m_blankTokenIdx] = 1;
}
}
/* Erase right context? */
if (false == lastIteration) {
- uint8_t * rightCtxPtr = ptrData + (strideSzBytes * (this->_m_contextLen + this->_m_innerLen));
+ uint8_t * rightCtxPtr = ptrData + (strideSzBytes * (this->m_contextLen + this->m_innerLen));
/* Set output of each classification window to the blank token. */
std::memset(rightCtxPtr, 0, eraseLen);
- for (size_t windowIdx = 0; windowIdx < this->_m_contextLen; windowIdx++) {
- rightCtxPtr[windowIdx*strideSzBytes + this->_m_blankTokenIdx] = 1;
+ for (size_t windowIdx = 0; windowIdx < this->m_contextLen; windowIdx++) {
+ rightCtxPtr[windowIdx*strideSzBytes + this->m_blankTokenIdx] = 1;
}
}
if (lastIteration) {
- this->_m_countIterations = 0;
+ this->m_countIterations = 0;
} else {
- ++this->_m_countIterations;
+ ++this->m_countIterations;
}
return true;
diff --git a/source/use_case/asr/src/Wav2LetterPreprocess.cc b/source/use_case/asr/src/Wav2LetterPreprocess.cc
index d65ea75..e5ac3ca 100644
--- a/source/use_case/asr/src/Wav2LetterPreprocess.cc
+++ b/source/use_case/asr/src/Wav2LetterPreprocess.cc
@@ -32,18 +32,18 @@ namespace asr {
const uint32_t windowLen,
const uint32_t windowStride,
const uint32_t numMfccVectors):
- _m_mfcc(numMfccFeatures, windowLen),
- _m_mfccBuf(numMfccFeatures, numMfccVectors),
- _m_delta1Buf(numMfccFeatures, numMfccVectors),
- _m_delta2Buf(numMfccFeatures, numMfccVectors),
- _m_windowLen(windowLen),
- _m_windowStride(windowStride),
- _m_numMfccFeats(numMfccFeatures),
- _m_numFeatVectors(numMfccVectors),
- _m_window()
+ m_mfcc(numMfccFeatures, windowLen),
+ m_mfccBuf(numMfccFeatures, numMfccVectors),
+ m_delta1Buf(numMfccFeatures, numMfccVectors),
+ m_delta2Buf(numMfccFeatures, numMfccVectors),
+ m_windowLen(windowLen),
+ m_windowStride(windowStride),
+ m_numMfccFeats(numMfccFeatures),
+ m_numFeatVectors(numMfccVectors),
+ m_window()
{
if (numMfccFeatures > 0 && windowLen > 0) {
- this->_m_mfcc.Init();
+ this->m_mfcc.Init();
}
}
@@ -52,45 +52,45 @@ namespace asr {
const uint32_t audioDataLen,
TfLiteTensor* tensor)
{
- this->_m_window = SlidingWindow<const int16_t>(
+ this->m_window = SlidingWindow<const int16_t>(
audioData, audioDataLen,
- this->_m_windowLen, this->_m_windowStride);
+ this->m_windowLen, this->m_windowStride);
uint32_t mfccBufIdx = 0;
- std::fill(_m_mfccBuf.begin(), _m_mfccBuf.end(), 0.f);
- std::fill(_m_delta1Buf.begin(), _m_delta1Buf.end(), 0.f);
- std::fill(_m_delta2Buf.begin(), _m_delta2Buf.end(), 0.f);
+ std::fill(m_mfccBuf.begin(), m_mfccBuf.end(), 0.f);
+ std::fill(m_delta1Buf.begin(), m_delta1Buf.end(), 0.f);
+ std::fill(m_delta2Buf.begin(), m_delta2Buf.end(), 0.f);
/* While we can slide over the window. */
- while (this->_m_window.HasNext()) {
- const int16_t* mfccWindow = this->_m_window.Next();
+ while (this->m_window.HasNext()) {
+ const int16_t* mfccWindow = this->m_window.Next();
auto mfccAudioData = std::vector<int16_t>(
mfccWindow,
- mfccWindow + this->_m_windowLen);
- auto mfcc = this->_m_mfcc.MfccCompute(mfccAudioData);
- for (size_t i = 0; i < this->_m_mfccBuf.size(0); ++i) {
- this->_m_mfccBuf(i, mfccBufIdx) = mfcc[i];
+ mfccWindow + this->m_windowLen);
+ auto mfcc = this->m_mfcc.MfccCompute(mfccAudioData);
+ for (size_t i = 0; i < this->m_mfccBuf.size(0); ++i) {
+ this->m_mfccBuf(i, mfccBufIdx) = mfcc[i];
}
++mfccBufIdx;
}
/* Pad MFCC if needed by adding MFCC for zeros. */
- if (mfccBufIdx != this->_m_numFeatVectors) {
- std::vector<int16_t> zerosWindow = std::vector<int16_t>(this->_m_windowLen, 0);
- std::vector<float> mfccZeros = this->_m_mfcc.MfccCompute(zerosWindow);
+ if (mfccBufIdx != this->m_numFeatVectors) {
+ std::vector<int16_t> zerosWindow = std::vector<int16_t>(this->m_windowLen, 0);
+ std::vector<float> mfccZeros = this->m_mfcc.MfccCompute(zerosWindow);
- while (mfccBufIdx != this->_m_numFeatVectors) {
- memcpy(&this->_m_mfccBuf(0, mfccBufIdx),
- mfccZeros.data(), sizeof(float) * _m_numMfccFeats);
+ while (mfccBufIdx != this->m_numFeatVectors) {
+ memcpy(&this->m_mfccBuf(0, mfccBufIdx),
+ mfccZeros.data(), sizeof(float) * m_numMfccFeats);
++mfccBufIdx;
}
}
/* Compute first and second order deltas from MFCCs. */
- Preprocess::ComputeDeltas(this->_m_mfccBuf,
- this->_m_delta1Buf,
- this->_m_delta2Buf);
+ Preprocess::ComputeDeltas(this->m_mfccBuf,
+ this->m_delta1Buf,
+ this->m_delta2Buf);
/* Normalise. */
this->Normalise();
@@ -206,9 +206,9 @@ namespace asr {
void Preprocess::Normalise()
{
- Preprocess::NormaliseVec(this->_m_mfccBuf);
- Preprocess::NormaliseVec(this->_m_delta1Buf);
- Preprocess::NormaliseVec(this->_m_delta2Buf);
+ Preprocess::NormaliseVec(this->m_mfccBuf);
+ Preprocess::NormaliseVec(this->m_delta1Buf);
+ Preprocess::NormaliseVec(this->m_delta2Buf);
}
float Preprocess::GetQuantElem(