Skip to navigation

read_spelled

View as MarkdownOpen in Claude

Return the units a caller spelled, one uppercase letter, digit, or symbol each, from the recognizer’s text. It reads the common ways a caller spells:

  • Letter by letter ("s m i t h"), or with a hyphen between letters ("S-M-I-T-H").
  • Letter names ("ess em eye tee aitch").
  • "S as in Sam": the letter, with the word after “as in” skipped.
  • NATO alphabet words ("sierra mike").
  • "double l" for two of a letter, and "double u" for W.
  • Digit words ("one two") and symbol words ("dot", "at", "dash", "underscore", "plus", "slash").

“Capital”, “uppercase”, “lowercase”, and similar words before a letter are dropped. A word that names no letter, such as "smith", is taken as spelled: its letters.

from signalwire.speech.spelling import read_spelled

Parameters

text
strRequired

The recognizer’s text.

oh_is_zero
boolDefaults to False

Keyword-only. True reads “oh” as the digit 0, for a code of digits. By default it’s the letter O.

Returns

list[str] — The units, in order. Pass them to spelling_variants() to list likely misrecognitions.

Example

from signalwire.speech.spelling import read_spelled
print(read_spelled("S as in Sam, m i t h"))
# ['S', 'M', 'I', 'T', 'H']
print(read_spelled("sierra mike india tango hotel"))
# ['S', 'M', 'I', 'T', 'H']
print(read_spelled("capital b double l oh"))
# ['B', 'L', 'L', 'O']
print(read_spelled("one two oh four", oh_is_zero=True))
# ['1', '2', '0', '4']

Part of the speech helpers module.