Extension:Wikispeech

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
Wikispeech

Release status:Extension status beta

Wikispeech logo.svg
ImplementationTemplate:Extension#type other (invalid type)
DescriptionTemplate:Extension#description Integrates Wikispeech into MediaWiki for text-to-speech functionality
Author(s)Template:Extension#username
  • Sebastian Berlin
LicenseTemplate:Extension#license GNU General Public License 2.0 or later
Download
[ README]
ParametersTemplate:Extension#parameters
  • $wgWikispeechServerUrl
  • $wgWikispeechRemoveTags
  • $wgWikispeechNamespaces
  • $wgWikispeechKeyboardShortcuts
  • $wgWikispeechSkipBackRewindsThreshold
Hooks usedTemplate:Extension#hook
ResourceLoaderTestModulesManual:Hooks/ResourceLoaderTestModules
ParserAfterTidyManual:Hooks/ParserAfterTidy
BeforePageDisplayManual:Hooks/BeforePageDisplay
ResourceLoaderGetConfigVarsManual:Hooks/ResourceLoaderGetConfigVars

Translate the Wikispeech extension if it is available at translatewiki.net

Check usage and version matrix.
Vagrant roleMediaWiki-Vagrant#Using roles wikispeech

IssuesPhabricator

Open tasks · Report a bug

The Wikispeech project aims to create an open source text-to-speech tool to make Wikimedia's projects more accessible for people that have difficulties reading for different reasons. Wikispeech will be available as a MediaWiki extension. More information can be found on the project page; this page is just about the Wikispeech extension itself. Stable release is planned for 2017.

User guide[edit]

See Help:Extension:Wikispeech.

Download[edit]

For the General User:

For the Advanced User:

Setting up Wikispeech[edit]

These are the instructions to install the TTS server on wmflabs.org.

Creating an instance[edit]

Follow instructions on https://wikitech.wikimedia.org/wiki/Help:Instances#Creating_an_instance:

  1. Log in to https://horizon.wikimedia.org and go to the wikispeech project (in top bar).
  2. ComputeOverview and check that there are instances available.
  3. Create a Security Group:
    • ComputeAccess & SecurityCreate Security Group; Name: TTS-provider
      • Manage RulesAdd Rule; Port: 10000, Remote: CIDR, CIDR: 0.0.0.0/0
  4. Open Launch Instance dialogue (ComputeInstancesLaunch Instance):
    1. Details: only set Instance Name: wikispeech-tts
    2. Source: Select boot source: Image, under Available: add ubuntu-14.04-trusty
    3. Flavor: Under Available: add m1.medium (marytts uses ~ 1.1 GB on local machine)
    4. Security Groups: Under Available: add default, TTS-provider, web-server
  5. Make services accessible through proxy, DNSWeb proxiesCreate proxy
    1. Hostname: wikispeech-tts, Backend instance: wikispeech-tts, Backend port: 10000
    2. Hostname: wikispeech-tts-audio, Backend Instance: wikispeech-tts, Backend port: 80

To ssh to the new instance, see: https://wikitech.wikimedia.org/wiki/Help:Getting_Started#Project_Instances

Install TTS server[edit]

The TTS server consists of three components: MaryTTS (TTS platform), pronlex (a pronunciation lexicon database) and wikispeech_mockup (wikispeech API).

