UNPKG

@sam17896/ngx-speech-recognition

Version:

Angular 5+ speech recognition service (based on browser implementation such as Chrome).

1,217 lines (1,208 loc) 60.9 kB
import { Observable, pipe, Subject, BehaviorSubject } from 'rxjs'; import { filter, map } from 'rxjs/operators'; import { __spread, __extends } from 'tslib'; import { InjectionToken, Injectable, ApplicationRef, Inject, Optional, NgModule, PLATFORM_ID } from '@angular/core'; import { isPlatformBrowser } from '@angular/common'; /** * @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/adapter.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @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 InjectionToken('speech-recognition.grammars'); /** @type {?} */ var SpeechRecognitionLang = new InjectionToken('speech-recognition.lang'); /** @type {?} */ var SpeechRecognitionContinuous = new InjectionToken('speech-recognition.continuous'); /** @type {?} */ var SpeechRecognitionInterimResults = new InjectionToken('speech-recognition.interimResults'); /** @type {?} */ var SpeechRecognitionMaxAlternatives = new InjectionToken('speech-recognition.maxAlternatives'); /** @type {?} */ var SpeechRecognitionServiceUri = new InjectionToken('speech-recognition.serviceURI'); /** @type {?} */ var SpeechRecognitionAudiostartHandler = new InjectionToken('speech-recognition.onaudiostart'); /** @type {?} */ var SpeechRecognitionSoundstartHandler = new InjectionToken('speech-recognition.onsoundstart'); /** @type {?} */ var SpeechRecognitionSpeechstartHandler = new InjectionToken('speech-recognition.onspeechstart'); /** @type {?} */ var SpeechRecognitionSpeechendHandler = new InjectionToken('speech-recognition.onspeechend'); /** @type {?} */ var SpeechRecognitionSoundendHandler = new InjectionToken('speech-recognition.onsoundend'); /** @type {?} */ var SpeechRecognitionAudioendHandler = new InjectionToken('speech-recognition.onaudioend'); /** @type {?} */ var SpeechRecognitionResultHandler = new InjectionToken('speech-recognition.onresult'); /** @type {?} */ var SpeechRecognitionNomatchHandler = new InjectionToken('speech-recognition.onnomatch'); /** @type {?} */ var SpeechRecognitionErrorHandler = new InjectionToken('speech-recognition.onerror'); /** @type {?} */ var SpeechRecognitionStartHandler = new InjectionToken('speech-recognition.onstart'); /** @type {?} */ var SpeechRecognitionEndHandler = new InjectionToken('speech-recognition.onend'); /** * @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 filter((/** * @param {?} e * @return {?} */ function (e) { return (e.type === type); })); }); /** @type {?} */ var resultList = pipe(onType('result'), 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 Subject(); _this._started$ = new 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 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: Injectable } ]; /** @nocollapse */ RxSpeechRecognitionService.ctorParameters = function () { return [ { type: ApplicationRef }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionGrammars,] }] }, { type: String, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionLang,] }] }, { type: Boolean, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionContinuous,] }] }, { type: Boolean, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionInterimResults,] }] }, { type: Number, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionMaxAlternatives,] }] }, { type: String, decorators: [{ type: Optional }, { type: 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のabort()メソッドは、音声認識サービスが着信オーディオを聴くのをやめ、 // SpeechRecognitionResultを返そうとしません。 // 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のabort()メソッドは、音声認識サービスが着信オーディオを聴くのをやめ、 // SpeechRecognitionResultを返そうとしません。 /** * @return {?} */ SpeechRecognitionService.prototype.abort = // 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のabort()メソッドは、音声認識サービスが着信オーディオを聴くのをやめ、 // SpeechRecognitionResultを返そうとしません。 /** * @return {?} */ function () { this.internal.abort(); this.ref.tick(); }; SpeechRecognitionService.decorators = [ { type: Injectable } ]; /** @nocollapse */ SpeechRecognitionService.ctorParameters = function () { return [ { type: ApplicationRef }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionGrammars,] }] }, { type: String, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionLang,] }] }, { type: Boolean, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionContinuous,] }] }, { type: Boolean, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionInterimResults,] }] }, { type: Number, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionMaxAlternatives,] }] }, { type: String, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionServiceUri,] }] }, { type: Function, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionAudiostartHandler,] }] }, { type: Function, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionSoundstartHandler,] }] }, { type: Function, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionSpeechstartHandler,] }] }, { type: Function, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionSpeechendHandler,] }] }, { type: Function, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionSoundendHandler,] }] }, { type: Function, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionAudioendHandler,] }] }, { type: Function, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionResultHandler,] }] }, { type: Function, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionNomatchHandler,] }] }, { type: Function, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionErrorHandler,] }] }, { type: Function, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionStartHandler,] }] }, { type: Function, decorators: [{ type: Optional }, { type: Inject, args: [SpeechRecognitionEndHandler,] }] } ]; }; return SpeechRecognitionService; }(SpeechRecognitionCommon)); /** * @fileoverview added by tsickle * Generated from: lib/speech-recognition.config.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * Generated from: lib/speech-recognition.provider.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ // tslint:disable-next-line:class-name /** @type {?} */ var SPEECH_RECOGNITION_DEFAULT = [ { provide: SpeechRecognitionContinuous, useValue: false, }, { provide: SpeechRecognitionInterimResults, useValue: false, }, { provide: SpeechRecognitionMaxAlternatives, useValue: 1, }, ]; /** * @fileoverview added by tsickle * Generated from: lib/speech-recognition.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var SpeechRecognitionModule = /** @class */ (function () { function SpeechRecognitionModule(platformId) { if (isPlatformBrowser(platformId) === false) { throw new Error('SpeechRecognitionModule: it run on PlatformBrowser.'); } } /** * @param {?} config * @return {?} */ SpeechRecognitionModule.forRoot = /** * @param {?} config * @return {?} */ function (config) { return { ngModule: SpeechRecognitionModule, providers: __spread((config.grammars !== undefined && config.grammars != null ? [{ useValue: config.grammars, provide: SpeechRecognitionGrammars }] : []), (config.lang !== undefined && config.lang != null ? [{ useValue: config.lang, provide: SpeechRecognitionLang }] : []), (config.continuous !== undefined && config.continuous != null ? [{ useValue: config.continuous, provide: SpeechRecognitionContinuous }] : []), (config.interimResults !== undefined && config.interimResults != null ? [{ useValue: config.interimResults, provide: SpeechRecognitionInterimResults }] : []), (config.maxAlternatives !== undefined && config.maxAlternatives != null ? [{ useValue: config.maxAlternatives, provide: SpeechRecognitionMaxAlternatives }] : []), (config.serviceURI !== undefined && config.serviceURI != null ? [{ useValue: config.serviceURI, provide: SpeechRecognitionServiceUri }] : []), (config.onaudiostart instanceof Function ? [{ useValue: config.onaudiostart, provide: SpeechRecognitionAudiostartHandler }] : []), (config.onsoundstart instanceof Function ? [{ useValue: config.onsoundstart, provide: SpeechRecognitionSoundstartHandler }] : []), (config.onspeechstart instanceof Function ? [{ useValue: config.onspeechstart, provide: SpeechRecognitionSpeechstartHandler }] : []), (config.onspeechend instanceof Function ? [{ useValue: config.onspeechend, provide: SpeechRecognitionSpeechendHandler }] : []), (config.onsoundend instanceof Function ? [{ useValue: config.onsoundend, provide: SpeechRecognitionSoundendHandler }] : []), (config.onaudioend instanceof Function ? [{ useValue: config.onaudioend, provide: SpeechRecognitionAudioendHandler }] : []), (config.onresult instanceof Function ? [{ useValue: config.onresult, provide: SpeechRecognitionResultHandler }] : []), (config.onnomatch instanceof Function ? [{ useValue: config.onnomatch, provide: SpeechRecognitionNomatchHandler }] : []), (config.onerror instanceof Function ? [{ useValue: config.onerror, provide: SpeechRecognitionErrorHandler }] : []), (config.onstart instanceof Function ? [{ useValue: config.onstart, provide: SpeechRecognitionStartHandler }] : []), (config.onend instanceof Function ? [{ useValue: config.onend, provide: SpeechRecognitionEndHandler }] : []), [ { useClass: SpeechRecognitionService, provide: SpeechRecognitionService }, { useClass: RxSpeechRecognitionService, provide: RxSpeechRecognitionService } ]), }; }; /** * @param {?} config * @return {?} */ SpeechRecognitionModule.withConfig = /** * @param {?} config * @return {?} */ function (config) { return { ngModule: SpeechRecognitionModule, provid