0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Mac 読み上げ言語を切り替えるシェルスクリプト

Last updated at Posted at 2021-01-13

読み上げ言語の切り替え

日本語だったら英語に、英語だったら日本語に切り替えるためのシェルスクリプトです。

automatorに実行させて、ショートカットで動くようにしています。
スクリプトを直接実行させると反映されなかったので、シェルをファイルに保存して、bash speech.shのように実行させています。

#!/bin/sh

SelectedVoiceID=`/usr/libexec/PlistBuddy -c "print SelectedVoiceID" ~/Library/Preferences/com.apple.speech.voice.prefs.plist`

if [ $SelectedVoiceID != 369275117 ]; then
	/usr/libexec/PlistBuddy -c "set SelectedVoiceID 369275117" ~/Library/Preferences/com.apple.speech.voice.prefs.plist
	/usr/libexec/PlistBuddy -c "set SelectedVoiceCreator 1886745202" ~/Library/Preferences/com.apple.speech.voice.prefs.plist
	/usr/libexec/PlistBuddy -c "set SelectedVoiceName Kyoko" ~/Library/Preferences/com.apple.speech.voice.prefs.plist
else
	/usr/libexec/PlistBuddy -c "set SelectedVoiceID 184560141" ~/Library/Preferences/com.apple.speech.voice.prefs.plist
	/usr/libexec/PlistBuddy -c "set SelectedVoiceCreator 1886745202" ~/Library/Preferences/com.apple.speech.voice.prefs.plist
	/usr/libexec/PlistBuddy -c "set SelectedVoiceName Ava" ~/Library/Preferences/com.apple.speech.voice.prefs.plist
fi

killall com.apple.speech.speechsynthesisd
killall SpeechSynthesisServer
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?