I made this program that utilizes the built in speech voice, and what I want is a pop-up menu that lets you select from the different speech voices, which can then be stored in the preferences. I can do the preference part, but I’m stuck on the pop-up menu, let alone getting the list of speech voices into it. �Me ayudas, por favor!
I’m afraid I can’t asnwer your question, sorry
but I waswondering… do you know how to save preferences that set the popup buttons menu item when the app is launched? all my other preferences are working on launch, but I can’t get the popup to work!!
This assumes you have a window named “main” with a popup button named “voices”. Make sure the window is attached to the script’s “awake from nib” and “choose menu item” handlers. Then, in your script, add this:
on awake from nib the_object
set object_name to name of the_object as string
if object_name = "main" then
set default_voice to "Victoria"
set path_to_Voices to (path to "fvoc") as string
set the_voices to (list folder path_to_Voices)
set old_delim to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
tell menu of popup button "voices" of window "main"
try
delete menu items
end try
repeat with this_voice in the_voices
set this_voice to (text item 1 of (contents of this_voice))
if this_voice ends with "News" then set this_voice to ((text 1 thru -5 of this_voice) & " News")
--there's a bug in the Good News voice so don't use it
if this_voice is not "Good News" then make new menu item at end with properties {title:this_voice}
end repeat
end tell
set AppleScript's text item delimiters to old_delim
--this is how you set the selection of the popup to the default
set title of popup button "voices" of window "main" to default_voice
end if
end awake from nib
on choose menu item the_object
set object_name to name of the_object as string
if object_name = "voices" then
set the_voice to title of the_object
say "You chose " & the_voice using the_voice
end if
end choose menu item
As noted above, there’s a bug in the “Good News” voice. (See this thread.)
Jon