Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > AppleScript Voices

AppleScript Voices
Thread Tools
Addicted to MacNN
Join Date: Sep 2000
Status: Offline
Reply With Quote
Nov 4, 2001, 01:45 PM
 
I needed to get the voices in Mac OS 9, so I used:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
set ext_path to path to extensions
set voices_path to (ext_path & <font color = red>"Voices"</font>) as string
set raw_voices_contents to list folder voices_path
set raw_voices_list to every item in raw_voices_contents
set chosen_voice to choose from list raw_voices_list with prompt <font color = red>"Select a voice"</font> default items chosen_voice
return chosen_voice
</font>[/code]

works good. Now in Mac OS X, that obviously doesn't work....

Problems:
I can't get path to "/System/Library/Speech/Voices"
I need to trim ".SpeechVoice" off of each item in the results.

Does anyone know how to fix these problems? I haven't been able to do the first one, and I don't know of an efficient (less than a billion line) method for the second either.
I always use protection when fscking my Mac... Do you?
     
Mac Elite
Join Date: Oct 2000
Status: Offline
Reply With Quote
Nov 4, 2001, 04:13 PM
 
Originally posted by macvillage.net:
<STRONG>Problems:
I can't get path to "/System/Library/Speech/Voices"
I need to trim ".SpeechVoice" off of each item in the results.

Does anyone know how to fix these problems? I haven't been able to do the first one, and I don't know of an efficient (less than a billion line) method for the second either.</STRONG>
Try this for the path...

tell application "Finder" to set tPath to {name of startup disk as string, ":System:Library:Speech:Voices:"} as string

A billion line method for the second one? You need to read about text manipulation

If your list of items is {"Victoria.SpeechVoice", "Ralph.SpeechVoice", "Cellos.SpeechVoice"} or whatever.. then try this...

set utVoices to {"Victoria.SpeechVoice", "Ralph.SpeechVoice", "Cellos.SpeechVoice"}
 set tVoices to {}
 
 repeat with aVoice from 1 to length of (items of utVoices)
  set end of tVoices to (items 1 thru -13 of (item aVoice of utVoices)) as string
 end repeat
 
 tVoices

Now.. to put it all together...

on run
  tell application "Finder" to set utVoices to name of every item of folder ({(name of startup disk) as string, ":System:Library:Speech:Voices:"} as string)
 
  set tVoices to {}
 
  repeat with aVoice from 1 to length of (items of utVoices)
  set end of tVoices to (items 1 thru -13 of (item aVoice of utVoices)) as string
  end repeat
 
  return choose from list tVoices OK button name "Choose" with prompt "Select a voice"
 end run

Keep in mind that has only been tested in OS 9.

Edit: I converted into hard spaces for the last part... I have a script that turns the clipboard into UBB.. but it also has ... or something..

[ 11-04-2001: Message edited by: Synotic ]
     
Addicted to MacNN
Join Date: Sep 2000
Status: Offline
Reply With Quote
Nov 4, 2001, 05:22 PM
 
seems to work.
I always use protection when fscking my Mac... Do you?
     
Forum Regular
Join Date: Aug 2001
Location: Vienna, Austria
Status: Offline
Reply With Quote
Nov 9, 2001, 07:52 AM
 
...and as soon as somebody installs a voice into ~/Library/Voices, /Network/Library/Voices or /Library/Voices, your app fails.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:58 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2