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CAAC;gBAEX,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK9D;AAGD,qBAAa,MAAM;IACR,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;gBAEX,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAKnE;AAED,MAAM,WAAW,kBAAkB;IAC/B,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,QAAQ,CAAC,EAAE,wBAAwB,CAAC;CACvC;AAED,MAAM,WAAW,wBAAwB;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,YAAY,CAAC;IAC3B,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,oBAAY,YAAY;IACpB,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,OAAO,YAAY;CACtB;AAED,oBAAY,IAAI;IACZ,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,aAAa,kBAAkB;IAC/B,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,MAAM,WAAW;CACpB","file":"RecognizerConfig.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { PropertyCollection } from \"../sdk/Exports\";\n\nexport enum RecognitionMode {\n Interactive,\n Conversation,\n Dictation,\n}\n\nexport enum SpeechResultFormat {\n Simple,\n Detailed,\n}\n\nexport class RecognizerConfig {\n private privRecognitionMode: RecognitionMode = RecognitionMode.Interactive;\n private privSpeechServiceConfig: SpeechServiceConfig;\n private privRecognitionActivityTimeout: number;\n private privParameters: PropertyCollection;\n\n constructor(\n speechServiceConfig: SpeechServiceConfig,\n parameters: PropertyCollection) {\n this.privSpeechServiceConfig = speechServiceConfig ? speechServiceConfig : new SpeechServiceConfig(new Context(null));\n this.privParameters = parameters;\n }\n\n public get parameters(): PropertyCollection {\n return this.privParameters;\n }\n\n public get recognitionMode(): RecognitionMode {\n return this.privRecognitionMode;\n }\n\n public set recognitionMode(value: RecognitionMode) {\n this.privRecognitionMode = value;\n this.privRecognitionActivityTimeout = value === RecognitionMode.Interactive ? 8000 : 25000;\n this.privSpeechServiceConfig.Recognition = RecognitionMode[value];\n }\n\n public get SpeechServiceConfig(): SpeechServiceConfig {\n return this.privSpeechServiceConfig;\n }\n\n public get recognitionActivityTimeout(): number {\n return this.privRecognitionActivityTimeout;\n }\n\n public get isContinuousRecognition(): boolean {\n return this.privRecognitionMode !== RecognitionMode.Interactive;\n }\n}\n\n// The config is serialized and sent as the Speech.Config\n// tslint:disable-next-line:max-classes-per-file\nexport class SpeechServiceConfig {\n private context: Context;\n private recognition: string;\n\n constructor(context: Context) {\n this.context = context;\n }\n\n public serialize = (): string => {\n return JSON.stringify(this, (key: any, value: any): any => {\n if (value && typeof value === \"object\") {\n const replacement: any = {};\n for (const k in value) {\n if (Object.hasOwnProperty.call(value, k)) {\n replacement[k && k.charAt(0).toLowerCase() + k.substring(1)] = value[k];\n }\n }\n return replacement;\n }\n return value;\n });\n }\n\n public get Context(): Context {\n return this.context;\n }\n\n public get Recognition(): string {\n return this.recognition;\n }\n\n public set Recognition(value: string) {\n this.recognition = value.toLowerCase();\n }\n}\n\n// tslint:disable-next-line:max-classes-per-file\nexport class Context {\n public system: System;\n public os: OS;\n public audio: ISpeechConfigAudio;\n\n constructor(os: OS) {\n this.system = new System();\n this.os = os;\n }\n}\n\n// tslint:disable-next-line:max-classes-per-file\nexport class System {\n public name: string;\n public version: string;\n public build: string;\n public lang: string;\n\n constructor() {\n // Note: below will be patched for official builds.\n const SPEECHSDK_CLIENTSDK_VERSION = \"1.6.0-alpha.0.1\";\n\n this.name = \"SpeechSDK\";\n this.version = SPEECHSDK_CLIENTSDK_VERSION;\n this.build = \"JavaScript\";\n this.lang = \"JavaScript\";\n }\n}\n\n// tslint:disable-next-line:max-classes-per-file\nexport class OS {\n public platform: string;\n public name: string;\n public version: string;\n\n constructor(platform: string, name: string, version: string) {\n this.platform = platform;\n this.name = name;\n this.version = version;\n }\n}\n\n// tslint:disable-next-line:max-classes-per-file\nexport class Device {\n public manufacturer: string;\n public model: string;\n public version: string;\n\n constructor(manufacturer: string, model: string, version: string) {\n this.manufacturer = manufacturer;\n this.model = model;\n this.version = version;\n }\n}\n\nexport interface ISpeechConfigAudio {\n source?: ISpeechConfigAudioDevice;\n playback?: ISpeechConfigAudioDevice;\n}\n\nexport interface ISpeechConfigAudioDevice {\n manufacturer: string;\n model: string;\n connectivity: connectivity;\n type: type;\n samplerate: number;\n bitspersample: number;\n channelcount: number;\n}\n\nexport enum connectivity {\n Bluetooth = \"Bluetooth\",\n Wired = \"Wired\",\n WiFi = \"WiFi\",\n Cellular = \"Cellular\",\n InBuilt = \"InBuilt\",\n Unknown = \"Unknown\",\n}\n\nexport enum type {\n Phone = \"Phone\",\n Speaker = \"Speaker\",\n Car = \"Car\",\n Headset = \"Headset\",\n Thermostat = \"Thermostat\",\n Microphones = \"Microphones\",\n Deskphone = \"Deskphone\",\n RemoteControl = \"RemoteControl\",\n Unknown = \"Unknown\",\n File = \"File\",\n Stream = \"Stream\",\n}\n"]}