@sam17896/ngx-speech-recognition
Version:
Angular 5+ speech recognition service (based on browser implementation such as Chrome).
1,122 lines (1,114 loc) • 70.3 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('rxjs/operators'), require('@angular/core'), require('@angular/common')) :
typeof define === 'function' && define.amd ? define('@sam17896/ngx-speech-recognition', ['exports', 'rxjs', 'rxjs/operators', '@angular/core', '@angular/common'], factory) :
(factory((global.sam17896 = global.sam17896 || {}, global.sam17896['ngx-speech-recognition'] = {}),global.rxjs,global.rxjs.operators,global.ng.core,global.ng.common));
}(this, (function (exports,rxjs,operators,core,common) { 'use strict';
/**
* @fileoverview added by tsickle
* Generated from: lib/polifill.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
if (window['webkitSpeechRecognition']) {
window['SpeechRecognition'] = window['webkitSpeechRecognition'];
}
if (window['webkitSpeechGrammarList']) {
window['SpeechGrammarList'] = window['webkitSpeechGrammarList'];
}
/**
* @fileoverview added by tsickle
* Generated from: lib/service/speech-recognition.token.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var SpeechRecognitionGrammars = new core.InjectionToken('speech-recognition.grammars');
/** @type {?} */
var SpeechRecognitionLang = new core.InjectionToken('speech-recognition.lang');
/** @type {?} */
var SpeechRecognitionContinuous = new core.InjectionToken('speech-recognition.continuous');
/** @type {?} */
var SpeechRecognitionInterimResults = new core.InjectionToken('speech-recognition.interimResults');
/** @type {?} */
var SpeechRecognitionMaxAlternatives = new core.InjectionToken('speech-recognition.maxAlternatives');
/** @type {?} */
var SpeechRecognitionServiceUri = new core.InjectionToken('speech-recognition.serviceURI');
/** @type {?} */
var SpeechRecognitionAudiostartHandler = new core.InjectionToken('speech-recognition.onaudiostart');
/** @type {?} */
var SpeechRecognitionSoundstartHandler = new core.InjectionToken('speech-recognition.onsoundstart');
/** @type {?} */
var SpeechRecognitionSpeechstartHandler = new core.InjectionToken('speech-recognition.onspeechstart');
/** @type {?} */
var SpeechRecognitionSpeechendHandler = new core.InjectionToken('speech-recognition.onspeechend');
/** @type {?} */
var SpeechRecognitionSoundendHandler = new core.InjectionToken('speech-recognition.onsoundend');
/** @type {?} */
var SpeechRecognitionAudioendHandler = new core.InjectionToken('speech-recognition.onaudioend');
/** @type {?} */
var SpeechRecognitionResultHandler = new core.InjectionToken('speech-recognition.onresult');
/** @type {?} */
var SpeechRecognitionNomatchHandler = new core.InjectionToken('speech-recognition.onnomatch');
/** @type {?} */
var SpeechRecognitionErrorHandler = new core.InjectionToken('speech-recognition.onerror');
/** @type {?} */
var SpeechRecognitionStartHandler = new core.InjectionToken('speech-recognition.onstart');
/** @type {?} */
var SpeechRecognitionEndHandler = new core.InjectionToken('speech-recognition.onend');
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m)
return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
ar.push(r.value);
}
catch (error) {
e = { error: error };
}
finally {
try {
if (r && !r.done && (m = i["return"]))
m.call(i);
}
finally {
if (e)
throw e.error;
}
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/service/speech-recognition.common.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SpeechRecognitionCommon = /** @class */ (function () {
function SpeechRecognitionCommon(_grammars, _lang, _continuous, _interimResults, _maxAlternatives, _serviceURI) {
this._grammars = _grammars;
this._lang = _lang;
this._continuous = _continuous;
this._interimResults = _interimResults;
this._maxAlternatives = _maxAlternatives;
this._serviceURI = _serviceURI;
this.internal = new SpeechRecognition();
}
Object.defineProperty(SpeechRecognitionCommon.prototype, "grammars", {
/**
* Property
*/
// The grammars property of the SpeechRecognition interface returns and sets
// a collection of SpeechGrammar objects
// that represent the grammars that will be understood
// by the current SpeechRecognition.
//
// SpeechRecognitionインターフェイスのgrammarsプロパティは、
// 現在のSpeechRecognitionで認識される文法を表す
// SpeechGrammarオブジェクトのコレクションを返して設定します。
get: /**
* Property
* @return {?}
*/
// The grammars property of the SpeechRecognition interface returns and sets
// a collection of SpeechGrammar objects
// that represent the grammars that will be understood
// by the current SpeechRecognition.
//
// SpeechRecognitionインターフェイスのgrammarsプロパティは、
// 現在のSpeechRecognitionで認識される文法を表す
// SpeechGrammarオブジェクトのコレクションを返して設定します。
function () {
return this._grammars;
},
set: /**
* @param {?} grammars
* @return {?}
*/ function (grammars) {
this._grammars = grammars;
if (this._grammars !== undefined && this._grammars != null && this.internal) {
this.internal.grammars = this._grammars;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionCommon.prototype, "lang", {
// The lang property of the SpeechRecognition interface returns
// and sets the language of the current SpeechRecognition.
// If not specified, this defaults to the HTML lang attribute value,
// or the user agent's language setting if that isn't set either.
//
// SpeechRecognitionインターフェイスのlangプロパティは、
// 現在のSpeechRecognitionの言語を返して設定します。
// 指定されていない場合、これはデフォルトでHTMLのlang属性の値、
// またはユーザエージェントの言語設定が設定されていない場合は
// その値になります。
get:
// The lang property of the SpeechRecognition interface returns
// and sets the language of the current SpeechRecognition.
// If not specified, this defaults to the HTML lang attribute value,
// or the user agent's language setting if that isn't set either.
//
// SpeechRecognitionインターフェイスのlangプロパティは、
// 現在のSpeechRecognitionの言語を返して設定します。
// 指定されていない場合、これはデフォルトでHTMLのlang属性の値、
// またはユーザエージェントの言語設定が設定されていない場合は
// その値になります。
/**
* @return {?}
*/
function () {
return this._lang;
},
set: /**
* @param {?} lang
* @return {?}
*/ function (lang) {
this._lang = lang;
if (this._lang !== undefined && this._lang != null && this.internal) {
this.internal.lang = this._lang;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionCommon.prototype, "continuous", {
// The continuous property of the SpeechRecognition interface controls
// whether continuous results are returned for each recognition, or only a single result.
//
// SpeechRecognitionインターフェイスの連続プロパティは、
// 認識結果ごとに連続した結果を返すか、単一の結果のみを返すかを制御します。
get:
// The continuous property of the SpeechRecognition interface controls
// whether continuous results are returned for each recognition, or only a single result.
//
// SpeechRecognitionインターフェイスの連続プロパティは、
// 認識結果ごとに連続した結果を返すか、単一の結果のみを返すかを制御します。
/**
* @return {?}
*/
function () {
return this._continuous;
},
set: /**
* @param {?} continuous
* @return {?}
*/ function (continuous) {
this._continuous = continuous;
if (this._continuous !== undefined && this._continuous != null && this.internal) {
this.internal.continuous = this._continuous;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionCommon.prototype, "interimResults", {
// The interimResults property of the SpeechRecognition interface controls
// whether interim results should be returned (true)
// or not (false.) Interim results are results that are not yet final
// (e.g. the SpeechRecognitionResult.isFinal property is false.)
//
// SpeechRecognitionインターフェイスのinterimResultsプロパティは、
// 中間結果を返すかどうか(true)、そうでないか(false)を制御します。
// 中間結果は、最終段階ではない結果です(SpeechRecognitionResult.isFinalプロパティはfalseです)。
get:
// The interimResults property of the SpeechRecognition interface controls
// whether interim results should be returned (true)
// or not (false.) Interim results are results that are not yet final
// (e.g. the SpeechRecognitionResult.isFinal property is false.)
//
// SpeechRecognitionインターフェイスのinterimResultsプロパティは、
// 中間結果を返すかどうか(true)、そうでないか(false)を制御します。
// 中間結果は、最終段階ではない結果です(SpeechRecognitionResult.isFinalプロパティはfalseです)。
/**
* @return {?}
*/
function () {
return this._interimResults;
},
set: /**
* @param {?} interimResults
* @return {?}
*/ function (interimResults) {
this._interimResults = interimResults;
if (this._interimResults !== undefined && this._interimResults != null && this.internal) {
this.internal.interimResults = this._interimResults;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionCommon.prototype, "maxAlternatives", {
// The maxAlternatives property of the SpeechRecognition interface sets
// the maximum number of SpeechRecognitionAlternatives
// provided per SpeechRecognitionResult.
//
// SpeechRecognitionインターフェイスのmaxAlternativesプロパティは、
// SpeechRecognitionResultごとに提供される
// SpeechRecognitionAlternativesの最大数を設定します。
get:
// The maxAlternatives property of the SpeechRecognition interface sets
// the maximum number of SpeechRecognitionAlternatives
// provided per SpeechRecognitionResult.
//
// SpeechRecognitionインターフェイスのmaxAlternativesプロパティは、
// SpeechRecognitionResultごとに提供される
// SpeechRecognitionAlternativesの最大数を設定します。
/**
* @return {?}
*/
function () {
return this._maxAlternatives;
},
set: /**
* @param {?} maxAlternatives
* @return {?}
*/ function (maxAlternatives) {
this._maxAlternatives = maxAlternatives;
if (this._maxAlternatives !== undefined && this._maxAlternatives != null && this.internal) {
this.internal.maxAlternatives = this._maxAlternatives;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionCommon.prototype, "serviceURI", {
// The serviceURI property of the SpeechRecognition interface specifies
// the location of the speech recognition service
// used by the current SpeechRecognition to handle
// the actual recognition. The default is the user agent's
// default speech service.
//
// SpeechRecognitionインターフェイスのserviceURIプロパティは、
// 現在のSpeechRecognitionが実際の認識を処理するために使用する
// 音声認識サービスの場所を指定します。
// デフォルトはユーザエージェントのデフォルト音声サービスです。
get:
// The serviceURI property of the SpeechRecognition interface specifies
// the location of the speech recognition service
// used by the current SpeechRecognition to handle
// the actual recognition. The default is the user agent's
// default speech service.
//
// SpeechRecognitionインターフェイスのserviceURIプロパティは、
// 現在のSpeechRecognitionが実際の認識を処理するために使用する
// 音声認識サービスの場所を指定します。
// デフォルトはユーザエージェントのデフォルト音声サービスです。
/**
* @return {?}
*/
function () {
return this._serviceURI;
},
set: /**
* @param {?} serviceURI
* @return {?}
*/ function (serviceURI) {
this._serviceURI = serviceURI;
if (this._serviceURI !== undefined && this._serviceURI != null && this.internal) {
this.internal.serviceURI = this._serviceURI;
}
},
enumerable: true,
configurable: true
});
return SpeechRecognitionCommon;
}());
/**
* @fileoverview added by tsickle
* Generated from: lib/service/rx-speech-recognition.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var onType = ( /**
* @param {?} type
* @return {?}
*/function (type) {
return operators.filter(( /**
* @param {?} e
* @return {?}
*/function (e) { return (e.type === type); }));
});
/** @type {?} */
var resultList = rxjs.pipe(onType('result'), operators.map(( /**
* @param {?} e
* @return {?}
*/function (e) { return e.results; })));
var RxSpeechRecognitionService = /** @class */ (function (_super) {
__extends(RxSpeechRecognitionService, _super);
function RxSpeechRecognitionService(ref, grammars, lang, continuous, interimResults, maxAlternatives, serviceURI) {
var _this = _super.call(this, grammars, lang, continuous, interimResults, maxAlternatives, serviceURI) || this;
_this.ref = ref;
_this.proxy$ = new rxjs.Subject();
_this._started$ = new rxjs.BehaviorSubject(false);
_this.initInternal();
return _this;
}
Object.defineProperty(RxSpeechRecognitionService.prototype, "$", {
get: /**
* @return {?}
*/ function () {
return ( /** @type {?} */(this.proxy$));
},
enumerable: true,
configurable: true
});
Object.defineProperty(RxSpeechRecognitionService.prototype, "started$", {
get: /**
* @return {?}
*/ function () {
return ( /** @type {?} */(this._started$));
},
enumerable: true,
configurable: true
});
/**
* @private
* @return {?}
*/
RxSpeechRecognitionService.prototype.initInternal = /**
* @private
* @return {?}
*/
function () {
var _this = this;
// set handlers
/** @type {?} */
var handler = ( /**
* @param {?} e
* @return {?}
*/function (e) {
_this.proxy$.next(e);
_this.ref.tick();
});
/** @type {?} */
var errHandler = ( /**
* @param {?} e
* @return {?}
*/function (e) {
_this.proxy$.error(e);
_this.ref.tick();
});
this.internal.onaudiostart = handler;
this.internal.onsoundstart = handler;
this.internal.onspeechstart = handler;
this.internal.onspeechend = handler;
this.internal.onsoundend = handler;
this.internal.onaudioend = handler;
this.internal.onresult = handler;
this.internal.onnomatch = handler;
this.internal.onerror = errHandler;
this.internal.onstart = handler;
this.internal.onend = handler;
// see setter methods
this.grammars = this._grammars;
this.lang = this._lang;
this.continuous = this._continuous;
this.interimResults = this._interimResults;
this.maxAlternatives = this._maxAlternatives;
this.serviceURI = this._serviceURI;
this.proxy$.subscribe(( /**
* @param {?} e
* @return {?}
*/function (e) {
switch (e.type) {
case 'start':
_this._started$.next(true);
break;
case 'end':
_this._started$.next(false);
break;
}
}));
};
// The listen() method aims to recognize the grammar associated with the current SpeechRecognition,
// Observable is returned for handling voice recognition service listening to incoming voice.
// When you subscrive the return value, listening begins and listening ends when an end event occurs.
// Interrupt listening by unsubscribing in the middle.
//
// listen() メソッドは、現在のSpeechRecognitionに
// 関連付けられた文法を認識することを目的として、
// 着信音声を聴取する音声認識サービスを扱うためのObservableが返されます。
// 返り値をsubscriveすると聴取が開始され、endのイベントが発生すると聴取を終了します。
// 途中でunsbscriveすることで聴取を中断します。
// The listen() method aims to recognize the grammar associated with the current SpeechRecognition,
// Observable is returned for handling voice recognition service listening to incoming voice.
// When you subscrive the return value, listening begins and listening ends when an end event occurs.
// Interrupt listening by unsubscribing in the middle.
//
// listen() メソッドは、現在のSpeechRecognitionに
// 関連付けられた文法を認識することを目的として、
// 着信音声を聴取する音声認識サービスを扱うためのObservableが返されます。
// 返り値をsubscriveすると聴取が開始され、endのイベントが発生すると聴取を終了します。
// 途中でunsbscriveすることで聴取を中断します。
/**
* @return {?}
*/
RxSpeechRecognitionService.prototype.listen =
// The listen() method aims to recognize the grammar associated with the current SpeechRecognition,
// Observable is returned for handling voice recognition service listening to incoming voice.
// When you subscrive the return value, listening begins and listening ends when an end event occurs.
// Interrupt listening by unsubscribing in the middle.
//
// listen() メソッドは、現在のSpeechRecognitionに
// 関連付けられた文法を認識することを目的として、
// 着信音声を聴取する音声認識サービスを扱うためのObservableが返されます。
// 返り値をsubscriveすると聴取が開始され、endのイベントが発生すると聴取を終了します。
// 途中でunsbscriveすることで聴取を中断します。
/**
* @return {?}
*/
function () {
var _this = this;
/** @type {?} */
var listener = new rxjs.Observable(( /**
* @param {?} ovserver
* @return {?}
*/function (ovserver) {
// create subscriotion
/** @type {?} */
var subscriotion = _this.proxy$.subscribe({
next: ( /**
* @param {?} e
* @return {?}
*/function (e) {
ovserver.next(e);
if (e.type && e.type === 'end') {
_this.internal.stop();
ovserver.complete();
subscriotion.unsubscribe();
}
}),
error: ( /**
* @param {?} e
* @return {?}
*/function (e) { return ovserver.error(e); }),
});
// Speech Recognition start
_this.internal.start();
return ( /**
* @return {?}
*/function () {
_this.internal.abort();
subscriotion.unsubscribe();
});
}));
return listener;
};
RxSpeechRecognitionService.decorators = [
{ type: core.Injectable }
];
/** @nocollapse */
RxSpeechRecognitionService.ctorParameters = function () {
return [
{ type: core.ApplicationRef },
{ type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [SpeechRecognitionGrammars,] }] },
{ type: String, decorators: [{ type: core.Optional }, { type: core.Inject, args: [SpeechRecognitionLang,] }] },
{ type: Boolean, decorators: [{ type: core.Optional }, { type: core.Inject, args: [SpeechRecognitionContinuous,] }] },
{ type: Boolean, decorators: [{ type: core.Optional }, { type: core.Inject, args: [SpeechRecognitionInterimResults,] }] },
{ type: Number, decorators: [{ type: core.Optional }, { type: core.Inject, args: [SpeechRecognitionMaxAlternatives,] }] },
{ type: String, decorators: [{ type: core.Optional }, { type: core.Inject, args: [SpeechRecognitionServiceUri,] }] }
];
};
return RxSpeechRecognitionService;
}(SpeechRecognitionCommon));
/**
* @fileoverview added by tsickle
* Generated from: lib/service/speech-recognition.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
// @dynamic
var SpeechRecognitionService = /** @class */ (function (_super) {
__extends(SpeechRecognitionService, _super);
function SpeechRecognitionService(ref, grammars, lang, continuous, interimResults, maxAlternatives, serviceURI, audiostartHandler, soundstartHandler, speechstartHandler, speechendHandler, soundendHandler, audioendHandler, resultHandler, nomatchHandler, errorHandler, startHandler, endHandler) {
var _this = _super.call(this, grammars, lang, continuous, interimResults, maxAlternatives, serviceURI) || this;
_this.ref = ref;
_this.audiostartHandler = audiostartHandler;
_this.soundstartHandler = soundstartHandler;
_this.speechstartHandler = speechstartHandler;
_this.speechendHandler = speechendHandler;
_this.soundendHandler = soundendHandler;
_this.audioendHandler = audioendHandler;
_this.resultHandler = resultHandler;
_this.nomatchHandler = nomatchHandler;
_this.errorHandler = errorHandler;
_this.startHandler = startHandler;
_this.endHandler = endHandler;
_this.initHandlers();
_this.initInternal();
return _this;
}
/**
* @private
* @return {?}
*/
SpeechRecognitionService.prototype.initHandlers = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var _ = ( /**
* @return {?}
*/function () { });
if (!this.audiostartHandler) {
this.audiostartHandler = _;
}
if (!this.soundstartHandler) {
this.soundstartHandler = _;
}
if (!this.speechstartHandler) {
this.speechstartHandler = _;
}
if (!this.speechendHandler) {
this.speechendHandler = _;
}
if (!this.soundendHandler) {
this.soundendHandler = _;
}
if (!this.audioendHandler) {
this.audioendHandler = _;
}
if (!this.resultHandler) {
this.resultHandler = _;
}
if (!this.nomatchHandler) {
this.nomatchHandler = _;
}
if (!this.errorHandler) {
this.errorHandler = _;
}
if (!this.startHandler) {
this.startHandler = _;
}
if (!this.endHandler) {
this.endHandler = _;
}
};
/**
* @private
* @return {?}
*/
SpeechRecognitionService.prototype.initInternal = /**
* @private
* @return {?}
*/
function () {
var _this = this;
// see setter methods
this.grammars = this._grammars;
this.lang = this._lang;
this.continuous = this._continuous;
this.interimResults = this._interimResults;
this.maxAlternatives = this._maxAlternatives;
this.serviceURI = this._serviceURI;
this.internal.onaudiostart = ( /**
* @param {?} e
* @return {?}
*/function (e) {
_this.audiostartHandler(e);
_this.ref.tick();
});
this.internal.onsoundstart = ( /**
* @param {?} e
* @return {?}
*/function (e) {
_this.soundstartHandler(e);
_this.ref.tick();
});
this.internal.onspeechstart = ( /**
* @param {?} e
* @return {?}
*/function (e) {
_this.speechstartHandler(e);
_this.ref.tick();
});
this.internal.onspeechend = ( /**
* @param {?} e
* @return {?}
*/function (e) {
_this.speechendHandler(e);
_this.ref.tick();
});
this.internal.onsoundend = ( /**
* @param {?} e
* @return {?}
*/function (e) {
_this.soundendHandler(e);
_this.ref.tick();
});
this.internal.onaudioend = ( /**
* @param {?} e
* @return {?}
*/function (e) {
_this.audioendHandler(e);
_this.ref.tick();
});
this.internal.onresult = ( /**
* @param {?} e
* @return {?}
*/function (e) {
_this.resultHandler(e);
_this.ref.tick();
});
this.internal.onnomatch = ( /**
* @param {?} e
* @return {?}
*/function (e) {
_this.nomatchHandler(e);
_this.ref.tick();
});
this.internal.onerror = ( /**
* @param {?} e
* @return {?}
*/function (e) {
_this.errorHandler(e);
_this.ref.tick();
});
this.internal.onstart = ( /**
* @param {?} e
* @return {?}
*/function (e) {
_this.startHandler(e);
_this.ref.tick();
});
this.internal.onend = ( /**
* @param {?} e
* @return {?}
*/function (e) {
_this.endHandler(e);
_this.ref.tick();
});
};
Object.defineProperty(SpeechRecognitionService.prototype, "onaudiostart", {
// The onaudiostart property of the SpeechRecognition interface
// represents an event handler that will run
// when the user agent has started to capture audio
// (when the audiostart event fires.)
//
// SpeechRecognitionインターフェイスのonaudiostartプロパティは、
// ユーザーエージェントがオーディオのキャプチャを開始したとき
// (audiostartイベントが発生したとき)に実行されるイベントハンドラを
// 表します。
set:
// The onaudiostart property of the SpeechRecognition interface
// represents an event handler that will run
// when the user agent has started to capture audio
// (when the audiostart event fires.)
//
// SpeechRecognitionインターフェイスのonaudiostartプロパティは、
// ユーザーエージェントがオーディオのキャプチャを開始したとき
// (audiostartイベントが発生したとき)に実行されるイベントハンドラを
// 表します。
/**
* @param {?} handler
* @return {?}
*/
function (handler) {
this.audiostartHandler = handler;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionService.prototype, "onsoundstart", {
// The onsoundstart property of the SpeechRecognition interface represents
// an event handler that will run when any sound
// — recognisable speech or not
// — has been detected (when the soundstart event fires.)
//
// SpeechRecognitionインターフェイスのonsoundstartプロパティは、
// サウンド認識可能な音声が検出されたときに実行されるイベントハンドラを表します
// (サウンドスタートイベントが発生したとき)。
set:
// The onsoundstart property of the SpeechRecognition interface represents
// an event handler that will run when any sound
// — recognisable speech or not
// — has been detected (when the soundstart event fires.)
//
// SpeechRecognitionインターフェイスのonsoundstartプロパティは、
// サウンド認識可能な音声が検出されたときに実行されるイベントハンドラを表します
// (サウンドスタートイベントが発生したとき)。
/**
* @param {?} handler
* @return {?}
*/
function (handler) {
this.soundstartHandler = handler;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionService.prototype, "onspeechstart", {
// The onspeechstart property of the SpeechRecognition interface represents
// an event handler that will run when sound recognised
// by the speech recognition service as speech has been detected
// (when the speechstart event fires.)
//
// SpeechRecognitionインターフェイスのonspeechstartプロパティは、
// スピーチが検出されたとき(スピーチ開始イベントが発生したとき)に
// 音声認識サービスによって認識されたサウンドが実行されるイベントハンドラを表します。
set:
// The onspeechstart property of the SpeechRecognition interface represents
// an event handler that will run when sound recognised
// by the speech recognition service as speech has been detected
// (when the speechstart event fires.)
//
// SpeechRecognitionインターフェイスのonspeechstartプロパティは、
// スピーチが検出されたとき(スピーチ開始イベントが発生したとき)に
// 音声認識サービスによって認識されたサウンドが実行されるイベントハンドラを表します。
/**
* @param {?} handler
* @return {?}
*/
function (handler) {
this.speechstartHandler = handler;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionService.prototype, "onspeechend", {
// The onspeechend property of the SpeechRecognition interface represents
// an event handler that will run when speech recognised
// by the speech recognition service has stopped being detected
// (when the speechend event fires.)
//
// SpeechRecognitionインターフェイスのonspeechendプロパティは、
// 音声認識サービスによって認識された音声が検出されなくなったとき
// (Speechendイベントが発生したとき)に実行されるイベントハンドラを表します。
set:
// The onspeechend property of the SpeechRecognition interface represents
// an event handler that will run when speech recognised
// by the speech recognition service has stopped being detected
// (when the speechend event fires.)
//
// SpeechRecognitionインターフェイスのonspeechendプロパティは、
// 音声認識サービスによって認識された音声が検出されなくなったとき
// (Speechendイベントが発生したとき)に実行されるイベントハンドラを表します。
/**
* @param {?} handler
* @return {?}
*/
function (handler) {
this.speechendHandler = handler;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionService.prototype, "onsoundend", {
// The onsoundend property of the SpeechRecognition interface represents
// an event handler that will run when any sound
// — recognisable speech or not — has stopped being detected
// (when the soundend event fires.)
//
// SpeechRecognitionインターフェイスのonsoundendプロパティは、
// サウンド認識可能な音声が検出されなくなったときに実行されるイベントハンドラを表します
// (サウンドエンドイベントが発生したとき)。
set:
// The onsoundend property of the SpeechRecognition interface represents
// an event handler that will run when any sound
// — recognisable speech or not — has stopped being detected
// (when the soundend event fires.)
//
// SpeechRecognitionインターフェイスのonsoundendプロパティは、
// サウンド認識可能な音声が検出されなくなったときに実行されるイベントハンドラを表します
// (サウンドエンドイベントが発生したとき)。
/**
* @param {?} handler
* @return {?}
*/
function (handler) {
this.soundendHandler = handler;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionService.prototype, "onaudioend", {
// The onaudioend property of the SpeechRecognition interface represents
// an event handler that will run
// when the user agent has finished capturing audio
// (when the audioend event fires.)
//
// SpeechRecognitionインターフェイスのonaudioendプロパティは、
// ユーザーエージェントがオーディオのキャプチャを終了したとき
// (オーディオエンドイベントが発生したとき)に実行されるイベントハンドラを表します。
set:
// The onaudioend property of the SpeechRecognition interface represents
// an event handler that will run
// when the user agent has finished capturing audio
// (when the audioend event fires.)
//
// SpeechRecognitionインターフェイスのonaudioendプロパティは、
// ユーザーエージェントがオーディオのキャプチャを終了したとき
// (オーディオエンドイベントが発生したとき)に実行されるイベントハンドラを表します。
/**
* @param {?} handler
* @return {?}
*/
function (handler) {
this.audioendHandler = handler;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionService.prototype, "onresult", {
// The onresult property of the SpeechRecognition interface represents
// an event handler that will run
// when the speech recognition service returns a result
// — a word or phrase has been positively recognized
// and this has been communicated back to the app
// (when the result event fires.)
//
// SpeechRecognitionインターフェイスのonresultプロパティは、
// 音声認識サービスが結果を返すときに実行されるイベントハンドラを表します。
// 単語やフレーズが確実に認識され、結果イベントが発生したときにアプリに返されます。
set:
// The onresult property of the SpeechRecognition interface represents
// an event handler that will run
// when the speech recognition service returns a result
// — a word or phrase has been positively recognized
// and this has been communicated back to the app
// (when the result event fires.)
//
// SpeechRecognitionインターフェイスのonresultプロパティは、
// 音声認識サービスが結果を返すときに実行されるイベントハンドラを表します。
// 単語やフレーズが確実に認識され、結果イベントが発生したときにアプリに返されます。
/**
* @param {?} handler
* @return {?}
*/
function (handler) {
this.resultHandler = handler;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionService.prototype, "onnomatch", {
// The onnomatch property of the SpeechRecognition interface represents
// an event handler that will run
// when the speech recognition service returns
// a final result with no significant recognition
// (when the nomatch event fires.)
//
// This may involve some degree of recognition
// which doesn't meet or exceed the confidence threshold.
//
//
// SpeechRecognitionインターフェイスのonnomatchプロパティは、
// 音声認識サービスが重要な認識なしに(nomatchイベントが発生したとき)
// 最終結果を返すときに実行されるイベントハンドラを表します。
//
// これには、ある程度の認識が必要であり、これは信頼限界を満たさないか、
// 超えている。
set:
// The onnomatch property of the SpeechRecognition interface represents
// an event handler that will run
// when the speech recognition service returns
// a final result with no significant recognition
// (when the nomatch event fires.)
//
// This may involve some degree of recognition
// which doesn't meet or exceed the confidence threshold.
//
//
// SpeechRecognitionインターフェイスのonnomatchプロパティは、
// 音声認識サービスが重要な認識なしに(nomatchイベントが発生したとき)
// 最終結果を返すときに実行されるイベントハンドラを表します。
//
// これには、ある程度の認識が必要であり、これは信頼限界を満たさないか、
// 超えている。
/**
* @param {?} handler
* @return {?}
*/
function (handler) {
this.nomatchHandler = handler;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionService.prototype, "onerror", {
// The onerror property of the SpeechRecognition interface represents
// an event handler that will run
// when a speech recognition error occurs
// (when the error event fires.)
//
// SpeechRecognitionインターフェイスのonerrorプロパティは、
// 音声認識エラーが発生したとき(エラーイベントが発生したとき)に
// 実行されるイベントハンドラを表します。
set:
// The onerror property of the SpeechRecognition interface represents
// an event handler that will run
// when a speech recognition error occurs
// (when the error event fires.)
//
// SpeechRecognitionインターフェイスのonerrorプロパティは、
// 音声認識エラーが発生したとき(エラーイベントが発生したとき)に
// 実行されるイベントハンドラを表します。
/**
* @param {?} handler
* @return {?}
*/
function (handler) {
this.errorHandler = handler;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionService.prototype, "onstart", {
// The onstart property of the SpeechRecognition interface represents
// an event handler that will run when the speech
// recognition service has begun listening
// to incoming audio with intent to recognize grammars
// associated with the current SpeechRecognition
// (when the start event fires.)
//
//
// SpeechRecognitionインターフェイスのonstartプロパティは、
// 音声認識サービスが現在のSpeechRecognitionに関連付けられている文法を
// 認識することを目的として着信オーディオを聴き始めたときに実行される
// イベントハンドラを表します(開始イベントが発生したとき)。
set:
// The onstart property of the SpeechRecognition interface represents
// an event handler that will run when the speech
// recognition service has begun listening
// to incoming audio with intent to recognize grammars
// associated with the current SpeechRecognition
// (when the start event fires.)
//
//
// SpeechRecognitionインターフェイスのonstartプロパティは、
// 音声認識サービスが現在のSpeechRecognitionに関連付けられている文法を
// 認識することを目的として着信オーディオを聴き始めたときに実行される
// イベントハンドラを表します(開始イベントが発生したとき)。
/**
* @param {?} handler
* @return {?}
*/
function (handler) {
this.startHandler = handler;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SpeechRecognitionService.prototype, "onend", {
// The onend property of the SpeechRecognition interface represents
// an event handler that will run when the speech recognition
// service has disconnected (when the end event fires.)
//
// SpeechRecognitionインターフェイスのonendプロパティは、
// 音声認識サービスが切断されたとき(終了イベントが発生したとき)に
// 実行されるイベントハンドラを表します。
set:
// The onend property of the SpeechRecognition interface represents
// an event handler that will run when the speech recognition
// service has disconnected (when the end event fires.)
//
// SpeechRecognitionインターフェイスのonendプロパティは、
// 音声認識サービスが切断されたとき(終了イベントが発生したとき)に
// 実行されるイベントハンドラを表します。
/**
* @param {?} handler
* @return {?}
*/
function (handler) {
this.endHandler = handler;
},
enumerable: true,
configurable: true
});
// The start() method of the Web Speech API starts the speech recognition service
// listening to incoming audio with intent to recognize grammars
// associated with the current SpeechRecognition.
//
// Web Speech APIのstart()メソッドは、現在のSpeechRecognitionに
// 関連付けられた文法を認識することを目的として、
// 着信音声を聴取する音声認識サービスを開始します。
// The start() method of the Web Speech API starts the speech recognition service
// listening to incoming audio with intent to recognize grammars
// associated with the current SpeechRecognition.
//
// Web Speech APIのstart()メソッドは、現在のSpeechRecognitionに
// 関連付けられた文法を認識することを目的として、
// 着信音声を聴取する音声認識サービスを開始します。
/**
* @return {?}
*/
SpeechRecognitionService.prototype.start =
// The start() method of the Web Speech API starts the speech recognition service
// listening to incoming audio with intent to recognize grammars
// associated with the current SpeechRecognition.
//
// Web Speech APIのstart()メソッドは、現在のSpeechRecognitionに
// 関連付けられた文法を認識することを目的として、
// 着信音声を聴取する音声認識サービスを開始します。
/**
* @return {?}
*/
function () {
this.internal.start();
this.ref.tick();
};
// The stop() method of the Web Speech API stops the speech recognition service
// from listening to incoming audio, and attempts to return a SpeechRecognitionResult
// using the audio captured so far.
//
// Web Speech APIのstop()メソッドは、音声認識サービスが着信音声を聴取するのを停止し、
// これまでに取得した音声を使用してSpeechRecognitionResultを返そうとします。
// The stop() method of the Web Speech API stops the speech recognition service
// from listening to incoming audio, and attempts to return a SpeechRecognitionResult
// using the audio captured so far.
//
// Web Speech APIのstop()メソッドは、音声認識サービスが着信音声を聴取するのを停止し、
// これまでに取得した音声を使用してSpeechRecognitionResultを返そうとします。
/**
* @return {?}
*/
SpeechRecognitionService.prototype.stop =
// The stop() method of the Web Speech API stops the speech recognition service
// from listening to incoming audio, and attempts to return a SpeechRecognitionResult
// using the audio captured so far.
//
// Web Speech APIのstop()メソッドは、音声認識サービスが着信音声を聴取するのを停止し、
// これまでに取得した音声を使用してSpeechRecognitionResultを返そうとします。
/**
* @return {?}
*/
function () {
this.internal.stop();
this.ref.tick();
};
// The abort() method of the Web Speech API stops the speech recognition service
// from listening to incoming audio, and doesn't attempt to return
// a SpeechRecognitionResult.
//
// Web Speech APIのabo