Package Exports
- @speechly/browser-client
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@speechly/browser-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
speechly-browser-client
This repository contains source code for the browser client for Speechly SLU API. Speechly allows you to easily build applications with voice-enabled UIs.
Usage
Install the package:
# Using Yarn
yarn add @speechly/browser-client
# Using NPM
npm install --save @speechly/browser-clientStart using the client:
import { Client, Segment } from '@speechly/browser-client'
// Create a new Client. appId and language are configured in the dashboard.
const client = new Client({
appId: 'your-app-id',
language: 'en-US'
})
// Initialize the client - this will ask the user for microphone permissions and establish the connection to Speechly API.
// Make sure you call `initlialize` from a user action handler (e.g. from a button press handler).
client.initialize((err?: Error) => {
if (err !== undefined) {
console.error('Failed to initialize Speechly client:', err)
}
})
// React to the phrases received from the API
client.onSegmentChange((segment: Segment) => {
console.log('Received new segment from the API:', segment.intent, segment.entities, segment.words, segment.isFinal)
})
// Start recording
client.startContext((err?: Error) => {
if (err !== undefined) {
console.error('Failed to start recording:', err)
return
}
// Stop recording after 3 seconds
setTimeout(client.stopContext, 3000)
})Check out the browser-client-example repository for a demo app built using this client.
Documentation
You can find the detailed API documentation in GitHub repository.
Contributing
See contribution guide in CONTRIBUTING.md.
