// Set variable node in topic skill read-out-tap
// Topic.Spoken = one spoken phrase, one character per item, comma separated
// Input: Global.TAP (text)

With(
  {
    nato: Table(
      {k:"A",v:"Alfa"},{k:"B",v:"Bravo"},{k:"C",v:"Charlie"},{k:"D",v:"Delta"},{k:"E",v:"Echo"},
      {k:"F",v:"Foxtrot"},{k:"G",v:"Golf"},{k:"H",v:"Hotel"},{k:"I",v:"India"},{k:"J",v:"Juliett"},
      {k:"K",v:"Kilo"},{k:"L",v:"Lima"},{k:"M",v:"Mike"},{k:"N",v:"November"},{k:"O",v:"Oscar"},
      {k:"P",v:"Papa"},{k:"Q",v:"Quebec"},{k:"R",v:"Romeo"},{k:"S",v:"Sierra"},{k:"T",v:"Tango"},
      {k:"U",v:"Uniform"},{k:"V",v:"Victor"},{k:"W",v:"Whiskey"},{k:"X",v:"X-ray"},{k:"Y",v:"Yankee"},{k:"Z",v:"Zulu"}
    ),
    sym: Table(
      {k:"!",v:"exclamation mark"},{k:"#",v:"hash"},{k:"@",v:"at sign"},{k:"-",v:"dash"},
      {k:"_",v:"underscore"},{k:".",v:"dot"},{k:"$",v:"dollar sign"},{k:"%",v:"percent"},
      {k:"&",v:"ampersand"},{k:"*",v:"asterisk"},{k:"?",v:"question mark"},{k:"+",v:"plus"},{k:"=",v:"equals"}
    ),
    chars: ForAll(Sequence(Len(Global.TAP)), Mid(Global.TAP, Value, 1))
  },
  Concat(
    chars,
    With(
      {c: Value, u: Upper(Value)},
      If(
        IsMatch(c, "[0-9]"), c,
        IsMatch(c, "[A-Z]"), "uppercase " & c & " as in " & LookUp(nato, k = u, v),
        IsMatch(c, "[a-z]"), "lowercase " & c & " as in " & LookUp(nato, k = u, v),
        Coalesce(LookUp(sym, k = c, v), c)
      )
    ),
    ", "
  )
)

// Message node (barge-in off), SSML:
// <speak><prosody rate="slow">{Topic.Spoken}</prosody></speak>
// If you want a pause per character, replace ", " above with ", <break time=\"400ms\"/> " and keep the SSML wrapper.
// Dutch read-out: swap "uppercase"/"lowercase"/"as in" for "hoofdletter"/"kleine letter"/"als in" when Global.Language = "nl".
