├── test.js ├── README.md ├── index.js └── package.json /test.js: -------------------------------------------------------------------------------- 1 | var pico = require('./') 2 | 3 | pico.say('Hey this is a test', 'en-US', function() { 4 | console.log('Cool') 5 | }) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PicoTTS for Node 2 | ============ 3 | 4 | PicoTTS wrapper for NodeJS. PicoTTS is being used by Android and it's extremely lightweight and fast yet produces very natural voices. 5 | 6 | ## Usage 7 | 8 | ```javascript 9 | 10 | var pico = require('picotts') 11 | 12 | pico.say('Hey this is cool', 'en-US', function(err) { 13 | if (!err) 14 | console.log('Correctly played') 15 | }) 16 | 17 | ``` 18 | 19 | ## Install 20 | 21 | You need libttspico-utils to use the library 22 | 23 | ``` 24 | npm install picotts 25 | ``` 26 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'), 2 | exec = require('child_process').exec 3 | 4 | var commandTmpl = 'pico2wave -l "{{lang}}" -w {{file}} "{{text}}" && aplay {{file}}' 5 | 6 | function getTmpFile() { 7 | var random = Math.random().toString(36).slice(2), 8 | path = '/tmp/' + random + '.wav' 9 | 10 | return (!fs.existsSync(path)) ? path : getTmpFile() 11 | } 12 | 13 | function say(text, lang, cb) { 14 | var file = getTmpFile(), 15 | command = commandTmpl.replace('{{lang}}', lang).replace('{{text}}', text).replace(/\{\{file\}\}/g, file) 16 | exec(command, function(err) { 17 | cb && cb(err) 18 | fs.unlink(file) 19 | }) 20 | } 21 | 22 | module.exports = exports = {say: say} 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "picotts", 3 | "version": "0.1.1", 4 | "description": "PicoTTS wrapper. PicoTTS is being used by Android and it's extremely lightweight and fast yet produces very natural voices.", 5 | "homepage": "https://github.com/luisivan/node-picotts", 6 | "author": { 7 | "name": "Luis Iván Cuende", 8 | "email": "me@luisivan.net" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/luisivan/node-picotts.git" 13 | }, 14 | "licenses": [ 15 | { 16 | "type": "GPL-3.0+", 17 | "url": "http://www.gnu.org/licenses/gpl.txt" 18 | } 19 | ], 20 | "engines": { 21 | "node": ">=0.4.2" 22 | }, 23 | "keywords": [ 24 | "picotts", 25 | "tts", 26 | "text to speech", 27 | "pico" 28 | ] 29 | } 30 | --------------------------------------------------------------------------------