4.0.5 • Published 7 years ago

sugo-module-say v4.0.5

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
7 years ago

sugo-module-say

Build Status npm Version JS Standard

Say command module for SUGOS. (Supports only OSX)

Requirements

This modules uses say command of OSX, thus you need a mac.

Installation

$ npm install sugo-module-say --save

Usage

Register module to SUGO-Actor

#!/usr/bin/env node

/**
 * Example usage to register module on actor
 * @see https://github.com/realglobe-Inc/sugo-actor
 */
'use strict'

const sugoModuleSay = require('sugo-module-say')
const sugoActor = require('sugo-actor')
const co = require('co')

co(function * () {
  let actor = sugoActor('http://my-sugo-cloud.example.com/actors', {
    key: 'my-actor-01',
    modules: {
      // Register the module
      say: sugoModuleSay({})
    }
  })
  yield actor.connect()
}).catch((err) => console.error(err))

Then, call the module from remote caller.

#!/usr/bin/env node

/**
 * Example to call from caller
 * @see https://github.com/realglobe-Inc/sugo-caller
 */
'use strict'

const co = require('co')
const assert = require('assert')
const sugoCaller = require('sugo-caller')

co(function * () {
  let caller = sugoCaller('http://my-sugo-cloud.example.com/callers', {})
  let actor = caller.connect('my-actor-01')

  // Access to the module
  let say = actor.say()

  // Send ping
  let pong = yield say.ping()
  assert.ok(pong)

  // List available voices
  let voices = yield say.voices()
  console.log(voices)

  // Speech text
  say.say('Hi, there', { voice: voices[ 0 ] })

}).catch((err) => console.error(err))

Methods

The following methods are available from remote callers for the module.

.voices() -> array

List available voices

.say(text, options)

Say texts

ParamTypeDescription
textstringText to say
optionsObjectOptional settings

.ping(pong) -> string

Test the reachability of a module.

ParamTypeDescription
pongstringPong message to return

.assert() -> boolean

Test if the actor fulfills system requirements

License

This software is released under the Apache-2.0 License.

Links