mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-28 11:43:00 +00:00
Initial snowboy commit
This commit is contained in:
parent
f20324243d
commit
98e28fa9b0
20
types/snowboy/index.d.ts
vendored
Normal file
20
types/snowboy/index.d.ts
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Type definitions for snowboy 1.2
|
||||
// Project: https://github.com/Kitt-AI/snowboy
|
||||
// Definitions by: Dolan Miu <https://github.com/dolanmiu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { Stream } from "stream";
|
||||
|
||||
export type State = "sound" | "silence" | "hotword" | "error";
|
||||
|
||||
export class Detector extends Stream {
|
||||
constructor(params: any);
|
||||
|
||||
on(event: State | symbol, callback: (index: any, hotword?: any, buffer?: Buffer) => void): this;
|
||||
}
|
||||
|
||||
export class Models {
|
||||
add(params: any): void;
|
||||
}
|
||||
40
types/snowboy/snowboy-tests.ts
Normal file
40
types/snowboy/snowboy-tests.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { Detector, Models } from "snowboy";
|
||||
import * as fs from "fs";
|
||||
|
||||
const models = new Models();
|
||||
|
||||
models.add({
|
||||
file: 'resources/snowboy.umdl',
|
||||
sensitivity: '0.5',
|
||||
hotwords: 'snowboy'
|
||||
});
|
||||
|
||||
const detector = new Detector({
|
||||
resource: "resources/common.res",
|
||||
models,
|
||||
audioGain: 1.0
|
||||
});
|
||||
|
||||
detector.on('silence', () => {
|
||||
console.log('silence');
|
||||
});
|
||||
|
||||
detector.on('sound', (buffer) => {
|
||||
// <buffer> contains the last chunk of the audio that triggers the "sound"
|
||||
// event. It could be written to a wav stream.
|
||||
console.log('sound');
|
||||
});
|
||||
|
||||
detector.on('error', () => {
|
||||
console.log('error');
|
||||
});
|
||||
|
||||
detector.on('hotword', (index, hotword, buffer) => {
|
||||
// <buffer> contains the last chunk of the audio that triggers the "hotword"
|
||||
// event. It could be written to a wav stream. You will have to use it
|
||||
// together with the <buffer> in the "sound" event if you want to get audio
|
||||
// data after the hotword.
|
||||
console.log('hotword', index, hotword);
|
||||
});
|
||||
|
||||
const file = fs.createReadStream('resources/snowboy.wav');
|
||||
22
types/snowboy/tsconfig.json
Normal file
22
types/snowboy/tsconfig.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"snowboy-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/snowboy/tslint.json
Normal file
1
types/snowboy/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user