Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Commit cbd76ba

Browse files
committed
feat(asr): add Spokestack ASR
1 parent 0215ad6 commit cbd76ba

26 files changed

+7167
-868
lines changed

.eslintignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

.prettierignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
dist/**
2-
docs/**
3-
examples/**
1+
dist
2+
docs
3+
.next

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ This package is a work in progress.
1010
$ npm install spokestack --save
1111
```
1212

13-
## Requirements
13+
## Setup
1414

15-
1. Go to [spokestack.io](https://spokestack.io) and create an account. Create a token at [spokestack.io/account/settings#api](https://spokestack.io/account/settings#api). Note that you'll only be able to see the token secret once. If you accidentally leave the page, create another token. Once you have a token, set the following environment variables in your `.bash_profile` or `.zshenv`:
15+
Go to [spokestack.io](https://spokestack.io) and create an account. Create a token at [spokestack.io/account/settings#api](https://spokestack.io/account/settings#api). Note that you'll only be able to see the token secret once. If you accidentally leave the page, create another token. Once you have a token, set the following environment variables in your `.bash_profile` or `.zshenv`:
1616

1717
```bash
1818
export SS_API_URL=https://api.spokestack.io
1919
export SS_API_CLIENT_ID=#"Identity" field from Spokestack API token
2020
export SS_API_CLIENT_SECRET=#"Secret key" field from Spokestack API token
2121
```
2222

23-
2. [Set up Google Cloud Speech](https://github.com/googleapis/nodejs-speech#before-you-begin). Ensure `GOOGLE_APPLICATION_CREDENTIALS` is set in your environment.
23+
## Using Google ASR instead of Spokestack ASR
24+
25+
If you'd prefer to use Google ASR, follow these [instructions for setting up Google Cloud Speech](https://github.com/googleapis/nodejs-speech#before-you-begin). Ensure `GOOGLE_APPLICATION_CREDENTIALS` is set in your environment.
2426

2527
---
2628

client.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './dist/client'

client.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./dist/client')

examples/with-next/.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/with-next/README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# with-next
22

3-
This example is built on [next.js](https://github.com/zeit/next.js).
3+
This example is built on [Next.js](https://github.com/zeit/next.js).
44

55
It is a proof-of-concept using [Spokestack](../../) to demonstrate
66
searching a database with voice using ASR and reading off the first result with text-to-speech.
77

88
## Usage
99

10+
See `server/index.ts` for example code using [Next.js][next] and [Express][express].
11+
1012
```bash
1113
$ git clone [email protected]:spokestack/node-spokestack.git
1214
$ cd node-spokestack/examples/with-next
@@ -17,3 +19,18 @@ $ npm run dev
1719
Then visit http://localhost:3000 in your browser.
1820

1921
Visit http://localhost:3000/\_\_graphiql to view introspection docs on the Spokestack GraphQL API for synthesizing text to speech.
22+
23+
### Run example using Google ASR instead of Spokestack ASR
24+
25+
This command will run the server and use [Google Cloud Speech][google] instead of [Spokestack ASR][spokestack]
26+
27+
```bash
28+
$ ASR_SERVICE=google npm run dev
29+
```
30+
31+
Then visit http://localhost:3000 in your browser.
32+
33+
[next]: https://github.com/zeit/next.js
34+
[express]: https://expressjs.com/
35+
[google]: https://cloud.google.com/speech-to-text/
36+
[spokestack]: https://www.spokestack.io/docs/concepts/asr

examples/with-next/babel.config.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
const path = require('path')
2-
const pak = require('../../package.json')
3-
41
module.exports = {
52
presets: ['next/babel'],
6-
plugins: [
7-
'transform-optional-chaining',
8-
[
9-
'module-resolver',
10-
{
11-
alias: {
12-
[pak.name]: path.join(__dirname, '..', '..', pak.source)
13-
}
14-
}
15-
]
16-
]
3+
plugins: ['transform-optional-chaining']
174
}

examples/with-next/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const withTM = require('next-transpile-modules')(['graphiql', 'spokestack'])
1+
const withTM = require('next-transpile-modules')(['graphiql'])
22

33
module.exports = withTM()

examples/with-next/nodemon.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"watch": ["server"],
2+
"watch": ["server", "../../src"],
33
"exec": "ts-node --project tsconfig.server.json server/index.ts",
44
"ext": "js ts"
55
}

0 commit comments

Comments
 (0)