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

◆ voiced_intervals()

std::vector< std::pair< size_t, size_t > > MayaFlux::Yantra::voiced_intervals ( StandardWaveformAnalyzer & analyzer,
std::span< const double > samples,
double threshold,
uint32_t hop )
inlinenodiscard

The stretches of a recording where the waveform is voiced.

Parameters
analyzerAnalyzer built from voicing_analyzer_config with the same hop.
samplesOne channel of samples.
thresholdPeriodicity at or above which a window is voiced.
hopHop of the analyzer. Each voiced window stands for the hop samples around its centre.
Returns
Sorted [start, end) pairs, voiced windows that touch joined.

Definition at line 143 of file SpeechSegmenter.hpp.

145{
146 if (samples.size() < WaveformAnalyzerConfig {}.window_size || hop == 0) {
147 return {};
148 }
149 const auto analysis = analyzer.analyze_waveform(
150 std::vector<Kakshya::DataVariant> { std::vector<double>(samples.begin(), samples.end()) });
151 if (analysis.channels.empty()) {
152 return {};
153 }
154 const auto& waveform = analysis.channels[0];
155
156 std::vector<size_t> cells;
157 for (size_t window = 0; window < waveform.periodicity.size() && window < waveform.window_positions.size(); ++window) {
158 if (waveform.periodicity[window] >= threshold) {
159 const auto& [first, last] = waveform.window_positions[window];
160 const size_t centre = (first + last) / 2;
161 cells.push_back(centre >= hop / 2 ? centre - hop / 2 : 0);
162 }
163 }
165 Kinesis::Discrete::intervals_from_window_starts(cells, hop, samples.size()));
166}
WaveformAnalysis analyze_waveform(const input_type &data)
Type-safe waveform analysis.
std::vector< std::pair< size_t, size_t > > intervals_from_window_starts(const std::vector< size_t > &window_starts, uint32_t window_size, size_t data_size)
Build [start, end) intervals from window start indices.
Definition Extract.cpp:147
std::vector< std::pair< size_t, size_t > > merge_intervals(const std::vector< std::pair< size_t, size_t > > &intervals)
Merge overlapping or adjacent half-open intervals.
Definition Extract.cpp:14
void threshold(std::span< const float > gray, std::span< float > dst, float value)
Global threshold writing into caller-supplied buffer.
Definition PixelOps.cpp:194
uint32_t window_size
Analysis window length in samples.
Definition Analyzer.hpp:64
std::vector< ChannelWaveform > channels
Settings of a WaveformAnalyzer.

References MayaFlux::Yantra::WaveformAnalyzer< InputType, OutputType >::analyze_waveform(), MayaFlux::Yantra::WaveformAnalysis::channels, MayaFlux::Kinesis::Discrete::intervals_from_window_starts(), MayaFlux::Kinesis::Discrete::merge_intervals(), MayaFlux::Kinesis::Vision::threshold(), and MayaFlux::Yantra::AnalyzerConfig::window_size.

Referenced by MayaFlux::Yantra::PhonemeExtractor< std::vector< Kakshya::DataVariant >, Kakshya::CompositeArray >::find_voiced().

Here is the call graph for this function:
Here is the caller graph for this function: