Ubuntu – How to change the voice used by Firefox Reader View (Narrator) in Ubuntu

firefoxtext to speech

**how to change firefox reader view voice in ubuntu**

The default voice as well as all alternative voices are very difficult to understand.

I cannot find any documentation about how this feature is wired up.

Best Answer

  • I managed to use the festival voice as default on Firefox.

    enter image description here

    In order to do that, we need to change some configurations on the file /etc/speech-dispatcher/speechd.conf. But first, I need to explain the basic idea of how it works. We can always see what voice is the default one used by speech-dispatcher using the command spd-say:

    spd-say "Hello. How are you?"

    On Ubuntu, the default Texto To Speech (TTS) voice that comes with speech-dispatcher is espeak. So we hear exactly the same voice when we use this other command:

    espeak "Hello. How are you?"

    That happens because spd-say is just using espeak voices as output. And well, Firefox does the same, it uses whatever voice is configured in speech-dispatcher as output to read web pages in the reader view mode (Ctrl+Alt+R).

    So, what we need to do here is to change the voice that comes as output in the spd-say command and, once we do that, Firefox is going to use a different TTS voice as default as well. I'm going to describe the process of making it work with the festival voice, but I believe the procedure is the same if you want to run a different TTS voice. First, we need to install festival:

    sudo apt-get install festival

    We can test its voice in the command line by typing:

    echo "Hello. How are you?" | festival --tts

    Now we need to change the file speechd.conf. So we type sudo vi /etc/speech-dispatcher/speechd.conf on the terminal and around the line 205 we'll see the following piece of commented configurations:

    #AddModule "espeak"       "sd_espeak"   "espeak.conf"
    AddModule "festival"     "sd_festival"  "festival.conf"
    #AddModule "flite"        "sd_flite"     "flite.conf"
    #AddModule "ivona"    "sd_ivona"    "ivona.conf"
    #AddModule "pico"        "sd_pico"     "pico.conf"
    #AddModule "espeak-generic" "sd_generic" "espeak-generic.conf"
    #AddModule "espeak-mbrola-generic" "sd_generic" "espeak-mbrola-generic.conf"
    #AddModule "swift-generic" "sd_generic" "swift-generic.conf"
    #AddModule "epos-generic" "sd_generic"   "epos-generic.conf"
    #AddModule "dtk-generic"  "sd_generic"   "dtk-generic.conf"
    #AddModule "pico-generic"  "sd_generic"   "pico-generic.conf"
    #AddModule "ibmtts"       "sd_ibmtts"    "ibmtts.conf"
    #AddModule "cicero"        "sd_cicero"     "cicero.conf"
    # DO NOT REMOVE the following line unless you have
    # a specific reason -- this is the fallback output module
    # that is only used when no other modules are in use
    #AddModule "dummy"         "sd_dummy"      ""
    # The output module testing doesn't actually connect to anything. It
    # outputs the requested commands to standard output and reads
    # responses from stdandard input. This way, Speech Dispatcher's
    # communication with output modules can be tested easily.
    # AddModule "testing"
    # The DefaultModule selects which output module is the default.  You
    # must use one of the names of the modules loaded with AddModule.
    #DefaultModule espeak
    DefaultModule festival

    It's necessary to make two changes here:

    1. Uncomment the line AddModule "festival" "sd_festival" "festival.conf"
    2. Add the line DefaultModule festival

    We need to run festival as a server in order to make speech-dispatcher use it as default. We can do that by adding the following line at the end of the file that's open when we use the command sudo crontab -e:

    @reboot /usr/bin/festival --server

    Now it's done!! After rebooting the system Firefox and spd-say will be using the festival voice as output.

    Additional Information

    I believe that the procedure to make new voices work in Firefox will be always the same:

    1. Uncomment the module of the new TTS voice that we installed (/etc/speech-dispatcher/speechd.conf).

    2. Set a new default line for the TTS voice that we want (/etc/speech-dispatcher/speechd.conf).

    3. Run a server on the port specified on the files inside the folder /etc/speech-dispatcher/modules/.

    What called my attention on that is that there's a module for the Ivona voices there. Ivona is a proprietary product and today the only way to use it (as far as I know) is as a pay-as-you-go service on AWS, but its voices are really good and they sound very natural.

    The file /etc/speech-dispatcher/modules/ivona.conf is configured to listen to a server on the port 9123. I think perhaps there's a way to run a local server that gets the Ivona voices using my AWS APIs ( I'm not sure, but perhaps using a part of this Node.js app that's already developed) ... And if that's possible, it means that it's also possible to run Ivona on Ubuntu as the default voice of the system and consequently use it with the reader view mode on Firefox . Although I don't know how to do it now, it looks like an interesting possibility.

  • Related Question