– Tested in Tiger where “list voices” doesn’t work
tell application "Finder" to set v to list folder (path to voices as Unicode text) without invisibles
set vn to {}
set text item delimiters to ".SpeechVoice"
repeat with k from 1 to count of v
tell text item 1 of item k of v
if it is not in {"BadNews", "GoodNews", "Organ"} then
set end of vn to it
else if it is "BadNews" then
set end of vn to "Bad News"
else if it is "GoodNews" then
set end of vn to "Good News"
else
set end of vn to "Pipe Organ"
end if
end tell
end repeat
set tVoice to choose from list vn without multiple selections allowed and empty selection allowed
set text item delimiters to ""
if tVoice is not false then say "This is a sample of " & tVoice using tVoice
In another venue, Kai added this method for testing voices which goes after the proper name directly from the voice resource:
to test_voice()
set F to path to voices as Unicode text
set l to list folder F without invisibles
repeat with i in l
set t to read file (F & i & ":Contents:Resources:VoiceDescription")
set i's contents to t's text 18 thru (17 + (ASCII number t's character 17))
end repeat
set v to choose from list l with prompt "Please choose a voice:"
if v is not false then say "This is a sample of " & v using v
end test_voice
test_voice()
This variation uses the default phrase for each voice:
to demo_voice()
set f to path to voices as Unicode text
set l to list folder f without invisibles
set s to l's items
set c to count l
repeat with i from 1 to c
set t to read file (f & l's item i & ":Contents:Resources:VoiceDescription")
set s's item i to t
set l's item i to t's text 18 thru (17 + (ASCII number t's character 17))
end repeat
set v to choose from list l with prompt "Please choose a voice:"
if v is false then return
tell v's item 1 to repeat with i from 1 to c
if it is l's item i then exit repeat
end repeat
set i to s's item i
say i's text 82 thru (81 + (ASCII number i's character 81)) & "[[inpt PHON]]%" using v
end demo_voice
demo_voice()