├── .gitignore
├── LICENSE
├── README.md
├── package.json
└── ttsmp3
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # Compiled binary addons (http://nodejs.org/api/addons.html)
20 | build/Release
21 |
22 | # Dependency directory
23 | # Commenting this out is preferred by some people, see
24 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
25 | node_modules
26 |
27 | # Users Environment Variables
28 | .lock-wscript
29 |
30 | # mp3 files
31 | *.mp3
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | ttsmp3 is a node.js script used to download text-to-speech mp3 files.
2 | Copyright (C) 2015 Aaron Landis
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ttsmp3
2 | A node.js script used to download text-to-speech mp3 files.
3 | Install with `sudo npm install ttsmp3 -g`.
4 |
5 | ```
6 | Usage: ttsmp3 [-o ] [-l ] [-g ]
7 | [-v | --version] [-h | --help]
8 |
9 | text: input text
10 | outfile: output mp3 file
11 | lang: accent variable
12 | gender: "fm" or "ml" for female or male
13 | ```
14 |
15 | Props to [`vozme.com`](http://vozme.com) for providing the free service.
16 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ttsmp3",
3 | "version": "1.0.1",
4 | "description": "A node.js script used to download text-to-speech mp3 files.",
5 | "main": "ttsmp3",
6 | "dependencies": {
7 | "needle": "^0.7.10",
8 | "yargs": "^1.3.3"
9 | },
10 | "scripts": {
11 | "test": "./ttsmp3 \"test command\""
12 | },
13 | "bin": "./ttsmp3",
14 | "repository": {
15 | "type": "git",
16 | "url": "https://github.com/5paceManSpiff/ttsmp3"
17 | },
18 | "keywords": [
19 | "text",
20 | "to",
21 | "speech",
22 | "tts",
23 | "text-to-speech",
24 | "mp3",
25 | "audio"
26 | ],
27 | "author": "Aaron Landis",
28 | "license": "GPL",
29 | "bugs": {
30 | "url": "https://github.com/5paceManSpiff/ttsmp3/issues"
31 | },
32 | "homepage": "https://github.com/5paceManSpiff/ttsmp3"
33 | }
34 |
--------------------------------------------------------------------------------
/ttsmp3:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var main = function () {
4 | var needle = require('needle');
5 | var argv = require('yargs')
6 | .alias('o', 'outfile').default('o', 'text.mp3')
7 | .alias('l', 'lang').default('l', 'en')
8 | .alias('g', 'gender').default('g', 'fm')
9 | .alias('h', 'help')
10 | .alias('v', 'version')
11 | .argv;
12 |
13 | var usage = 'Usage: ttsmp3 [-o ] [-l ] [-g ]\n' +
14 | ' [-v | --version] [-h | --help]\n' +
15 | '\n' +
16 | ' text: input text\n' +
17 | ' outfile: output mp3 file\n' +
18 | ' lang: accent variable\n' +
19 | ' gender: "fm" or "ml" for female or male';
20 |
21 | if (argv.v) {
22 | var path = require('path');
23 | var pkg = require(path.join(__dirname, 'package.json'));
24 | console.log(pkg.name + ' is at version ' + pkg.version);
25 | return true;
26 | }
27 |
28 | if (argv.h) {
29 | var path = require('path');
30 | var pkg = require(path.join(__dirname, 'package.json'));
31 | console.log(pkg.name + ': ' + pkg.description + '\n');
32 | console.log(usage);
33 | return true;
34 | }
35 |
36 | if (argv._.length != 1) {
37 | if (argv._.length == 0) {
38 | console.log('Error: could not find variable');
39 | }
40 | if (argv._.length > 1) {
41 | console.log('Error: too many variables');
42 | }
43 |
44 | console.log(usage);
45 | return false;
46 | }
47 |
48 | var base = 'http://vozme.com/';
49 | var opts = {
50 | text : argv._[0],
51 | lang : argv.l,
52 | gn : argv.g,
53 | interface : 'full'
54 | };
55 |
56 | needle.post(base + 'text2voice.php', opts, {}, function(err, resp) {
57 | if (err) {
58 | console.log('Error: couldn\'t get download link');
59 | }
60 |
61 | var url = base + resp.body.split('