指定のテキスト読み上げ(Text To Speech)ボイスキャラクターの読み上げ例文テキストを取得して実際に読み上げるAppleScriptです。
TTS音声は言語や性別、年齢、高音質かどうかなどの情報を持っているので、これらを指定して絞り込むことが可能です。また、指定TTS音声キャラクターの例文テキストもこのように取得できます。
AppleScript名:指定TTSボイスキャラクタの読み上げ例文テキストを取得.scpt |
— Created 2015-08-25 by Takaaki Naganoya — Modified 2015-08-26 by Shane Stanley, Takaaki Naganoya — Modified 2020-07-06 by Takaaki Naganoya — 2020 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "AppKit" use scripting additions set vList to getVoiceNames() of me using terms from scripting additions set aTargTTSVoiceName to contents of (choose from list vList) end using terms from using terms from scripting additions set v1Res to getDemoText(aTargTTSVoiceName) of me say v1Res using aTargTTSVoiceName end using terms from –Get TTS Voice sample text on getDemoText(aName as string) set vList to getVoiceNames() of me if aName is not in vList then return "" set anID to getSpecifiedVoiceIDfromVoiceName(aName) of me set aDemoText to ((current application’s NSSpeechSynthesizer’s attributesForVoice:anID)’s VoiceDemoText) return aDemoText as string end getDemoText –Get all voice names on getVoiceNames() –Make Blank Array set outArray to current application’s NSMutableArray’s arrayWithObject:{} set aList to {} –Make Installed Voice List set nameList to current application’s NSSpeechSynthesizer’s availableVoices() repeat with i in nameList set j to contents of i set aDic to ((current application’s NSSpeechSynthesizer’s attributesForVoice:j)) set aDemoText to (aDic’s VoiceDemoText) as string set aName to (aDic’s VoiceName) as string set the end of aList to aName end repeat return aList as list end getVoiceNames –Voice Name –> Voice ID on getSpecifiedVoiceIDfromVoiceName(VoiceName as string) set outArray to current application’s NSMutableArray’s arrayWithObject:{} 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 –Filter Voice set aPredicate to current application’s NSPredicate’s predicateWithFormat_("VoiceName == %@", VoiceName) set filteredArray to outArray’s filteredArrayUsingPredicate:aPredicate set aReList to (filteredArray’s valueForKey:"VoiceIdentifier") as list if length of aReList = 1 then return first item of aReList else return "" end if end getSpecifiedVoiceIDfromVoiceName |
More from my site
(Visited 175 times, 1 visits today)