Text-to-speech in GoldenDict

dictionarytext to speech

I know how to add text-to-speech feature to GoldenDict in Linux, but I searched everywhere for a solution for Windows, and found nothing.

Best Answer

The same solution should work in Windows, but you need something equivalent to espeak.

Here is a PowerShell snippet that, using .NET classes, reads some text:

Add-Type -AssemblyName System.speech
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
$speak.Speak('Hello.')

Here is the equivalent command that can be run in Windows Command Prompt (cmd.exe):

PowerShell -Command "Add-Type –AssemblyName System.Speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak('hello');"

Using the above command (and replacing 'hello' with '%GDWORD%'), and steps mentioned in post above, we can achieve the same thing.

Here are the full steps:

  1. Open GoldenDict and press F3 to bring up the Dictionaries window.

  2. On the Sources tab, select Programs tab.

  3. Click the Add button, select Audio for the Type column, enter some name ("tts" for example) in the Name column, and the following command for the Command Line column:

    PowerShell -Command "Add-Type –AssemblyName System.Speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak('%GDWORD%');"
    
  4. Don't forget to check the Enabled box.

  5. Click OK

This uses the default voice in Windows. If you want to use a female voice, use the following command instead:

PowerShell -Command "Add-Type –AssemblyName System.Speech; $s=(New-Object System.Speech.Synthesis.SpeechSynthesizer); $s.SelectVoiceByHints(2); $s.Speak('%GDWORD%');"

Configuring the voice is easy, if you are a .NET programmer and know PowerShell.

Related Question