Package Exports
- kaia.js
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 (kaia.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Kaia.js
Kaia.ai platform's JS client library
We have not yet launched the platform. For launch announcement please follow us on Facebook.
Live Demos
- Browse sample apps for live demos, source code
Installation
Kaia.ai robot apps run on Android smartphones. To run sample apps:
- Go to kaia.ai, familiarize yourself with how the robot platform works
- Optional, but highly recommended: if you don't have Kaia.ai account, create an account
- Go to Google Play, search for "kaia.ai" to find and install Kaia.ai Android app
- Launch Kaia.ai Android app on your Android smartphone
- In Kaia.ai Android app: (optional, but highly recommended): sign in, navigate to Kaia.ai App Store
- Choose a robot app to launch
- Optionally: click the heart icon to pin the robot app to your launch screen
API Overview
TfMobile
- Sample app
- Sample app source code
- Sample app source code, built with node.js and webpack
let tfMobile = await createTfMobile(model); // load model
let result = await tfMobile.run([img], { // classify image
feed: [{width: size, height: size, inputName: 'input', imageMean: 128.0, imageStd: 128.0,
feedType: 'colorBitmapAsFloat'}],
run: {enableStats: false},
fetch: {outputNames: ['MobilenetV1/Predictions/Softmax'], outputTypes: ['float']}
});
let probabilities = result.output[0];
TfLite
- Sample app
- Sample app source code
- Sample app source code, built with node.js and webpack
let tfLite = await createTfLite(model); // load model
let result = await tfLite.run([img], { // classify image
input: [{width: size, height: size, channels: 4, batchSize: 1, imageMean: 128.0, imageStd: 128.0,
type: 'colorBitmapAsFloat'}],
output:[{type: 'float', size: [1, 1001]}]
});
let probabilities = result.output[0][0];
Configuration options passed to run():
// Input parameters
type: 'colorBitmapAsFloat', // input data type colorBitmapAsFloat|float|int|double|long|byte|colorBitmapAsByte
width: inputWidth, // input layer width
height: inputHeight, // input layer height
channels: inputChannels, // input layer channels
batchSize: inputBatchSize, // input layer batch size
imageMean: imageMean, // input image mean, 0...255, default 128
imageStd: imageStd, // input image standard deviation, default 128
// Output parameters
type: 'float', // output data type float|int|double|long|byte
size: [1, 1001], // output data size
// Miscellaneous options
useNNAPI: false, // use Android NN API, default false
numThreads: 0 // number of threads to use, default 0
TextToSpeech
- Sample App
- Sample app source code
textToSpeech = await createTextToSpeech();
await textToSpeech.speak('Hello');
Serial
- Sample App
- Sample app source code
serial = await createSerial({ baudRate: 115200, eventListener: onSerialEvent });
serial.write('Hello Arduino!\n')
function onSerialEvent(err, data) {
if (!err && data.event === 'received')
console.log(data.message);
}
Installing
Via npm + webpack/rollup
npm install kaia.js
Now you can require/import kaia.js
:
import { createTfMobile, createTfLite, createTextToSpeech, createAndroidMultiDetect, createPocketSphinx
createAndroidSpeechRecognition, createDeviceSettings, createSerial, createSensors} from 'kaia.js';
Via <script>
dist/kaia.mjs
is a valid JS module.dist/kaia-iife.js
can be used in browsers that don't support modules.kaiaJs
is created as a global.dist/kaia-iife.min.js
As above, but minified.dist/kaia-iife-compat.min.js
As above, but works in older browsers such as IE 10.dist/kaia-amd.js
is an AMD module.dist/kaia-amd.min.js
As above, but minified.
These built versions are also available on jsDelivr, e.g.:
<script src="https://cdn.jsdelivr.net/npm/kaia.js/dist/kaia-iife.min.js"></script>
<!-- Or in modern browsers: -->
<script type="module">
import { createTfMobile, createTfLite, createTextToSpeech } from 'https://cdn.jsdelivr.net/npm/kaia.js';
</script>
and unpkg
<script src="https://unpkg.com/kaia.js/dist/kaia-iife.min.js"></script>
<!-- Or in modern browsers: -->
<script type="module">
import { createTfMobile, createTfLite, createTextToSpeech } from 'https://unpkg.com/kaia.js';
</script>
Customizing NN Model
- To make a custom TfMobile model please follow a detailed Google Codelabs TFMobile tutorial
- To make a custom TfLite model please follow a detailed Google Codelabs TFLite tutorial
Deprecations
- Expect TextToSpeech to be eventually deprecated in favor of Web text-to-speech API.
- Expect Serial API to be eventually deprecated in favor of WebUSB