npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

speechkit-js

v0.0.1

Published

JavaScript client for interacting with the SpeechKit API

Downloads

20

Readme

speechkit-js Build Status

JavaScript client for interacting with the SpeechKit API.

Install

$ yarn add speechkit-js

Usage

const Speechkit = require('speechkit-js')

const speechkit = new Speechkit(<token>)

await speechkit.getVoices()

API

Kind: global class

new Speechkit(token)

token

Type: string Description: Your SpeechKit token Required

.getVoices()

Returns a promise

Get all voices available from speechkit

const speechkit = new Speechkit(<token>)

await speechkit.getVoices()
/*
[
  {
    "id": 1,
    "language": "en_AU",
    "name": "Nicole"
  },
  {
    "id": 2,
    "language": "en_AU",
    "name": "Russel"
  },
  ...
]
*/

.getNewsSites()

Returns a promise

Get all news sites that belong to your publisher

const speechkit = new Speechkit(<token>)

await speechkit.getNewsSites()
/*
[
  {
    "id": 28,
    "title": "Bloomberg",
    "external_id": "bloomberg"
  },
  {
    "id": 29,
    "title": "The Guardian",
    "external_id": "the-guardian"
  },
  {
    "id": 30,
    "title": "Der Tagesspiegel",
    "external_id": "der-tagesspiegel"
  },
  ...
]
*/

.createNewsSites({ title })

Returns a promise

title

Type: string Description: Title of the new site Required

Create sites to your publisher

const speechkit = new Speechkit(<token>)

await speechkit.createNewsSites({ title: 'My Site'})
/*
{
  "id": 1,
  "title": "My Site",
  "external_id": "my-site"
}
*/

.getArticles(newsSiteId, { page })

Returns a promise

newsSiteId

Type: string Description: The id of your site you want to fetch all articles for. This can also be your news_sites external id Required

page

Type: integer Description: Since this is a paginated response you can set the page to get more articles.

Get all articles for a news site

const speechkit = new Speechkit(<token>)

await speechkit.getArticles(1, { page: 1 })
/*
[
  {
    "id": "1",
    "url": "https://www.bloomberg.com/news/articles/2016-09-09/google-s-ai-brainiacs-achieve-speech-generation-breakthrough",
    "title": "Google’s DeepMind Achieves Speech-Generation Breakthrough",
    "author": "Jeremy Khan",
    "summary": "",
    "image": "",
    "published_at": "2016-09-09T13:03:00.000Z",
    "body": "Google’s DeepMind Achieves Speech-Generation Breakthrough.....",
    "state": "processed",
    "media": [
      {
        "id": 25726,
        "role": "body",
        "content_type": "application/x-mpegURL",
        "url": "https://d22tbkdovk5ea2.cloudfront.net/audio/news_sites/28/articles/12860/roles/body/voices/37/ab6faf941b7f604a77a60c5ebcacda82.m3u8",
        "created_at": "2017-04-25T13:05:15.536Z",
        "state": "processed"
      },
      {
        "id": 25725,
        "role": "body",
        "content_type": "audio/mpeg",
        "url": "https://d22tbkdovk5ea2.cloudfront.net/audio/news_sites/28/articles/12860/roles/body/voices/37/c9d36a0c25e84d98c5a40f4a6ca510ca.mp3",
        "created_at": "2017-04-25T13:05:06.450Z",
        "state": "processed"
      }
    ]
  }
]
*/

.getArticle(newsSiteId, articleId)

Returns a promise

newsSiteId

Type: string Description: The id of your site you want to fetch all articles for. This can also be your news_sites external id Required

articleId

Type: string Description: The id of the article you want to request.

Get a specific article

const speechkit = new Speechkit(<token>)

await speechkit.getArticle(1, 1)
/*
{
  "id": "1",
  "url": "https://www.bloomberg.com/news/articles/2016-09-09/google-s-ai-brainiacs-achieve-speech-generation-breakthrough",
  "title": "Google’s DeepMind Achieves Speech-Generation Breakthrough",
  "author": "Jeremy Khan",
  "summary": "",
  "image": "",
  "published_at": "2016-09-09T13:03:00.000Z",
  "body": "Google’s DeepMind Achieves Speech-Generation Breakthrough.....",
  "state": "processed",
  "media": [
    {
      "id": 25726,
      "role": "body",
      "content_type": "application/x-mpegURL",
      "url": "https://d22tbkdovk5ea2.cloudfront.net/audio/news_sites/28/articles/12860/roles/body/voices/37/ab6faf941b7f604a77a60c5ebcacda82.m3u8",
      "created_at": "2017-04-25T13:05:15.536Z",
      "state": "processed"
    },
    {
      "id": 25725,
      "role": "body",
      "content_type": "audio/mpeg",
      "url": "https://d22tbkdovk5ea2.cloudfront.net/audio/news_sites/28/articles/12860/roles/body/voices/37/c9d36a0c25e84d98c5a40f4a6ca510ca.mp3",
      "created_at": "2017-04-25T13:05:06.450Z",
      "state": "processed"
    }
  ]
}
*/

.createArticle(newsSiteId, [data])

Returns a promise

newsSiteId

Type: string Description: The id of your site you want to fetch all articles for. This can also be your news_sites external id Required

data

Type: object Description: Object containing data to create article

external_id

Type: string Description: The id you want to identify this article as. Needs to be unique

title

Type: string Description: The title of the article

published_at

Type: string Description: When this article was originally published

author

Type: string Description: The name of the author for this article

summary

Type: string Description: The summary of the article

body

Type: string Description: The complete body of the article

media_attributes

Type: string Description: This is an array containing all media files you want produced. Array should contain role (string) and/or voice_id (integer).

Create an article for your site. Every time you create an article we build the audio for you.

const speechkit = new Speechkit(<token>)

const body = {
  external_id: 1,
  title: 'The title of my article',
  published_at: '2017-02-03',
  author: 'John Doe',
  summary: 'My summary of the article',
  body: 'This is the body of the article',
  media_attributes: [
    {
      role: 'body',
      voice_id: 1
    }
  ]
}

await speechkit.createArticle(1, body)
/*
{
  "id": "1141123123",
  "url": null,
  "title": "The title of my article",
  "author": "John Doe",
  "summary": "My summary of the article",
  "image": null,
  "published_at": "2017-02-03T00:00:00.000Z",
  "body": "This is the body of the article",
  "state": "unprocessed",
  "media": [
    {
      "id": 208,
      "role": "summary",
      "content_type": "",
      "url": null,
      "created_at": "2017-04-26T11:48:29.069Z",
      "state": "unprocessed",
      "voice": {
        "id": 1,
        "language": "en_GB",
        "name": "en-GB_KateVoice"
      }
    },
    {
      "id": 209,
      "role": "body",
      "content_type": "",
      "url": null,
      "created_at": "2017-04-26T11:48:29.071Z",
      "state": "unprocessed",
      "voice": {
        "id": 1,
        "language": "en_GB",
        "name": "en-GB_KateVoice"
      }
    }
  ]
}
*/

Related

  • speechkit — AI-read audio for your news posts
  • speechkit-state — Check if the state of SpeechKit article has been processed

License

MIT © Bu Kinoshita