kamiazya/ngx-speech-synthesis

View on GitHub
docs/main.dce54f8eee00a2ababb9.bundle.js

Summary

Maintainability
A
0 mins
Test Coverage
(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{259:function(module,exports){function webpackEmptyAsyncContext(req){return Promise.resolve().then(function(){var e=new Error("Cannot find module '"+req+"'");throw e.code="MODULE_NOT_FOUND",e})}webpackEmptyAsyncContext.keys=function(){return[]},webpackEmptyAsyncContext.resolve=webpackEmptyAsyncContext,module.exports=webpackEmptyAsyncContext,webpackEmptyAsyncContext.id=259},26:function(module,__webpack_exports__,__webpack_require__){"use strict";var core_umd=__webpack_require__(1),Lang=new core_umd.InjectionToken("speech-synthesis.lang"),Voice=new core_umd.InjectionToken("speech-synthesis.voice"),Volume=new core_umd.InjectionToken("speech-synthesis.volume"),Rate=new core_umd.InjectionToken("speech-synthesis.rate"),Pitch=new core_umd.InjectionToken("speech-synthesis.pitch"),OnStartHandler=new core_umd.InjectionToken("speech-synthesis.onstart"),OnEndHandler=new core_umd.InjectionToken("speech-synthesis.onend"),OnErrorHandler=new core_umd.InjectionToken("speech-synthesis.onerror"),OnPauseHandler=new core_umd.InjectionToken("speech-synthesis.onpause"),OnResumeHandler=new core_umd.InjectionToken("speech-synthesis.onresume"),OnMarkHandler=new core_umd.InjectionToken("speech-synthesis.onmark"),OnBoundaryHandler=new core_umd.InjectionToken("speech-synthesis.onboundary"),Config=(new core_umd.InjectionToken("speech-synthesis.params"),new core_umd.InjectionToken("speech-synthesis.config")),tslib=__webpack_require__(3),speech_synthesis_service_SpeechSynthesisService=function(){function SpeechSynthesisService(){this.internal=window.speechSynthesis}return Object.defineProperty(SpeechSynthesisService.prototype,"pending",{get:function(){return this.internal.pending},enumerable:!0,configurable:!0}),Object.defineProperty(SpeechSynthesisService.prototype,"speaking",{get:function(){return this.internal.speaking},enumerable:!0,configurable:!0}),Object.defineProperty(SpeechSynthesisService.prototype,"paused",{get:function(){return this.internal.paused},enumerable:!0,configurable:!0}),Object.defineProperty(SpeechSynthesisService.prototype,"onvoiceschanged",{set:function(handler){this.internal.onvoiceschanged=handler},enumerable:!0,configurable:!0}),SpeechSynthesisService.prototype.speak=function(utterance){this.internal.speak(utterance)},SpeechSynthesisService.prototype.cancel=function(){this.internal.cancel()},SpeechSynthesisService.prototype.pause=function(){this.internal.pause()},SpeechSynthesisService.prototype.resume=function(){this.internal.resume()},SpeechSynthesisService.prototype.getVoices=function(){return this.internal.getVoices()},SpeechSynthesisService=tslib.__decorate([Object(core_umd.Injectable)({providedIn:"root"}),tslib.__metadata("design:paramtypes",[])],SpeechSynthesisService)}(),speech_synthesis_utterance_factory_service_SpeechSynthesisUtteranceFactoryService=function(){function SpeechSynthesisUtteranceFactoryService(config,lang,voice,volume,rate,pitch,onstart,onend,onerror,onpause,onresume,onmark,onboundary){var _this=this;this.internal=window.speechSynthesis,this._config=config,this._lang=lang,"string"==typeof voice?this.internal.addEventListener("voiceschanged",function(){_this._voice=_this.internal.getVoices().find(function(v){return v.name===voice})}):this._voice=voice,this._volume=volume,this._rate=rate,this._pitch=pitch,this._onstart=onstart,this._onend=onend,this._onerror=onerror,this._onpause=onpause,this._onresume=onresume,this._onmark=onmark,this._onboundary=onboundary}return Object.defineProperty(SpeechSynthesisUtteranceFactoryService.prototype,"lang",{get:function(){return this._lang||this._config.lang},set:function(lang){this._lang=lang},enumerable:!0,configurable:!0}),Object.defineProperty(SpeechSynthesisUtteranceFactoryService.prototype,"voice",{get:function(){return this._voice||this._config.voice},set:function(voice){this._voice=voice},enumerable:!0,configurable:!0}),Object.defineProperty(SpeechSynthesisUtteranceFactoryService.prototype,"volume",{get:function(){return this._volume||this._config.volume},set:function(volume){this._volume=volume},enumerable:!0,configurable:!0}),Object.defineProperty(SpeechSynthesisUtteranceFactoryService.prototype,"rate",{get:function(){return this._rate||this._config.rate},set:function(rate){this._rate=rate},enumerable:!0,configurable:!0}),Object.defineProperty(SpeechSynthesisUtteranceFactoryService.prototype,"pitch",{get:function(){return this._pitch||this._config.pitch},set:function(pitch){this._pitch=pitch},enumerable:!0,configurable:!0}),Object.defineProperty(SpeechSynthesisUtteranceFactoryService.prototype,"onstart",{get:function(){return this._onstart||this._config.onstart},set:function(onstart){this._onstart=onstart},enumerable:!0,configurable:!0}),Object.defineProperty(SpeechSynthesisUtteranceFactoryService.prototype,"onend",{get:function(){return this._onend||this._config.onend},set:function(onend){this._onend=onend},enumerable:!0,configurable:!0}),Object.defineProperty(SpeechSynthesisUtteranceFactoryService.prototype,"onerror",{get:function(){return this._onerror||this._config.onerror},set:function(onerror){this._onerror=onerror},enumerable:!0,configurable:!0}),Object.defineProperty(SpeechSynthesisUtteranceFactoryService.prototype,"onpause",{get:function(){return this._onpause||this._config.onpause},set:function(onpause){this._onpause=onpause},enumerable:!0,configurable:!0}),Object.defineProperty(SpeechSynthesisUtteranceFactoryService.prototype,"onresume",{get:function(){return this._onresume||this._config.onresume},set:function(onresume){this._onresume=onresume},enumerable:!0,configurable:!0}),Object.defineProperty(SpeechSynthesisUtteranceFactoryService.prototype,"onmark",{get:function(){return this._onmark||this._config.onmark},set:function(onmark){this._onmark=onmark},enumerable:!0,configurable:!0}),Object.defineProperty(SpeechSynthesisUtteranceFactoryService.prototype,"onboundary",{get:function(){return this._onboundary||this._config.onboundary},set:function(onboundary){this._onboundary=onboundary},enumerable:!0,configurable:!0}),SpeechSynthesisUtteranceFactoryService.prototype.text=function(text){var utterance=new SpeechSynthesisUtterance(text);return utterance.lang=this.lang,utterance.voice=this.voice,utterance.volume=this.volume,utterance.rate=this.rate,utterance.pitch=this.pitch,utterance.onstart=this.onstart,utterance.onend=this.onend,utterance.onerror=this.onerror,utterance.onpause=this.onpause,utterance.onresume=this.onresume,utterance.onmark=this.onmark,utterance.onboundary=this.onboundary,utterance},SpeechSynthesisUtteranceFactoryService=tslib.__decorate([Object(core_umd.Injectable)({providedIn:"root"}),tslib.__param(0,Object(core_umd.Optional)()),tslib.__param(0,Object(core_umd.Inject)(Config)),tslib.__param(1,Object(core_umd.Optional)()),tslib.__param(1,Object(core_umd.Inject)(Lang)),tslib.__param(2,Object(core_umd.Optional)()),tslib.__param(2,Object(core_umd.Inject)(Voice)),tslib.__param(3,Object(core_umd.Optional)()),tslib.__param(3,Object(core_umd.Inject)(Volume)),tslib.__param(4,Object(core_umd.Optional)()),tslib.__param(4,Object(core_umd.Inject)(Rate)),tslib.__param(5,Object(core_umd.Optional)()),tslib.__param(5,Object(core_umd.Inject)(Pitch)),tslib.__param(6,Object(core_umd.Optional)()),tslib.__param(6,Object(core_umd.Inject)(OnStartHandler)),tslib.__param(7,Object(core_umd.Optional)()),tslib.__param(7,Object(core_umd.Inject)(OnEndHandler)),tslib.__param(8,Object(core_umd.Optional)()),tslib.__param(8,Object(core_umd.Inject)(OnErrorHandler)),tslib.__param(9,Object(core_umd.Optional)()),tslib.__param(9,Object(core_umd.Inject)(OnPauseHandler)),tslib.__param(10,Object(core_umd.Optional)()),tslib.__param(10,Object(core_umd.Inject)(OnResumeHandler)),tslib.__param(11,Object(core_umd.Optional)()),tslib.__param(11,Object(core_umd.Inject)(OnMarkHandler)),tslib.__param(12,Object(core_umd.Optional)()),tslib.__param(12,Object(core_umd.Inject)(OnBoundaryHandler)),tslib.__metadata("design:paramtypes",["function"!=typeof!1&&Object,String,Object,Number,Number,Number,"function"!=typeof!1&&Object,"function"!=typeof!1&&Object,"function"!=typeof!1&&Object,"function"!=typeof!1&&Object,"function"!=typeof!1&&Object,"function"!=typeof!1&&Object,"function"!=typeof!1&&Object])],SpeechSynthesisUtteranceFactoryService)}(),speech_synthesis_module_SpeechSynthesisModule=function(){function SpeechSynthesisModule(){}var SpeechSynthesisModule_1;return SpeechSynthesisModule_1=SpeechSynthesisModule,SpeechSynthesisModule.forRoot=function(config){return{ngModule:SpeechSynthesisModule_1,providers:[{provide:Config,useValue:config}]}},SpeechSynthesisModule=SpeechSynthesisModule_1=tslib.__decorate([Object(core_umd.NgModule)({declarations:[],imports:[],exports:[]})],SpeechSynthesisModule)}();__webpack_require__.d(__webpack_exports__,"b",function(){return Rate}),__webpack_require__.d(__webpack_exports__,"a",function(){return Pitch}),__webpack_require__.d(__webpack_exports__,"d",function(){return speech_synthesis_service_SpeechSynthesisService}),__webpack_require__.d(__webpack_exports__,"e",function(){return speech_synthesis_utterance_factory_service_SpeechSynthesisUtteranceFactoryService}),__webpack_require__.d(__webpack_exports__,"c",function(){return speech_synthesis_module_SpeechSynthesisModule})},288:function(module,exports,__webpack_require__){__webpack_require__(289),__webpack_require__(369),module.exports=__webpack_require__(370)},370:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),function(module){__webpack_require__(16),__webpack_require__(17),__webpack_require__(18);var _storybook_angular__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(97),req=(__webpack_require__(557),__webpack_require__(558));Object(_storybook_angular__WEBPACK_IMPORTED_MODULE_3__.configure)(function(){req.keys().forEach(function(filename){return req(filename)})},module)}.call(this,__webpack_require__(196)(module))},558:function(module,exports,__webpack_require__){var map={"./index.stories.ts":559};function webpackContext(req){var id=webpackContextResolve(req);return __webpack_require__(id)}function webpackContextResolve(req){var id=map[req];if(!(id+1)){var e=new Error("Cannot find module '"+req+"'");throw e.code="MODULE_NOT_FOUND",e}return id}webpackContext.keys=function(){return Object.keys(map)},webpackContext.resolve=webpackContextResolve,module.exports=webpackContext,webpackContext.id=558},559:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),function(module){var _storybook_angular__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(97),_app_components_speech_synthesis_demo_speech_synthesis_demo_component__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(98),_projects_speech_synthesis_src_public_api__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(26),_storybook_addon_actions__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(99),_angular_forms__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(72);Object(_storybook_angular__WEBPACK_IMPORTED_MODULE_0__.storiesOf)("DEMO",module).add("English",function(){return{moduleMetadata:{imports:[_projects_speech_synthesis_src_public_api__WEBPACK_IMPORTED_MODULE_2__.c.forRoot({volume:1,pitch:1,rate:1}),_angular_forms__WEBPACK_IMPORTED_MODULE_4__.FormsModule]},component:_app_components_speech_synthesis_demo_speech_synthesis_demo_component__WEBPACK_IMPORTED_MODULE_1__.a,props:{content:["Peter Piper picked a peck of pickled peppers.","A peck of pickled peppers Peter Piper picked.","If Peter Piper picked a peck of pickled peppers,","Where's the peck of pickled peppers Peter Piper picked?"].join("\n"),lang:"en-US",utterance:Object(_storybook_addon_actions__WEBPACK_IMPORTED_MODULE_3__.action)("utterance")}}}).add("Japanese",function(){return{moduleMetadata:{imports:[_projects_speech_synthesis_src_public_api__WEBPACK_IMPORTED_MODULE_2__.c.forRoot({volume:1,pitch:1,rate:1}),_angular_forms__WEBPACK_IMPORTED_MODULE_4__.FormsModule]},component:_app_components_speech_synthesis_demo_speech_synthesis_demo_component__WEBPACK_IMPORTED_MODULE_1__.a,props:{content:["お宮の前の飴屋に","あんまと尼が雨やどり","雨やむまで","あんまももうと","あんま申す","あんま尼もみ","尼あんまもむ","あんまうまいか","尼うまいか","あんまも尼もみなうまい","あんまもおもみやれ","尼もおもみやれ","雨やどり"].join("\n"),lang:"ja",utterance:Object(_storybook_addon_actions__WEBPACK_IMPORTED_MODULE_3__.action)("utterance")}}}),Object(_storybook_angular__WEBPACK_IMPORTED_MODULE_0__.storiesOf)("Settings",module).add("You can pitch/rate/voice by factory.",function(){return{moduleMetadata:{imports:[_projects_speech_synthesis_src_public_api__WEBPACK_IMPORTED_MODULE_2__.c.forRoot({volume:1,pitch:.9,rate:2.2}),_angular_forms__WEBPACK_IMPORTED_MODULE_4__.FormsModule]},component:_app_components_speech_synthesis_demo_speech_synthesis_demo_component__WEBPACK_IMPORTED_MODULE_1__.a,props:{setting:!0,content:["How much wood would a woodchuck chuck if a woodchuck could chuck wood?","He would chuck, he would, as much as he could, and chuck as much wood","As a woodchuck would if a woodchuck could chuck wood"].join("\n"),lang:"en-US",utterance:Object(_storybook_addon_actions__WEBPACK_IMPORTED_MODULE_3__.action)("utterance")}}}).add("You can pitch/rate/voice by provider.",function(){return{moduleMetadata:{imports:[_projects_speech_synthesis_src_public_api__WEBPACK_IMPORTED_MODULE_2__.c.forRoot({volume:1}),_angular_forms__WEBPACK_IMPORTED_MODULE_4__.FormsModule],providers:[{provide:_projects_speech_synthesis_src_public_api__WEBPACK_IMPORTED_MODULE_2__.a,useValue:2},{provide:_projects_speech_synthesis_src_public_api__WEBPACK_IMPORTED_MODULE_2__.b,useValue:2}]},component:_app_components_speech_synthesis_demo_speech_synthesis_demo_component__WEBPACK_IMPORTED_MODULE_1__.a,props:{content:["可逆反応の逆不可逆反応","不可逆反応の逆可逆反応","可逆反応も不可逆反応も化学反応"].join("\n"),lang:"ja",utterance:Object(_storybook_addon_actions__WEBPACK_IMPORTED_MODULE_3__.action)("utterance")}}})}.call(this,__webpack_require__(196)(module))},560:function(module,exports){module.exports='<div>\n  <div id="selecting-manuscript" *ngIf="contentTexts">\n    <h2>Content({{lang}})</h2>\n    <div>\n      <p *ngFor="let text of contentTexts">{{text}}</p>\n    </div>\n    <div>\n      <button (click)="speech()">\n        speech\n      </button>\n      <button (click)="resume()">\n        resume\n      </button>\n      <button (click)="pause()">\n        pause\n      </button>\n      <button (click)="cancel()">\n        cancel\n      </button>\n    </div>\n\n  </div>\n  <div *ngIf="setting">\n    <h2>Setting</h2>\n    <div>\n      <h3>Pitch {{f.pitch}}</h3>\n      <p>This attribute specifies the speaking pitch for the utterance.</p>\n      <p>It ranges between 0 and 2 inclusive, with 0 being the lowest pitch and 2 the highest pitch.</p>\n      <p>1 corresponds to the default pitch of the speech synthesis engine or specific voice.</p>\n      <p>Speech synthesis engines or voices may constrain the minimum and maximum rates further.</p>\n      <p>If SSML is used, this value will be overridden by prosody tags in the markup.</p>\n      <input\n        type="number"\n        [(ngModel)]="f.pitch"\n        [min]="0"\n        [max]="2"\n        [step]="0.1"\n        />\n      <hr>\n      <h3>Rate {{f.rate}}</h3>\n      <p>This attribute specifies the speaking rate for the utterance.</p>\n      <p>It is relative to the default rate for this voice.</p>\n      <p>1 is the default rate supported by the speech synthesis engine or specific voice</p>\n      <p>(which should correspond to a normal speaking rate).</p>\n      <p>2 is twice as fast, and 0.5 is half as fast. Values below 0.1 or above 10 are strictly disallowed,</p>\n      <p>but speech synthesis engines or specific voices may constrain the minimum and maximum rates further,</p>\n      <p>for example, a particular voice may not actually speak faster than 3 times normal</p>\n      <p>even if you specify a value larger than 3.</p>\n      <p>If SSML is used, this value will be overridden by prosody tags in the markup.</p>\n      <input\n        type="number"\n        [(ngModel)]="f.rate"\n        [min]="1"\n        [max]="5"\n        [step]="0.1"\n        >\n\n      <hr>\n      <h3>Voice</h3>\n      <p>This attribute specifies the speech synthesis voice that the web application wishes to use.</p>\n      <p>When a SpeechSynthesisUtterance object is created this attribute must be initialized to null.</p>\n      <p>If, at the time of the speak() method call,</p>\n      <p>this attribute has been set to one of the SpeechSynthesisVoice objects returned by getVoices(),</p>\n      <p>then the user agent must use that voice. If this attribute is unset or null at the time of the speak()</p>\n      <p>method call, then the user agent must use a user agent default voice.</p>\n      <p>The user agent default voice should support the current language (see lang) and</p>\n      <p>can be a local or remote speech service and can incorporate end user choices via interfaces</p>\n      <p>provided by the user agent such as browser configuration parameters.</p>\n      <select [(ngModel)]="f.voice">\n        <option\n          *ngFor="let voice of getVoices$() | async"\n          [value]="voice"\n        >{{voice.name}}</option>\n      </select>\n    </div>\n  </div>\n</div>\n'},561:function(module,exports){module.exports="h2 {\n  font-size: 18px; }\n"},98:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.d(__webpack_exports__,"a",function(){return SpeechSynthesisDemoComponent});var tslib__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(3),_angular_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1),_projects_speech_synthesis_src_public_api__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(26),rxjs__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(125),SpeechSynthesisDemoComponent=function(){function SpeechSynthesisDemoComponent(f,svc){this.f=f,this.svc=svc,this.content="",this.lang="",this.setting=!1,this.utterance=new _angular_core__WEBPACK_IMPORTED_MODULE_1__.EventEmitter}var _a,_b;return SpeechSynthesisDemoComponent.prototype.ngOnChanges=function(_){this.f.lang=this.lang},Object.defineProperty(SpeechSynthesisDemoComponent.prototype,"contentTexts",{get:function(){return this.content.split("\n")},enumerable:!0,configurable:!0}),SpeechSynthesisDemoComponent.prototype.ngOnInit=function(){},SpeechSynthesisDemoComponent.prototype.speech=function(){for(var _i=0,_a=this.contentTexts;_i<_a.length;_i++){var text=_a[_i],v=this.f.text(text);this.utterance.emit(v),this.svc.speak(this.f.text(text))}},SpeechSynthesisDemoComponent.prototype.cancel=function(){this.svc.cancel()},SpeechSynthesisDemoComponent.prototype.pause=function(){this.svc.pause()},SpeechSynthesisDemoComponent.prototype.resume=function(){this.svc.resume()},SpeechSynthesisDemoComponent.prototype.getVoices$=function(){var _this=this,sub=new rxjs__WEBPACK_IMPORTED_MODULE_3__.ReplaySubject(1);return sub.next(this.svc.getVoices()),this.svc.onvoiceschanged=function(){return sub.next(_this.svc.getVoices())},sub.asObservable()},tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__.Input)(),tslib__WEBPACK_IMPORTED_MODULE_0__.__metadata("design:type",Object)],SpeechSynthesisDemoComponent.prototype,"content",void 0),tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__.Input)(),tslib__WEBPACK_IMPORTED_MODULE_0__.__metadata("design:type",Object)],SpeechSynthesisDemoComponent.prototype,"lang",void 0),tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__.Input)(),tslib__WEBPACK_IMPORTED_MODULE_0__.__metadata("design:type",Object)],SpeechSynthesisDemoComponent.prototype,"setting",void 0),tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__.Output)(),tslib__WEBPACK_IMPORTED_MODULE_0__.__metadata("design:type",Object)],SpeechSynthesisDemoComponent.prototype,"utterance",void 0),SpeechSynthesisDemoComponent=tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__.Component)({selector:"app-speech-synthesis-demo",template:__webpack_require__(560),styles:[__webpack_require__(561)],providers:[_projects_speech_synthesis_src_public_api__WEBPACK_IMPORTED_MODULE_2__.e]}),tslib__WEBPACK_IMPORTED_MODULE_0__.__metadata("design:paramtypes",["function"==typeof(_a=void 0!==_projects_speech_synthesis_src_public_api__WEBPACK_IMPORTED_MODULE_2__.e&&_projects_speech_synthesis_src_public_api__WEBPACK_IMPORTED_MODULE_2__.e)?_a:Object,"function"==typeof(_b=void 0!==_projects_speech_synthesis_src_public_api__WEBPACK_IMPORTED_MODULE_2__.d&&_projects_speech_synthesis_src_public_api__WEBPACK_IMPORTED_MODULE_2__.d)?_b:Object])],SpeechSynthesisDemoComponent)}()}},[[288,1,2]]]);
//# sourceMappingURL=main.dce54f8eee00a2ababb9.bundle.js.map