Tessera Speaking Pitch
Public facade for natural speaking pitch detection.
What is Speaking Pitch?
Speaking pitch is the median fundamental frequency of a person's voice during natural speech — their vocal "home base." It's useful for:
Voice profiling — establish a singer's natural pitch register.
Shruti suggestion — recommend a musical tonic (Sa) for practice.
Voice type classification — soprano, tenor, bass, etc.
The algorithm extracts voiced pitch values and takes a robust median, filtering out unvoiced frames and outliers.
When to Use
| Scenario | Use This | Why |
|---|---|---|
| Detect speaking pitch from speech audio | detectFromAudio | One-shot, accepts any sample rate |
| Detect from an already-extracted pitch contour | detect | Avoids redundant pitch extraction |
| Detect from a raw pitch array | detectFromPitch | Low-level entry point |
Quick Start
Kotlin
val hz = TesseraSpeakingPitch.detectFromAudio(audioSamples, sampleRate = 16000)
if (hz > 0) println("Speaking pitch: ${hz} Hz")Swift
let hz = TesseraSpeakingPitch.detectFromAudio(audioMono: audioSamples, sampleRate: 16000)
if hz > 0 { print("Speaking pitch: \(hz) Hz") }Common Pitfalls
Returns 0 on failure: Not an exception — a sentinel indicating "could not detect." Always check
> 0before using.Needs speech, not singing: The median-based algorithm is tuned for natural speech. For singing, use TesseraBreath or Tessera.analyze.
Contour must be non-empty:
detect(contour)throws on empty input.detectFromPitch(pitchesHz)does NOT throw — it returns 0 for empty arrays.
See also
For multi-metric batch analysis
To convert the result to a note name