AppleScript名:すべてのTTS VoiceからLocale情報を抽出し、指定LocaleのTTS Voice名を取得 |
— Created 2015-08-25 by Takaaki Naganoya — Modified 2015-08-26 by Shane Stanley, Takaaki Naganoya — 2015 Piyomaru Software use AppleScript version "2.5" use scripting additions use framework "Foundation" use framework "AppKit" –すべてのTTS VoiceからIdentifier情報を抽出してユニーク化 set v1Res to getLocaleICodeFromTTSVoices() set vRes to choose from list v1Res with prompt "Select Locale" set v2Res to getTTSVoiceNameWithLanguage(first item of vRes) of me on getLocaleICodeFromTTSVoices() set aResList to getAttributeFromTTSVoices("VoiceLocaleIdentifier") of me return aResList as list end getLocaleICodeFromTTSVoices on getAttributeFromTTSVoices(anAttribute) set outArray to current application’s NSMutableArray’s new() set aList to current application’s NSSpeechSynthesizer’s availableVoices() set bList to aList as list repeat with i in bList set j to contents of i set aDict to (current application’s NSSpeechSynthesizer’s attributesForVoice:j) (outArray’s addObject:aDict) end repeat set aResArray to (outArray’s valueForKey:anAttribute) set aSet to current application’s NSMutableSet’s setWithArray:aResArray set aResList to aSet’s allObjects() return aResList as list end getAttributeFromTTSVoices on getTTSVoiceNameWithLanguage(voiceLang) set outArray to current application’s NSMutableArray’s new() set aList to current application’s NSSpeechSynthesizer’s availableVoices() set bList to aList as list repeat with i in bList set j to contents of i set aDIc to (current application’s NSSpeechSynthesizer’s attributesForVoice:j) (outArray’s addObject:aDIc) end repeat set aPredicate to current application’s NSPredicate’s predicateWithFormat_("VoiceLocaleIdentifier == %@", voiceLang) set filteredArray to outArray’s filteredArrayUsingPredicate:aPredicate set aResList to (filteredArray’s valueForKey:"VoiceName") as list return aResList end getTTSVoiceNameWithLanguage |
More from my site
(Visited 25 times, 1 visits today)