TesseraSpeakingPitch

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

ScenarioUse ThisWhy
Detect speaking pitch from speech audiodetectFromAudioOne-shot, accepts any sample rate
Detect from an already-extracted pitch contourdetectAvoids redundant pitch extraction
Detect from a raw pitch arraydetectFromPitchLow-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

  1. Returns 0 on failure: Not an exception — a sentinel indicating "could not detect." Always check > 0 before using.

  2. Needs speech, not singing: The median-based algorithm is tuned for natural speech. For singing, use TesseraBreath or Tessera.analyze.

  3. 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

Functions

Link copied to clipboard
fun detect(contour: PitchContour): Float

Detect speaking pitch from a PitchContour.

Link copied to clipboard
fun detectFromAudio(audioMono: FloatArray, sampleRate: Int = 16000): Float

Detect speaking pitch from raw audio samples.

Link copied to clipboard

Detect speaking pitch from a pitch array.