Socket
Socket
Sign inDemoInstall

api-ai-speech-context

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    api-ai-speech-context

Generates a Google Cloud Speech API SpeechContext for an API.AI agent.


Version published
Weekly downloads
45
increased by7.14%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

API.AI Speech Context

Generates a Google Cloud Speech API SpeechContext for your API.AI agent.

Usage

generateSpeechContext takes two parameters:

  • summary: An API.AI agent summary object with the keys name, entities, and intents.
  • blacklist: An array of words to blacklist from the context.

The summary can be created with api-ai-agent-downloader.

It returns an array containing words and phrases based on your agent's entities and intents. Non-blacklisted single words are given highest priority, then phrases that contain at least one non-blacklisted word. Entities within intent templates (e.g. '@sys.any') are removed.

The array comports with the Google Cloud Speech API's SpeechContext usage limits.

Example

const agentDownloader = require('api-ai-agent-downloader');
const { generateSpeechContext } = require('api-ai-speech-context');
const fs = require('fs');

const agentName = 'agent_foo';
const developerToken = 'abc123';

const blacklist = ['bad', 'words', 'and phrases'];
const removeCommonWords = true;  // true by default

agentDownloader.getSummary(agentName, developerToken)
    .then(summary => {
      const context = generateSpeechContext(summary, blacklist, removeCommonWords);
      fs.writeFileSync('./speechContext.json', JSON.stringify(context));
    })
    .catch(error => console.error(error));

FAQs

Last updated on 13 Feb 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc