#!/usr/bin/perl use strict; use warnings; # speakPhonetic # This script speaks text using the NATO Phonetic Alphabet # (http://en.wikipedia.org/wiki/NATO_phonetic_alphabet). # The text is read from STDIN or from the files given as command-line arguments # # Cameron Hayne (macdev@hayne.net) Oct 2006 my %ph; # initialized in the BEGIN block below while (<>) { chomp(); s/([a-zA-Z0-9])/$ph{"\l$1"}, /g; system("/usr/bin/say $_"); } BEGIN { %ph = ( "a" => "Alpha", "b" => "Bravo", "c" => "Charlie", "d" => "Delta", "e" => "Echo", "f" => "Foxtrot", "g" => "Golf", "h" => "Hotel", "i" => "India", "j" => "Juliet", "k" => "Kilo", "l" => "Lima", "m" => "Mike", "n" => "November", "o" => "Oscar", "p" => "Papa", "q" => "Quebec", "r" => "Romeo", "s" => "Sierra", "t" => "Tango", "u" => "Uniform", "v" => "Victor", "w" => "Whisky", "x" => "Xray", "y" => "Yankee", "z" => "Zulu", "0" => "Zero", "1" => "One", "2" => "Two", "3" => "Three", "4" => "Four", "5" => "Five", "6" => "Six", "7" => "Seven", "8" => "Eight", "9" => "Nine", ); }