Created
July 12, 2014 03:45
-
-
Save pchw/a63b462e7481b84ca0c3 to your computer and use it in GitHub Desktop.
コマンドライン引数の文字列をvoicetext web apiで喋らせる
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'coffee-script/register' | |
fs = require 'fs' | |
stream = require 'stream' | |
Speaker = require 'speaker' | |
VoiceText = require '../src/lib/voicetext' | |
voice = new VoiceText('<your api key>') | |
text = process.argv[2] or 'きょうも いちにち がんばるぞい' | |
voice | |
.speaker(voice.SPEAKER.SHOW) | |
.emotion(voice.EMOTION.HAPPINESS) | |
.emotion_level(voice.EMOTION_LEVEL.HIGH) | |
.pitch(100) | |
.speed(100) | |
.volume(200) | |
.speak text, (e, buf)-> | |
return console.error e if e | |
speaker = new Speaker | |
channels: 1 | |
bitDepth: 16 | |
sampleRate: 16000 | |
bufferStream = new stream.Transform | |
bufferStream.pipe speaker | |
bufferStream.push buf | |
do bufferStream.end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment