我不小心损坏了属于语音合成服务器的 plist 文件,该如何修复?

我不小心损坏了属于语音合成服务器的 plist 文件,该如何修复?

我试图编写一个 AppleScript,它可以识别所选文本的语言,然后相应地设置语音合成语音,然后让我的 Mac 大声读出文本。

这是我取得的进展:

on run {input, parameters}

    set txt to (quoted form of (input as string))

    set resp to do shell script "curl -s https://ws.detectlanguage.com/0.2/detect -H 'Authorization: Bearer <my api key>'  -d q=" & txt & " | /usr/local/bin/jq '.data.detections[0].language'"

    set isDutch to resp is equal to "\"nl\""

    if isDutch then
        do shell script "
            defaults write com.apple.speech.voice.prefs SelectedVoiceID 5190
            defaults write com.apple.speech.voice.prefs SelectedVoiceName 'Pieter Siri'
        "
    else
        do shell script "
            defaults write com.apple.speech.voice.prefs SelectedVoiceID 101
            defaults write com.apple.speech.voice.prefs SelectedVoiceName 'Nora Siri'
        "
    end if

    do shell script "
        killall SpeechSynthesisServer
        pkill com.apple.speech.speechsynthesisd
    "

    -- and then here I was gonna try and see if I could
    -- press option+esc to trigger my Mac's native text to speech feature.

    return input
end run

我以为我已经想出了如何正确设置这些设置,但显然我错了,因为现在文本到语音不再起作用,当我尝试在系统偏好设置中打开它时,我看到的是:

系统偏好设置错误

答案1

好的,解决方案是删除我的com.apple.speech.voice.prefs.plist文件,这是我从 reddit 上的一个用户那里学到的。它重置了我所有与语音相关的设置,但这比完全重新安装要好。

相关内容