MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ analyze_implementation()

template<ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = Eigen::MatrixXd>
output_type MayaFlux::Yantra::PhonemeAnalyzer< InputType, OutputType >::analyze_implementation ( const input_type & input)
inlineoverrideprotectedvirtual

Pure virtual analysis implementation - derived classes implement this.

Parameters
inputInput data with metadata
Returns
Raw analysis output before granularity formatting

Implements MayaFlux::Yantra::Analyzer< InputType, OutputType >.

Definition at line 354 of file PhonemeAnalyzer.hpp.

355 {
356 try {
357 const auto& cfg = this->template config<PhonemeAnalyzerConfig>();
358 if (const std::string reason = diagnose(cfg); !reason.empty()) {
360 std::source_location::current(), "PhonemeAnalyzer: {}", reason);
361 }
362
364 const_cast<input_type&>(input));
365
366 if (data_span.size() != 1) {
368 std::source_location::current(), "PhonemeAnalyzer analyses one channel and was given {}", data_span.size());
369 }
370
372
373 constexpr size_t classes = HubertPhonemeModel::classes;
376 analysis.posteriors = network().process(samples);
377 analysis.frames = analysis.posteriors.size() / classes;
378 if (cfg.keep_embeddings) {
379 analysis.embeddings = network().hidden_states();
380 }
383
385
387 output.metadata = input.metadata;
388 output.facets = input.facets;
389 output.facets.set(analysis);
390 return output;
391 } catch (const std::exception& e) {
392 MF_ERROR(Journal::Component::Yantra, Journal::Context::ComputeMatrix, "Phoneme analysis failed: {}", e.what());
394 error_result.metadata = input.metadata;
395 error_result.facets = input.facets;
396 return error_result;
397 }
398 }
#define MF_ERROR(comp, ctx,...)
void store_current_analysis(AnalysisResultType &&result) const
Definition Analyzer.hpp:234
const Config & config() const
The stored config struct of type Config, or its defaults when none was set.
std::vector< float > process(std::span< const float > samples)
Run one utterance.
std::vector< float > hidden_states()
The state before the final layer for every frame of the latest utterance.
static std::tuple< NumericChannels, DataStructureInfo > extract_structured_double(T &compute_data)
Extract structured double data from Datum container or direct ComputeData with automatic container ha...
static void describe_frames(PhonemeAnalysis &analysis)
static std::string diagnose(const PhonemeAnalyzerConfig &config)
Why a config cannot be analysed.
HubertPhonemeModel & network() const
output_type make_output(const PhonemeAnalysis &analysis, PhonemeMethod method, DataStructureInfo &structure_info)
static void bound_events(PhonemeAnalysis &analysis, size_t samples)
Gives every event its sample range.
Which phoneme is spoken near each frame of a mono 16 kHz utterance, from a learned network.