Estimated reading time: 6 minutes

Language support in Mycroft - Portuguese - Português

NOTE: These instructions apply to Mycroft for Linux only; we don't currently have instructions for changing the language on Picroft, but changing the language in Picroft should work in a similar way - why not give it a try and let us know how you go?. If you'd like to help us out with that, jump into the ~languages channel on Mycroft Chat and let us know.

Olá, falas Português? Follow these steps to change Mycroft's language to Portuguese (BCP 47:pt).

If you speak Portuguese and wish to enable Portuguese language support for
Mycroft, this is possible. However, this requires some technical knowledge such as:

  • moving and copying files in a Linux shell
  • downloading and unzipping large files
  • editing configuration files

If you need further assistance, please join us in the Languages channel on Mycroft Chat.

Change the Wake Word to Portuguese

Mycroft uses PocketSphinx as the Wake Word engine. The default Wake Word in English is Hey Mycroft.

The Wake Word engine takes a language parameter. If you can spell your
Wake Word with english phonemes nothing special must be done.

You can find English phonemes for words with The CMU Pronouncing
Dictionary
. Try to pick english
sounds that spell your Portuguese word.

First, locate your mycroft.conf configuration file. On Mycroft for Linux,
the configuration files exists in several places and is loaded by this order

default, remote (mycroft.ai), system, user

More information about the mycroft.conf file

You should use remote settings, or edit the user configuration file located at:

~/.mycroft/mycroft.conf

    {
    // Hotword configurations
      "hotwords": {
        "hey jarbas": {
            "module": "pocketsphinx",
            "phonemes": "HH EY . JH AA R B AA SH ",
            "threshold": 1e-60,
            "lang": "en-us"
            },
        "hey mycroft": {
            "module": "pocketsphinx",
            "phonemes": "HH EY . M AY K R AO F T",
            "threshold": 1e-90,
            "lang": "en-us"
            }
        },

      "listener": {
        "wake_word": "hey jarbas",
        ...
        },
    }

If you want to use a Portuguese Wake Word with Portuguese phonemes we need to
download a Portuguese dictionary and a Portuguese acoustic model, trained with
the latest sphinxtrain. The following steps are optional, you only need
them if you want to use Portuguese phonemes.

Download and install Portuguese acoustic model

No official model currently exists, but you can get an acoustic model from
FalaBrasil

Download the acoustic model

@TODO downloads link, site is currently down

wget link -O file

Install language in Mycroft directories

Now that we have downloaded the PocketSphinx files for Portuguese, we need to install Portuguese in the Mycroft directories.

First, SSH into your device.

Navigate to the Mycroft language model directory.

For instance, on mycroft-core for Linux, navigate to

/mycroft-core/mycroft/client/speech/recognizer/model

You should see the following files in this directory:

$ ls -las
total 24
8 drwxrwxr-x 3 kathyreid kathyreid 4096 Nov 24 00:08 .
8 drwxrwxr-x 3 kathyreid kathyreid 4096 Nov 24 00:08 ..
8 drwxrwxr-x 3 kathyreid kathyreid 4096 Nov 24 00:08 en-us

NOTE: Note that there is only one model folder - en-us for American English

Create a new directory here for Portuguese, and then copy the downloaded files

@TODO bash usage example

Verify the installed files

Check that the following files exist:

  • /mycroft_core/mycroft/client/speech/recognizer/model/pt-br/hmm/feat.params
  • /mycroft_core/mycroft/client/speech/recognizer/model/pt-br/hmm/mdef
  • /mycroft_core/mycroft/client/speech/recognizer/model/pt-br/hmm/means
  • /mycroft_core/mycroft/client/speech/recognizer/model/pt-br/hmm/mixture_weights
  • /mycroft_core/mycroft/client/speech/recognizer/model/pt-br/hmm/noisedict
  • /mycroft_core/mycroft/client/speech/recognizer/model/pt-br/hmm/sendump
  • /mycroft_core/mycroft/client/speech/recognizer/model/pt-br/hmm/transition_matrices
  • /mycroft_core/mycroft/client/speech/recognizer/model/pt-br/hmm/variances

Choosing a Portuguese Wake Word

There is no tool to easily get the Portuguese phonemes for words. You could
choose a Wake Word in Portuguese, and then verify that it
is in the pt-br.dic file of the language model. This file is not needed for
Wake Word spotting, you can get it from [FalaBrasil]() @TODO link

