Skip to content
Text-to-Speech module for MagicMirror with Google Cloud TTS API.
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore first Feb 26, 2019
LICENSE Initial commit Feb 26, 2019
MMM-GoogleTTS.js first Feb 26, 2019 Update Feb 26, 2019
api_count.json.temp Update api_count.json.temp Feb 26, 2019
node_helper.js fix:api_count Feb 27, 2019
package.json first Feb 26, 2019


Text-to-Speech module for MagicMirror with Google Cloud TTS API.


This module works on Background, so there is no screenshot.


This module gives "voice" to MagicMirror

  • speech by notification order
  • hooking other notification data to speak. (e.g: SHOW_ALERT)
  • speech by MMM-TelegramBot command /tts
  • welcomeMessage
  • preventing over-used API quota by daily limitation.


cd ~/MagicMirror/modules
git clone
cd MMM-GoogleTTS
npm install
cp api_count.json.temp api_count.json

Getting Google Credential

  1. Select or create a Cloud Platform project.

  2. Enable billing for your project.

    • Pricing Information
    • Enable billing
    • By default 4 Millions(for standard voice, 1 Million for WaveNet voice) characters could be used per month.
    • Usually 4 Millions characters seems enough to be used for normal usage per month.
    • You can limit daily usage by configuration if you don't want to pay for this service.
  3. Enable the Google Cloud Text-to-Speech API.

  4. Set up authentication with a service account so you can access the API from your device.

    1. In the GCP Console, go to the Create service account key page.
    2. From the Service account drop-down list, select New service account.
    3. In the Service account name field, enter a name(whatever)
    4. Don't select a value from the Role drop-down list. No role is required to access this service.
    5. Click Create. A note appears, warning that this service account has no role.
    6. Click Create without role. A JSON file that contains your key downloads to your device.
  5. Rename downloaded file to credentials.json and copy it to MMM-GoogleTTS directory



  module: "MMM-GoogleTTS", // no `position` is needed.
  config: {}

Details and Defaults

  module: "MMM-GoogleTTS", // no `position` is needed.
  config: {
    welcome: ["May the force be with you", "Live long and prosper"],
    // String or Array of String or callback function to return String or Array. To disable this feature, set to null.
    /* Other example
    welcome: null,
    welcome: "Hello",
    welcome: ()=> {
      var d = Math.floor((Math.random() * 10) + 1)
      return "Today's Lucky number is" + d

    dailyCharLimit: 129000,
    // 4 Million divide by 30. I think it's enough for daily usage. If you have a will to pay, you can expand this value as your wish. But free usage will be enough.
    // Warning. When you use WaveNet voice, your free quota will be `1 Million per month` not `4 Million`.

    sourceType: "text",
    // "text" or "ssml".

    voiceName: "en-US-Standard-C",
    //If exists. e.g)"en-US-Standard-C". You can select specific voice name when there are many voices with same languageCode and gender.
    // voiceName should be matched with languageCode and ssmlGender

    languageCode: "en-US",
    ssmlGender: "FEMALE",
    // supported voices, languages and gender;

    playCommand: "aplay %OUTPUTFILE%",
    // aplay, mpg321, afplay, as your wish....
    // sometimes you should give more options to play correctly.
    // e.g) "aplay -D plughw:1,0 $OUTPUTFILE%"

    audioEncoding: "LINEAR16",
    // LINEAR16 (.wav) or MP3 (.mp3) for playCommand. You don't need to modify this when you use `aplay`

    notificationTrigger: {
      "TEST_TTS" : "Test TTS notification is coming",
      "SHOW_ALERT" : (payload, sender) => {
        return payload.message
    // You can hook specific notification to speak something. String or callback function could be available.

    // You don't need to modify belows;
    notifications: {
      TTS_SAY: "TTS_SAY",
    credentialPath: "credentials.json",


By Notification

notification hooking

You can hook specific notification to speak something with that notification. By example;

notificationTrigger: {
  "TEST_TTS" : "Test TTS notification is coming",
  "SHOW_ALERT" : (payload, sender) => {
    return payload.message
  • When TEST_TTS notification is received, "Test TTS notification is coming" will be spoken.
  • When SHOW_ALERT notification is received, payload.message will be spoken. You can make Mirror to read ALERT by its voice.

notification command

With TTS_SAY notification, Other module can order this module to speak

this.sendNotification("TTS_SAY", "May the Force be with you")


this.sendNotification("TTS_SAY", {
  content: "Live long and prosper", //text to be spoken
  //belows are optional
  type: "text", // "text" or "ssml"
  voiceName: "en-US-Standard-B",
  languageCode: "en-US",
  ssmlGender: "FEMALE",
  callback: (error)=> {
    console.log("Message is spoken.")

By MMM-TelegramBot

  • /tts something or /alert something
  • By Example : /tts Mom, I'm Tom, coming home now. I'm so hungry


  • Google Text-To-Speech SDK is limited free. 4 Millions characters could be used per month without charge. I think it’s quiet enough for usual usage. You can limit daily usage by force with configuration to avoid charging. (But it’s your responsibility)

  • If you are using another module or program which use speaker, use this carefully. Occupation collision could happen.

You can’t perform that action at this time.