Skip to content

Commit

Permalink
Added another Pitch method:
Browse files Browse the repository at this point in the history
- get_fraction_of_locally_unvoiced_frames()
  • Loading branch information
hokiedsp committed Feb 22, 2021
1 parent e555f8a commit 206f148
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/parselmouth/Pitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,18 @@ PRAAT_CLASS_BINDING(Pitch) {
"get_maximum", &Pitch_getMaximum, "from_time"_a = 0.0, "to_time"_a = 0.0, "unit"_a = "HERTZ", "interpolate"_a = true,
GET_MAXIMUM_DOCSTRING);

def(
"get_fraction_of_locally_unvoiced_frames",
[](Pitch self, double tmin, double tmax, double ceiling,
double silenceThreshold, double voicingThreshold) {
MelderFraction out = Pitch_getFractionOfLocallyUnvoicedFrames(self, tmin, tmax, ceiling,
silenceThreshold, voicingThreshold);

return std::make_tuple(out.numerator / out.denominator, out.numerator, out.denominator);
},
"from_time"_a = 0.0, "to_time"_a = 0.0, "to_pitch"_a = 600.0, "silence_threshold"_a = 0.03,
"voicing_threshold"_a = 0.45, GET_FRACTION_OF_LOCALLY_UNVOICED_FRAMES_DOCSTRING);

// End added by @hokiedsp on 2/17/21

// TODO Pitch_Intensity_getMean & Pitch_Intensity_getMeanAbsoluteSlope ? (cfr. Intensity)
Expand Down
28 changes: 28 additions & 0 deletions src/parselmouth/Pitch_docstrings.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,32 @@ See Also
:praat:`Voice report`
)";

constexpr auto GET_FRACTION_OF_LOCALLY_UNVOICED_FRAMES_DOCSTRING = R"(Get unvoiced statistics
Returns the statistics related to the unvoiced periods
Parameters
----------
from_time : double=0.0
The starting time of the analysis time domain.
to_time : double=0.0
The ending time of the analysis time domain. Values outside this domain
are ignored. If `to_time` is not greater than `from_time`, the entire
time domain of the Pitch object is considered.
to_pitch : double=600.0
The maximum voice frequency
silence_threshold : double=0.03
The upper pitch strength limit of silent period
voicing_threshold : double 0.45
The lower pitch strength limit of voicing period
See Also
--------
:praat:`Voice report`
)";

}// namespace parselmouth
2 changes: 2 additions & 0 deletions tests/test_pitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ def test_get_maximum(pitch):
def test_get_quantile(pitch):
print(f"10% Quantile={pitch.get_quantile(0.1)}")

def test_get_fraction_of_locally_unvoiced_frames(pitch):
print(pitch.get_fraction_of_locally_unvoiced_frames())

0 comments on commit 206f148

Please sign in to comment.