Install MaryTTS[edit]

  1. Log into wikispeech-tts
  2. Install java: $ sudo apt install openjdk-8-jdk (Java 8 is needed for Arabic. If it can't be installed the normal way, see https://askubuntu.com/questions/464755/how-to-install-openjdk-8-on-14-04-lts/464894#464894 under, Original Message)
  3. Create a user to run the server: $ sudo useradd -m tts-agent -p <password>
  4. Become this user: $ sudo su - tts-agent
  5. Clone marytts-installer repo: $ git clone https://github.com/marytts/marytts-installer.git
  6. Follow instructions to install English voices
  7. To install Swedish and Arabic:
    1. $ cd marytts-installer/installed
    2. $ wget https://github.com/HaraldBerthelsen/marytts/releases/download/v5.9-alpha/marytts-lang-sv-6.0-SNAPSHOT.jar
    3. $ wget https://github.com/HaraldBerthelsen/marytts/releases/download/v5.9-alpha/voice-stts_sv_nst-hsmm-5.2.jar
    4. $ wget https://github.com/HaraldBerthelsen/marytts-lang-ar/releases/download/v0.1-alpha/marytts-lang-ar-6.0-SNAPSHOT.jar
    5. $ wget https://github.com/HaraldBerthelsen/voice-ar-nah-hsmm/releases/download/v5.2/voice-ar-nah-hsmm-5.2.jar

Install pronlex[edit]

Follow the instructions at https://github.com/stts-se/lexdata/wiki/Create-lexicon-database.

Install wikispeech_mockup[edit]

Following instruction at https://github.com/stts-se/wikispeech_mockup.

Install Mishkal (for Arabic)[edit]

  1. $ cd ~/marytts-installer/installed
  2. wget http://repo1.maven.org/maven2/org/glassfish/javax.json/1.0.4/javax.json-1.0.4.jar
  3. $ cd ~
  4. git clone https://github.com/linuxscout/mishkal.git
  5. $ cd mishkal
  6. In mishkal/tashkeel/tashkeel.py, change line 385 from:
    • vocalized_text = u" ".join([vocalized_text, self.display(word, format_display)])
    • to:
    • vocalized_text = u" ".join([vocalized_text, self.display(voc_word, format_display)])
  7. Run webserver with: $ python interfaces/web/mishkal-webserver.py

Make audio files accessible[edit]

  1. Install apache: $ sudo apt install apache2
  2. Link the audio file directory in /var/www/html: $ cd /var/www/html; sudo ln -s ~/wikispeech_mockup/wikispeech_mockup/tmp/ audio

Audio files generated by the TTS should now be accessible through: http://wikispeech-tts-audio.wmflabs.org/audio/.

  • Disallow access to non-opus files by adding a .htaccess-file in ~/wikispeech_mockup/wikispeech_mockup/tmp/ with the following content
<FilesMatch "\.*$">
  Deny from all
</FilesMatch>
<FilesMatch "\.opus$">
  Order deny,allow
  Allow from all
</FilesMatch>
  • Remove directory listing by adding a index.html file in ~/wikispeech_mockup/wikispeech_mockup/tmp/ with something like the following content:

This is a service to serve Wikispeech audio files. There is really never any reason to see this page.

  • To also display this page in the root directory (instead of apache default): $ cd /var/www/html/; sudo rm index.html; sudo ln -s audio/index.html

Update the server with the new path[edit]

In ~/wikispeech_mockup/wikispeech_mockup/wikispeech.py, in synthesise(), change:

audio_url = "%s/%s/%s" % (hostname,config.config.get("Audio settings","audio_url_prefix"),opus_audio)

to:

audio_url = "%s/%s/%s" % ("//wikispeech-tts-audio.wmflabs.org",config.config.get("Audio settings","audio_url_prefix"),opus_audio)

Start processes in screen[edit]

As user tts-agent:

  1. $ script /dev/null, needed to get screen running (http://serverfault.com/a/116830)
  2. Start MaryTTS
    1. $ cd ~/marytts-installer/
    2. $ ./marytts
  3. Create new window: Ctrl+a, w
  4. Start pronlex
    1. $ cd ~/go/src/github.com/stts-se/pronlex/lexserver/
    2. $ go run *.go
  5. Create new window
  6. Start wikispeech.py
    1. $ cd ~/wikispeech_mockup/
    2. $ python3 wikispeech.py

You can now detach the screen Ctrl+a, d and resume with $ screen -r. Note that $ script /dev/null is required to run screen each time you become tts-agent.

Basic configuration for MediaWiki-Wikispeech[edit]

Complete list of configuration options[edit]

Option Default value Documentation
WikispeechServerUrl
"https://morf.se/wikispeech/"
The URL for the TTS server to use.
WikispeechRemoveTags
{
    "editsection": true, 
    "toc": true, 
    "table": true, 
    "sup": {
        "class": "reference"
    }, 
    "div": {
        "class": "thumb"
    }, 
    "ul": true, 
    "ol": true
}
Map of HTML tags that should be removed completely, i.e. including any content. Keys are tag names and the values determine whether a tag should be removed, as follows:
  • If true, remove all tags of that type.
  • If an object (array in LocalSetting.php) containing the "class" key, only tags that also have the value of "class" as class will be removed.
  • If false, tags of that type will not be removed. This can be used in LocalSetting.php to override default criteria.
WikispeechNamespaces
[
    "NS_MAIN"
]
List of the namespaces, for which Wikispeech is activated, using constant names.
WikispeechKeyboardShortcuts
{
    "playStop": {
        "key": 32,
        "modifiers": [
            "alt",
            "shift"
        ]
    },
    "skipAheadSentence": {
        "key": 39,
        "modifiers": [
            "alt",
            "shift"
        ]
    },
    "skipBackSentence": {
        "key": 37,
        "modifiers": [
            "alt",
            "shift"
        ]
    },
    "skipAheadWord": {
        "key": 40,
        "modifiers": [
            "alt",
            "shift"
        ]
    },
    "skipBackWord": {
        "key": 38,
        "modifiers": [
            "alt",
            "shift"
        ]
    }
}
Shortcuts for Wikispeech commands. Each shortcut defines the key pressed (as key code[1]) and any modifier keys (ctrl, alt or shift).
WikispeechSkipBackRewindsThreshold
3.0
If an utterance has played longer than this (in seconds), skipping back will rewind to the start of the current utterance, instead of skipping to previous utterance.

CSS[edit]

Selector Default values Documentation
.ext-wikispeech-highlight-sentence
background-color: rgb(0, 200, 0);
background-color: rgba(0, 200, 0, 0.5)
The visual highlighting for the sentence that is currently being recited.

Setting Wikispeech up on shared hosting[edit]

See Extension:Wikispeech/Installation on a shared host

Troubleshooting[edit]

See also[edit]