# speechkit-js

> JavaScript client for interacting with the SpeechKit API

Latest version **0.0.1** (published 2017-10-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install speechkit-js
pnpm add speechkit-js
yarn add speechkit-js
bun add speechkit-js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2017-10-05 |
| First published | 2017-10-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Bu Kinoshita |
| Maintainers | bukinoshita |
| Keywords | speechkit, api, wrapper, AI, artificial, intelligence, audio, read |

## Links

- npm: https://www.npmjs.com/package/speechkit-js
- Repository: https://github.com/bukinoshita/speechkit-js
- Homepage: https://github.com/bukinoshita/speechkit-js#readme
- Issues: https://github.com/bukinoshita/speechkit-js/issues
- npm.io page: https://npm.io/package/speechkit-js

## Dependencies (2)

- [request](https://npm.io/package/request.md) ^2.83.0
- [request-promise-native](https://npm.io/package/request-promise-native.md) ^1.0.5

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2017-10-05

## README

# speechkit-js [![Build Status](https://travis-ci.org/bukinoshita/speechkit-js.svg?branch=master)](https://travis-ci.org/bukinoshita/speechkit-js)

> JavaScript client for interacting with the [SpeechKit API](https://docs.speechkit.io).


## Install

```bash
$ yarn add speechkit-js
```


## Usage

```js
const Speechkit = require('speechkit-js')

const speechkit = new Speechkit(<token>)

await speechkit.getVoices()
```


## API

**Kind**: global class  

* [Speechkit](#Speechkit)
  * [new Speechkit(token)](#new_Speechkit_new)
  * [.getVoices()](#Speechkit+getVoices) ⇒ <code>Promise</code>
  * [.getNewsSites()](#Speechkit+getNewsSites) ⇒ <code>Promise</code>
  * [.createNewsSites({ title })](#Speechkit+createNewsSites) ⇒ <code>Promise</code>
  * [.getArticles(newsSiteId, { page })](#Speechkit+getArticles) ⇒ <code>Promise</code>
  * [.getArticle(newsSiteId, articleId)](#Speechkit+getArticle) ⇒ <code>Promise</code>
  * [.createArticle(newsSiteId, [data])](#Speechkit+createArticle) ⇒ <code>Promise</code>


<a name="new_Speechkit_new"></a>

### new Speechkit(token)

#### token

Type: `string`<br/>
Description: Your [SpeechKit](https://speechkit.io/) token<br/>
Required


<a name="Speechkit+getVoices"></a>

### .getVoices()

Returns a `promise`

Get all voices available from speechkit

```js
const speechkit = new Speechkit(<token>)

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


<a name="Speechkit+getNewsSites"></a>

### .getNewsSites()

Returns a `promise`

Get all news sites that belong to your publisher

```js
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"
  },
  ...
]
*/
```


<a name="Speechkit+createNewsSites"></a>

### .createNewsSites({ title })

Returns a `promise`

#### title

Type: `string`<br/>
Description: Title of the new site<br/>
Required

Create sites to your publisher
```js
const speechkit = new Speechkit(<token>)

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


<a name="Speechkit+getArticles"></a>

### .getArticles(newsSiteId, { page })

Returns a `promise`

#### newsSiteId

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

#### page

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

Get all articles for a news site

```js
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"
      }
    ]
  }
]
*/
```


<a name="Speechkit+getArticle"></a>

### .getArticle(newsSiteId, articleId)

Returns a `promise`

#### newsSiteId

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

#### articleId

Type: `string`<br/>
Description:  The id of the article you want to request.

Get a specific article

```js
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"
    }
  ]
}
*/
```


<a name="Speechkit+createArticle"></a>

### .createArticle(newsSiteId, [data])

Returns a `promise`

#### newsSiteId

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

#### data

Type: `object`<br/>
Description:  Object containing data to create article

##### external_id

Type: `string`<br/>
Description: The id you want to identify this article as. Needs to be unique

##### title

Type: `string`<br/>
Description: The title of the article

##### published_at

Type: `string`<br/>
Description: When this article was originally published

##### author

Type: `string`<br/>
Description: The name of the author for this article

##### summary

Type: `string`<br/>
Description: The summary of the article

##### body

Type: `string`<br/>
Description: The complete body of the article

##### media_attributes

Type: `string`<br/>
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.

```js
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](https://github.com/bukinoshita/speechkit) — AI-read audio for your news posts
- [speechkit-state](https://github.com/bukinoshita/speechkit) — Check if the state of SpeechKit article has been processed


## License

MIT © [Bu Kinoshita](https://bukinoshita.io)

---
_Source: https://npm.io/package/speechkit-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
