|
|
@ -12,7 +12,7 @@
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
|
|
#include "frontend/audio/dispenser.h"
|
|
|
|
#include "frontend/audio/assembler.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace ppspeech {
|
|
|
|
namespace ppspeech {
|
|
|
|
|
|
|
|
|
|
|
@ -21,7 +21,7 @@ using kaldi::VectorBase;
|
|
|
|
using kaldi::BaseFloat;
|
|
|
|
using kaldi::BaseFloat;
|
|
|
|
using std::unique_ptr;
|
|
|
|
using std::unique_ptr;
|
|
|
|
|
|
|
|
|
|
|
|
Dispenser::Dispenser(DispenserOptions opts,
|
|
|
|
Assembler::Assembler(AssemblerOptions opts,
|
|
|
|
unique_ptr<FrontendInterface> base_extractor) {
|
|
|
|
unique_ptr<FrontendInterface> base_extractor) {
|
|
|
|
frame_chunk_stride_ = opts.frame_chunk_stride;
|
|
|
|
frame_chunk_stride_ = opts.frame_chunk_stride;
|
|
|
|
frame_chunk_size_ = opts.frame_chunk_size;
|
|
|
|
frame_chunk_size_ = opts.frame_chunk_size;
|
|
|
@ -29,20 +29,20 @@ Dispenser::Dispenser(DispenserOptions opts,
|
|
|
|
dim_ = base_extractor_->Dim();
|
|
|
|
dim_ = base_extractor_->Dim();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Dispenser::Accept(const kaldi::VectorBase<kaldi::BaseFloat>& inputs) {
|
|
|
|
void Assembler::Accept(const kaldi::VectorBase<kaldi::BaseFloat>& inputs) {
|
|
|
|
// read inputs
|
|
|
|
// read inputs
|
|
|
|
base_extractor_->Accept(inputs);
|
|
|
|
base_extractor_->Accept(inputs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// pop feature chunk
|
|
|
|
// pop feature chunk
|
|
|
|
bool Dispenser::Read(kaldi::Vector<kaldi::BaseFloat>* feats) {
|
|
|
|
bool Assembler::Read(kaldi::Vector<kaldi::BaseFloat>* feats) {
|
|
|
|
feats->Resize(dim_ * frame_chunk_size_);
|
|
|
|
feats->Resize(dim_ * frame_chunk_size_);
|
|
|
|
bool result = Compute(feats);
|
|
|
|
bool result = Compute(feats);
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// read all data from base_feature_extractor_ into cache_
|
|
|
|
// read all data from base_feature_extractor_ into cache_
|
|
|
|
bool Dispenser::Compute(Vector<BaseFloat>* feats) {
|
|
|
|
bool Assembler::Compute(Vector<BaseFloat>* feats) {
|
|
|
|
// compute and feed
|
|
|
|
// compute and feed
|
|
|
|
bool result = false;
|
|
|
|
bool result = false;
|
|
|
|
while (feature_cache_.size() < frame_chunk_size_) {
|
|
|
|
while (feature_cache_.size() < frame_chunk_size_) {
|
|
|
@ -69,4 +69,4 @@ bool Dispenser::Compute(Vector<BaseFloat>* feats) {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace ppspeech
|
|
|
|
} // namespace ppspeech
|