nvda.speech

What NVDA asked to say, and waiting for it.

def test_nvda_speaks_when_asked(nvda):
    before = nvda.speech.index()
    nvda.speech.speak("the quick brown fox")
    found = nvda.speech.wait_for("quick brown fox", timeout=20, since=before)
    assert "quick brown fox" in found.text

wait_for polls until a speech sequence matching the pattern arrives, since the given index — it will not pass on a stale sequence spoken before since, and raises on timeout instead of returning None.

Without since, wait_for snapshots index() at call time and only sees speech produced afterwards; capture index() before a synchronous action and pass it as since. pattern is a case-insensitive regex.

Method Returns

index()

the current cursor; pass it to since() to ignore everything so far

since(index)

every SpeechSequence after index

all()

every sequence this session (since(0))

last()

the most recent sequence, or None

clear()

drops captured speech

speak(text)

asks NVDA to speak text

cancel()

cancels current speech

cancel_count()

how many times speech was cancelled

wait_for_done(timeout=10.0)

returns once NVDA’s event queue has drained