If your chosen Wake Word or phrase is not in the pt-br.dict file, you
can try looking for similar words and pick the phonemes manually.

Configure Mycroft to use Portuguese language and the chosen Wake Word

You should use remote settings or edit the user configuration file located at

~/.mycroft/mycroft.conf

Edit the configuration file and add the new portuguese wake word:

    {
    // Hotword configurations
      "hotwords": {
        "oi jarbas": {
            "module": "pocketsphinx",
            "phonemes": "o ii . zm a rm b a s",
            "threshold": 1e-60,
            "lang": "pt-br"
            },
        "hey mycroft": {
            "module": "pocketsphinx",
            "phonemes": "HH EY . M AY K R AO F T",
            "threshold": 1e-90,
            "lang": "en-us"
            }
        },

      "listener": {
        "wake_word": "oi jarbas",
        ...
        },
    }

Select and configure a Speech to Text (STT) engine with Portuguese support

If the Speech to Text engine you are using already supports Portuguese, you
don't need to do anything.

The standard Mycroft STT should support most languages by default.

Select and configure a Text to Speech (TTS) engine with Portuguese support

Next, select and configure a Text to Speech engine that supports Portuguese.

To configure your TTS engine, you should use remote settings or edit the user
configuration file located at

~/.mycroft/mycroft.conf

Espeak should support most languages

    "tts": {
      "module": "espeak",
      "espeak": {
        "lang": "pt",
        "voice": "m1"
      }
    }

Translating core dialog

The default Mycroft dialog files may need translation. For Portuguese this is already implemented.

You can find these files at

mycroft_root_dir/res/txt/pt-pt

You may need to copy the pt-pt folder into a pt-br folder

Check that the following files exist:

  • /mycroft_core/mycroft/res/text/pt-br/checking for updates.dialog
  • /mycroft_core/mycroft/res/text/pt-br/i am awake.dialog
  • /mycroft_core/mycroft/res/text/pt-br/i didn't catch that.dialog
  • /mycroft_core/mycroft/res/text/pt-br/checking for updates.dialog
  • /mycroft_core/mycroft/res/text/pt-br/not connected to the internet.dialog
  • /mycroft_core/mycroft/res/text/pt-br/reset to factory defaults.dialog
  • /mycroft_core/mycroft/res/text/pt-br/skills updated.dialog
  • /mycroft_core/mycroft/res/text/pt-br/sorry i couldn't install default skills.dialog
  • /mycroft_core/mycroft/res/text/pt-br/ssh disabled.dialog
  • /mycroft_core/mycroft/res/text/pt-br/ssh enabled.dialog

Configure Mycroft to use Portuguese

Finally, to change Mycroft to Portuguese, you should use remote settings or edit
the user configuration file located at

~/.mycroft/mycroft.conf

    lang": "pt-br",

Language Parsing

There a few pieces of code needed to fully support a new language. These
include extracting numbers from text, sentence normalization and date time
extraction.

For Portuguese these have already been implemented and you do not need to worry about it.

Translating Skills

Language support is implemented individually per Skill.

The Skills have a folder structure like this:

    dialog/en-us/speak.dialog
    vocab/en-us/sentence.intent
    vocab/en-us/word.entity
    vocab/en-us/keyword.voc
    regex/en-us/regex.rx

Will need to create a new language folder, pt-br in the dialog, vocab and regex directories, then translate all the files for the Skill to work in Portugues. Once you do this, please ensure you submit a PR in the Skill Repo on GitHub, so that the Skill author can merge the PR - and everyone benefits from your work.

_NOTE: once you change a Skill folder you will no longer get automatic updates of that Skill

Other things to consider with language translation in Mycroft

Some Skills may generate speech at runtime. Language support for these Skills is non-trivial and will require editing of code in Python.

Some Skills expect English input, like WolframAlpha. These Skills will not work correctly with other languages.

Some Skills use number and date-time processing, such as the Reminder and Alarm Skills. These Skills will not work correctly unless language parsing code has been implemented for the language.

Some Skills, like the News Skill, play audio streams in English. You will need to find alternative audio streams in your language.

You can also try to use auto_translatable skills. This is community contributed by community member @JarbasAI, and not officially supported by Mycroft.

Getting involved

If you would like to get involved with foreign language translations for Mycroft, we'd love to hear from you. Please join us in the Languages channel on Mycroft chat


Help us serve you better by rating this documentation