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

◆ extract_implementation()

template<ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = Kakshya::CompositeArray>
output_type MayaFlux::Yantra::PhonemeExtractor< InputType, OutputType >::extract_implementation ( const input_type & input)
inlineoverrideprotectedvirtual

Pure virtual extraction implementation - derived classes implement this.

Parameters
inputInput data with metadata
Returns
Raw extraction output before scope processing

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

Definition at line 235 of file PhonemeExtractor.hpp.

236 {
237 try {
238 const auto& cfg = this->template config<PhonemeExtractorConfig>();
239 if (const std::string reason = diagnose(cfg); !reason.empty()) {
241 std::source_location::current(), "PhonemeExtractor: {}", reason);
242 }
243
245 if (channels.size() != 1) {
247 std::source_location::current(), "PhonemeExtractor analyses one channel and was given {}", channels.size());
248 }
249 const std::span<const double> samples { channels[0].data(), channels[0].size() };
250
252 record.config = cfg;
253 if (!samples.empty()) {
254 record.speech = m_speech.segment(samples, speech_segmenter_config(cfg)).speech;
256 if (gate_applies(cfg)) {
257 record.voiced = find_voiced(samples, cfg);
258 }
259 }
260
261 const auto rows = selected_rows(record);
263 output.metadata = input.metadata;
264 output.facets = input.facets;
265 output.facets.set(record);
266 return output;
267 } catch (const std::exception& e) {
268 MF_ERROR(Journal::Component::Yantra, Journal::Context::ComputeMatrix, "Phoneme extraction failed: {}", e.what());
270 error_result.metadata = input.metadata;
271 error_result.facets = input.facets;
272 return error_result;
273 }
274 }
#define MF_ERROR(comp, ctx,...)
const Config & config() const
The stored config struct of type Config, or its defaults when none was set.
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 std::string diagnose(const PhonemeExtractorConfig &config)
Why a config cannot be extracted with.
static std::vector< size_t > selected_rows(const PhonemeExtraction &record)
static bool gate_applies(const PhonemeExtractorConfig &cfg)
void recognise_phonemes(std::span< const double > samples, PhonemeExtraction &record)
output_type build_output(const PhonemeExtraction &record, const std::vector< size_t > &rows, std::span< const double > samples, DataStructureInfo &info)
std::vector< std::pair< size_t, size_t > > find_voiced(std::span< const double > samples, const PhonemeExtractorConfig &cfg)
The phonemes of a whole mono 16 kHz recording, with the pauses between speech taken out.
SpeechSegmenterConfig speech_segmenter_config(const PhonemeExtractorConfig &config)
The segmenter settings a PhonemeExtractorConfig implies.