项目作者: BenjaminPoncet

项目描述 :
bobby-snips-tts is an implementation of snips-tts written in Node.js with Cloud TTS support
高级语言: JavaScript
项目地址: git://github.com/BenjaminPoncet/bobby-snips-tts.git
创建时间: 2019-02-19T13:05:07Z
项目社区:https://github.com/BenjaminPoncet/bobby-snips-tts

开源协议:MIT License

下载


bobby-snips-tts

bobby-snips-tts is an implementation of snips-tts written in Node.js. Why? Because Node.js is life!

It’s a part of Bobby Assistant Project but it’s designed to run in standalone. So, feel free to fork, use and modify it.

This implementation can use Google Text-To-Speech (and maybe more in the future) as replacement of pico2wave for more natural speak.

Because Google TTS (and much more TTS) are Online TTS, pico2wave is used has offline or timeout failover.

Dependencies

Get Google Text-To-Speech API Key

  1. Select or create a Cloud Platform project.

    Go to the projects page

  2. Enable billing for your project.

    Enable billing

  3. Enable the Google Cloud Text-to-Speech API.

    Enable the API

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

This guide is an exact of Official Google Text-To-Speech Project. See more on googleapis/nodejs-text-to-speech

Install LAME

LAME is used for converting MP3 buffer from Google TTS API to WAV buffer on the fly because Snips Audio Server play only WAV buffer.

bobby-snips-tts can work without LAME by asking WAV buffer directly from Google TTS API but WAVs are about 10 times bigger than MP3s so slower on network.

With apt-get LAME can be simply install by running

  1. apt-get install lame

See more on LAME Website

Install bobby-snips-tts

First, you need Node.js and Git.

Go in your favorite Node.js project directory (for me /home/pi) and run

  1. git clone https://github.com/BenjaminPoncet/bobby-snips-tts.git

Move to bobby-snips-tts directory and run

  1. npm install

Copy your JSON GOOGLE APPLICATION CREDENTIALS in bobby-snips-tts directory and rename it google-credentials.json

Voice configuration

See top of index.js:

  1. // Default Lang
  2. // Available Snips language: en, fr, it, es, de, ja, ko
  3. var defaultLang = "fr";
  4. // pico2wave Voice Config
  5. // Available Voices: en-US, en-GB, de-DE, es-ES, fr-FR, it-IT
  6. var voicePico = [];
  7. voicePico['en'] = "en-GB";
  8. voicePico['fr'] = "fr-FR";
  9. voicePico['it'] = "it-IT";
  10. voicePico['es'] = "es-ES";
  11. voicePico['de'] = "de-DE";
  12. voicePico['ja'] = "en-US";
  13. voicePico['ko'] = "en-US";
  14. // Google Voice Config
  15. // Available Voices: node listVoices.js
  16. var voiceGoogle = [];
  17. voiceGoogle['en'] = {voiceName: "en-US-Standard-B", voiceType: "MALE"};
  18. voiceGoogle['fr'] = {voiceName: "fr-CA-Standard-D", voiceType: "MALE"};
  19. voiceGoogle['it'] = {voiceName: "it-IT-Standard-A", voiceType: "FEMALE"};
  20. voiceGoogle['es'] = {voiceName: "es-ES-Standard-A", voiceType: "FEMALE"};
  21. voiceGoogle['de'] = {voiceName: "de-DE-Standard-B", voiceType: "MALE"};
  22. voiceGoogle['ja'] = {voiceName: "ja-JP-Standard-A", voiceType: "FEMALE"};
  23. voiceGoogle['ko'] = {voiceName: "ko-KR-Standard-C", voiceType: "MALE"};
  24. // Timeout before offline Speak for Cloud TTS call (in ms)
  25. var timeoutCloudTTS = 2500;

Manual run (for testing)

Stop snips-tts by running

  1. systemctl stop snips-tts

Move to bobby-snips-tts directory and run

  1. node index.js

Run as a service

Edit bobby-snips-tts.service and change the path of index.js if need (default is /home/pi/bobby-snips-tts/index.js)

Move bobby-snips-tts.service in /etc/systemd/system/ directory.

Stop and disable snips-tts by running

  1. systemctl stop snips-tts
  2. systemctl disable snips-tts

Enable and start bobby-snips-tts by running

  1. systemctl --system daemon-reload
  2. systemctl enable bobby-snips-tts
  3. systemctl start bobby-snips-tts

Todo

TODO

Credits

Snips Voice Platform

KiboOst/SNIPS-Tips and snipsco/awesome-snips for inspiration