Skip to content

Instantly share code, notes, and snippets.

@pchw
Created July 12, 2014 03:45
Show Gist options
  • Save pchw/a63b462e7481b84ca0c3 to your computer and use it in GitHub Desktop.
Save pchw/a63b462e7481b84ca0c3 to your computer and use it in GitHub Desktop.
コマンドライン引数の文字列をvoicetext web apiで喋らせる
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