Tuesday, February 3, 2015

how to add text to speech to goldendict

1- on menu bar click on "edit" --> "dictionaries"
2- on "dictionaries" window choose "Programs"

3- then click "add" on
- type choose "audio"
- command line write download your script/program and add %GDWORD% as the parameter for the current word
example: /home/user1/myttsEng.py %GDWORD%

- icon to distinguish when you add many tts


Below the script for tts

1- English

#!/usr/bin/python

import os
import sys

word = sys.argv[1]
os.system("echo " + word  +" | festival --tts" )


2- Russian

#!/usr/bin/python

import os
import sys

word = sys.argv[1]
os.system("echo " + word  +" | festival --tts --language russian" )



3- French
#!/usr/bin/nodejs

var pico = require('picotts')
opt = process.argv[2];
console.log(datavc)
pico.say(opt, 'fr-FR', function(err) {
          if (!err)
              console.log('Correctly played')
})


4- Spainish

#!/usr/bin/nodejs

var pico = require('picotts')
opt = process.argv[2];
console.log(datavc)
pico.say(opt, 'es-ES', function(err) {
          if (!err)
              console.log('Correctly played')
})




20 comments:

  1. Hi Dara Theam, I want to use SVox Pico `pico2wave` installing the following packages:

    libttspico0
    libttspico-utils
    libttspico-data

    I built your script but not working, this is my script:

    http://www.mediafire.com/view/le7hdposo6kk7i0/svoxgoldendict.py

    I use SVox Pico with LibreOffice from this:

    https://sites.google.com/site/readtextextension/home/linux

    I try with your instruccions to make working but no. Do you can help me to use with Goldendict

    ReplyDelete
  2. it's nodejs script,so make sure you install nodejs and install picotts package,

    $ sudo apt-get install nodejs
    $ sudo apt-get install npm
    $ sudo apt-get install libttspico-utils
    $ sudo npm install picotts

    ReplyDelete
  3. I follow all your instructions but in the four step fail to install(I using UbuntuStudio 16.04 x386). Here an snapshot:

    http://pix.toile-libre.org/upload/original/1466175791.png

    ReplyDelete
  4. use this command instead
    $ sudo npm install -g picotts

    ReplyDelete
  5. Install ok:

    http://pix.toile-libre.org/upload/original/1466223445.png

    This install some packages:

    http://pix.toile-libre.org/upload/original/1466223920.png

    This is the list:

    /home/wachin/node_modules/picotts/index.js
    /home/wachin/node_modules/picotts/package.json
    /home/wachin/node_modules/picotts/README.md
    /home/wachin/node_modules/picotts/test.js
    /home/wachin/os%0D
    /home/wachin/sys%0D

    now I try with english and spanish script but not have sound, here snapshot:

    http://pix.toile-libre.org/upload/original/1466223623.png

    I follow all your steps:

    script add in programs Goldendict tab
    http://pix.toile-libre.org/upload/original/1466224060.png

    script
    http://pix.toile-libre.org/upload/original/1466224181.png

    ReplyDelete
  6. if you run the script directly on terminal, does it product any sound
    $ /home/wachin/myttsEsp.py casa

    if not, you can check the permission, it must have executable permission.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Thanks for reply, permissions I set when I prepare the script:

    http://pix.toile-libre.org/upload/original/1466259725.png

    but when I run from terminal appear this:

    http://pix.toile-libre.org/upload/original/1466260368.png

    English translation would be:

    wachin@wachin-Inspiron-1750:~$ /home/wachin/myttsEsp.py casa
    bash: /home/wachin/myttsEsp.py: /usr/bin/nodejs^M: bad interpreter: No such file or directory

    Thanks for your help

    ReplyDelete
  9. But nodejs are present in my system in:

    /usr/bin/nodejs

    http://pix.toile-libre.org/upload/original/1466260804.png

    is a program with 11,2 MB

    ReplyDelete
  10. myttsEng.py sript not working also:

    http://pix.toile-libre.org/upload/original/1466261028.png

    I have installed festival

    ReplyDelete
  11. first you have to find where is your myttsEng.py stored
    your script:
    http://pix.toile-libre.org/upload/original/1466224181.png

    for example if it is stored in /home/wachin/code/myttsEsp.py,

    try run it again from the correct location
    $ /home/wachin/code/myttsEsp.py casa

    ReplyDelete
  12. The path is correct:

    /home/wachin/myttsEsp.py casa

    an snapshot explain this:

    http://pix.toile-libre.org/upload/original/1466262103.png

    ReplyDelete
  13. so if you run
    $ nodejs /home/wachin/myttsEsp.py casa

    is it working?

    ReplyDelete
  14. Appear this info, I dont understand what meaning:

    wachin@wachin-Inspiron-1750:~$ nodejs /home/wachin/myttsEsp.py casa
    /home/wachin/myttsEsp.py:5
    console.log(datavc)
    ^

    ReferenceError: datavc is not defined
    at Object. (/home/wachin/myttsEsp.py:5:13)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3
    wachin@wachin-Inspiron-1750:~$

    Here an terminal snapshot :

    http://pix.toile-libre.org/upload/original/1466263069.png

    ReplyDelete
  15. Python script working fine in terminal:

    python /home/wachin/myttsEng.py house

    http://pix.toile-libre.org/upload/original/1466263217.png

    I hear house

    ReplyDelete
  16. update script as below

    #!/usr/bin/nodejs

    var pico = require('picotts')
    opt = process.argv[2];

    pico.say(datavc, 'es-ES', function(err) {
    if (!err)
    console.log('Correctly played')
    })

    ReplyDelete
  17. I test with you new parameters in Goldendict English python script and Working fine. I add:

    python /home/wachin/myttsEng.py %GDWORD%

    to the Goldendict "Program" tab in command line. Wokfing fine, I hear in whatever word in english when I clic in the speaking icon

    ReplyDelete
  18. Hi, I made a tutorial in spanish. Working fine python script for english:


    Añadir Texto a Voz (Add Text to speech) en Goldendict (Inglés) en Ubuntu 16.04
    https://youtu.be/5Hds9gVy0BQ

    ReplyDelete
    Replies
    1. if you are still interested, this is the correct script for you ...

      #!/usr/bin/nodejs

      var pico = require('picotts')
      opt = process.argv[2];
      console.log('datavc')
      pico.say(opt, 'es-ES', function(err) {
      if (!err)
      console.log('Correctly played')
      })

      Delete
  19. TextAloud can change over wrote texts in normally sounding speech.text to speech

    ReplyDelete