Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

voc-cli

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

voc-cli - npm Package Compare versions

Comparing version 1.3.2 to 1.4.0

src/voicerss.js

2

index.js

@@ -61,2 +61,3 @@ #!/usr/bin/env node --harmony

.option('-i, --ispeech', "force download audio from ispeech")
.option('-v, --voicerss', "force download audio from voicerss")
.option('-a, --audio <cli>', "the command line to play .mp3 audio. set defaults to 'afplay'", setAudioCli)

@@ -87,2 +88,3 @@ .option('-d, --dir <path>', "set the download directory. set defaults to '~/vocabulary'", setAudioDirectory)

if (program.ispeech) service = 'ispeech';
if (program.voicerss) service = 'voicerss';

@@ -89,0 +91,0 @@ var audios = [];

2

package.json
{
"name": "voc-cli",
"version": "1.3.2",
"version": "1.4.0",
"description": "download and play English vocabularies' audio by command line",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -16,3 +16,9 @@ # voc

- [iSpeech](http://www.ispeech.org/)
- [Voice RSS](http://www.voicerss.org/)
## Support Node.js version
* `node.js` >= 0.12.0
* `io.js` >= 1.0.0
## Installation

@@ -37,2 +43,3 @@

-i, --ispeech force download audio from ispeech
-v, --voicerss force download audio from voicerss
-a, --audio <cli> the command line to play .mp3 audio. set defaults to 'afplay'

@@ -47,6 +54,6 @@ -d, --dir <path> set the download directory. set defaults to '~/vocabulary'

```bash
$ voc hello # download hello.mp3
$ voc hello world # download both hello.mp3, world.mp3
$ voc hello_world -g # download sentence hello_world.mp3 from google service
$ voc hello_world -i # download sentence hello_world.mp3 from ispeech service
$ voc hello # download hello.mp3
$ voc hello world # download both hello.mp3, world.mp3
$ voc hello_world -g # download hello_world.mp3 from google service
$ voc "Hello World" -i # download hello_world.mp3 from ispeech service
```

@@ -53,0 +60,0 @@

@@ -30,2 +30,8 @@ var fs = require('fs');

ext: '.mp3'
},
voicerss: {
type: 'tts',
getUrl: require('./voicerss'),
ext: '.mp3'
}

@@ -32,0 +38,0 @@ };

@@ -18,3 +18,3 @@ var UrlFormat = require('url').format;

voice: 'usenglishmale',
speed: -4,
speed: 0,
text: word

@@ -21,0 +21,0 @@ }

@@ -26,7 +26,21 @@ var util = require('util');

var $ = cheerio.load(html);
var data = $('#iconStyle.tri').text();
var map = {};
var list = [];
try {
return JSON.parse(data).sound_url_1[0].mp3;
var data = $('#iconStyle.tri').text();
JSON.parse(data).sound_url_1.forEach(function (item) {
var audio = item.mp3;
if (typeof audio !== 'string' || map.hasOwnProperty(audio) === true) {
return;
}
map[audio] = true;
list.push(audio);
});
} catch (e) {
// JSON parse failed
}
if (list.length === 0) {
var err = new Error(word + ' is not found from yahoo');

@@ -36,3 +50,14 @@ err.code = 'ENOENT';

}
// show all the audio url
if (list.length > 1) {
list.forEach(function (audio, i) {
i++;
console.log(i + '. ' + audio);
});
}
// return the first audio from list
return list[0];
});
}

@@ -85,2 +85,18 @@ var fs = require('fs');

it('perfect (from voicerss)', function () {
this.timeout(10000);
var word = 'perfect';
return expect(getAudio(word, __dirname, 'voicerss')).to.eventually.equal(
path.resolve(__dirname, 'perfect.mp3')
);
});
it('today_is_sunday (from voicerss)', function () {
this.timeout(10000);
var word = 'today_is_sunday';
return expect(getAudio(word, __dirname, 'voicerss')).to.eventually.equal(
path.resolve(__dirname, 'today_is_sunday.mp3')
);
});
it('askdjalksjdl', function () {

@@ -87,0 +103,0 @@ this.timeout(10000);

@@ -14,3 +14,3 @@ var chai = require('chai');

return expect(ispeech(word)).to.eventually.equal(
'http://api.ispeech.org/api/rest?format=mp3&action=convert&apikey=59e482ac28dd52db23a22aff4ac1d31e&voice=usenglishmale&speed=-4&text=hello'
'http://api.ispeech.org/api/rest?format=mp3&action=convert&apikey=59e482ac28dd52db23a22aff4ac1d31e&voice=usenglishmale&speed=0&text=hello'
);

@@ -22,3 +22,3 @@ });

return expect(ispeech(word)).to.eventually.equal(
'http://api.ispeech.org/api/rest?format=mp3&action=convert&apikey=59e482ac28dd52db23a22aff4ac1d31e&voice=usenglishmale&speed=-4&text=hello'
'http://api.ispeech.org/api/rest?format=mp3&action=convert&apikey=59e482ac28dd52db23a22aff4ac1d31e&voice=usenglishmale&speed=0&text=hello'
);

@@ -30,3 +30,3 @@ });

return expect(ispeech(word)).to.eventually.equal(
'http://api.ispeech.org/api/rest?format=mp3&action=convert&apikey=59e482ac28dd52db23a22aff4ac1d31e&voice=usenglishmale&speed=-4&text=hello%20world'
'http://api.ispeech.org/api/rest?format=mp3&action=convert&apikey=59e482ac28dd52db23a22aff4ac1d31e&voice=usenglishmale&speed=0&text=hello%20world'
);

@@ -38,3 +38,3 @@ });

return expect(ispeech(word)).to.eventually.equal(
'http://api.ispeech.org/api/rest?format=mp3&action=convert&apikey=59e482ac28dd52db23a22aff4ac1d31e&voice=usenglishmale&speed=-4&text=hello%20world'
'http://api.ispeech.org/api/rest?format=mp3&action=convert&apikey=59e482ac28dd52db23a22aff4ac1d31e&voice=usenglishmale&speed=0&text=hello%20world'
);

@@ -46,3 +46,3 @@ });

return expect(ispeech(word)).to.eventually.equal(
'http://api.ispeech.org/api/rest?format=mp3&action=convert&apikey=59e482ac28dd52db23a22aff4ac1d31e&voice=usenglishmale&speed=-4&text=how%20are%20you'
'http://api.ispeech.org/api/rest?format=mp3&action=convert&apikey=59e482ac28dd52db23a22aff4ac1d31e&voice=usenglishmale&speed=0&text=how%20are%20you'
);

@@ -54,3 +54,3 @@ });

return expect(ispeech(word)).to.eventually.equal(
'http://api.ispeech.org/api/rest?format=mp3&action=convert&apikey=59e482ac28dd52db23a22aff4ac1d31e&voice=usenglishmale&speed=-4&text=123'
'http://api.ispeech.org/api/rest?format=mp3&action=convert&apikey=59e482ac28dd52db23a22aff4ac1d31e&voice=usenglishmale&speed=0&text=123'
);

@@ -57,0 +57,0 @@ });

@@ -25,2 +25,9 @@ var chai = require('chai');

it('cactus', function () {
var word = 'cactus';
return expect(yahoo(word)).to.eventually.equal(
'https://s.yimg.com/tn/dict/dreye/live/m/cactus.mp3'
);
});
it('askdjalksjdl', function () {

@@ -27,0 +34,0 @@ var word = 'askdjalksjdl';

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc