use base Recognizer to pass along agent
This commit is contained in:
Родитель
a8d5c124a4
Коммит
740c7c10db
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import * as http from "http";
|
||||
import {
|
||||
ArgumentNullError,
|
||||
ConnectionEvent,
|
||||
|
@ -32,7 +31,7 @@ export class WebsocketConnection implements IConnection {
|
|||
messageFormatter: IWebsocketMessageFormatter,
|
||||
proxyInfo: ProxyInfo,
|
||||
enableCompression: boolean = false,
|
||||
agent: http.Agent,
|
||||
agent: object,
|
||||
connectionId?: string) {
|
||||
|
||||
if (!uri) {
|
||||
|
|
|
@ -68,7 +68,7 @@ export class WebsocketMessageAdapter {
|
|||
messageFormatter: IWebsocketMessageFormatter,
|
||||
proxyInfo: ProxyInfo,
|
||||
headers: { [key: string]: string },
|
||||
agent: http.Agent,
|
||||
agent: object,
|
||||
enableCompression: boolean) {
|
||||
|
||||
if (!uri) {
|
||||
|
@ -87,7 +87,7 @@ export class WebsocketMessageAdapter {
|
|||
this.privUri = uri;
|
||||
this.privHeaders = headers;
|
||||
this.privEnableCompression = enableCompression;
|
||||
this.privAgent = agent;
|
||||
this.privAgent = agent as http.Agent;
|
||||
|
||||
// Add the connection ID to the headers
|
||||
this.privHeaders[HeaderNames.ConnectionId] = this.privConnectionId;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import * as http from "http";
|
||||
import {
|
||||
ServicePropertiesPropertyName,
|
||||
} from "../common.speech/Exports";
|
||||
|
@ -11,13 +10,6 @@ import { AuthInfo, IConnectionFactory, RecognizerConfig } from "./Exports";
|
|||
import { QueryParameterNames } from "./QueryParameterNames";
|
||||
|
||||
export abstract class ConnectionFactoryBase implements IConnectionFactory {
|
||||
|
||||
protected privAgent: http.Agent;
|
||||
|
||||
public constructor(agent: http.Agent) {
|
||||
this.privAgent = agent;
|
||||
}
|
||||
|
||||
public static getHostSuffix(region: string): string {
|
||||
if (!!region) {
|
||||
if (region.toLowerCase().startsWith("china")) {
|
||||
|
@ -33,6 +25,7 @@ export abstract class ConnectionFactoryBase implements IConnectionFactory {
|
|||
public abstract create(
|
||||
config: RecognizerConfig,
|
||||
authInfo: AuthInfo,
|
||||
agent: object,
|
||||
connectionId?: string): IConnection;
|
||||
|
||||
protected setCommonUrlParams(
|
||||
|
|
|
@ -22,6 +22,7 @@ export class DialogConnectionFactory extends ConnectionFactoryBase {
|
|||
public create(
|
||||
config: RecognizerConfig,
|
||||
authInfo: AuthInfo,
|
||||
agent: object,
|
||||
connectionId?: string): IConnection {
|
||||
|
||||
const applicationId: string = config.parameters.getProperty(PropertyId.Conversation_ApplicationId, "");
|
||||
|
@ -73,6 +74,6 @@ export class DialogConnectionFactory extends ConnectionFactoryBase {
|
|||
this.setCommonUrlParams(config, queryParams, endpoint);
|
||||
|
||||
const enableCompression: boolean = config.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true";
|
||||
return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, this.privAgent, connectionId);
|
||||
return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, agent, connectionId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,5 +9,6 @@ export interface IConnectionFactory {
|
|||
create(
|
||||
config: RecognizerConfig,
|
||||
authInfo: AuthInfo,
|
||||
agent: object,
|
||||
connectionId?: string): IConnection;
|
||||
}
|
||||
|
|
|
@ -9,5 +9,6 @@ export interface ISynthesisConnectionFactory {
|
|||
create(
|
||||
config: SynthesizerConfig,
|
||||
authInfo: AuthInfo,
|
||||
agent: object,
|
||||
connectionId?: string): IConnection;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ export class IntentConnectionFactory extends ConnectionFactoryBase {
|
|||
public create(
|
||||
config: RecognizerConfig,
|
||||
authInfo: AuthInfo,
|
||||
agent: object,
|
||||
connectionId?: string): IConnection {
|
||||
|
||||
let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint);
|
||||
|
@ -53,7 +54,7 @@ export class IntentConnectionFactory extends ConnectionFactoryBase {
|
|||
config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);
|
||||
|
||||
const enableCompression: boolean = config.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true";
|
||||
return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, this.privAgent, connectionId);
|
||||
return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, agent, connectionId);
|
||||
}
|
||||
|
||||
private getSpeechRegionFromIntentRegion(intentRegion: string): string {
|
||||
|
|
|
@ -748,7 +748,7 @@ export abstract class ServiceRecognizerBase implements IDisposable {
|
|||
await this.privRequestSession.onAuthCompleted(false);
|
||||
|
||||
// Create the connection
|
||||
const connection: IConnection = this.privConnectionFactory.create(this.privRecognizerConfig, auth, this.privConnectionId);
|
||||
const connection: IConnection = this.privConnectionFactory.create(this.privRecognizerConfig, auth, this.privRecognizer.internalAgent, this.privConnectionId);
|
||||
// Attach the telemetry handlers.
|
||||
this.privRequestSession.listenForServiceTelemetry(connection.events);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ class SpeakerRecognitionConnectionFactoryBase extends ConnectionFactoryBase {
|
|||
public create(
|
||||
config: RecognizerConfig,
|
||||
authInfo: AuthInfo,
|
||||
agent: object,
|
||||
endpointPath: string,
|
||||
connectionId?: string): IConnection {
|
||||
|
||||
|
@ -58,7 +59,7 @@ class SpeakerRecognitionConnectionFactoryBase extends ConnectionFactoryBase {
|
|||
config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);
|
||||
|
||||
const enableCompression: boolean = config.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true";
|
||||
return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, this.privAgent, connectionId);
|
||||
return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, agent, connectionId);
|
||||
}
|
||||
|
||||
private scenarioToPath(mode: string): string {
|
||||
|
@ -76,14 +77,14 @@ class SpeakerRecognitionConnectionFactoryBase extends ConnectionFactoryBase {
|
|||
}
|
||||
|
||||
export class SpeakerRecognitionConnectionFactory extends SpeakerRecognitionConnectionFactoryBase {
|
||||
public create( config: RecognizerConfig, authInfo: AuthInfo, connectionId?: string): IConnection {
|
||||
return super.create(config, authInfo, "recognition", connectionId);
|
||||
public create( config: RecognizerConfig, authInfo: AuthInfo, agent: object, connectionId?: string): IConnection {
|
||||
return super.create(config, authInfo, agent, "recognition", connectionId);
|
||||
}
|
||||
}
|
||||
|
||||
export class VoiceProfileConnectionFactory extends SpeakerRecognitionConnectionFactoryBase {
|
||||
public create( config: RecognizerConfig, authInfo: AuthInfo, connectionId?: string): IConnection {
|
||||
return super.create(config, authInfo, "profile", connectionId);
|
||||
public create( config: RecognizerConfig, authInfo: AuthInfo, agent: object, connectionId?: string): IConnection {
|
||||
return super.create(config, authInfo, agent, "profile", connectionId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ export class SpeechConnectionFactory extends ConnectionFactoryBase {
|
|||
public create(
|
||||
config: RecognizerConfig,
|
||||
authInfo: AuthInfo,
|
||||
agent: object,
|
||||
connectionId?: string): IConnection {
|
||||
|
||||
let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint, undefined);
|
||||
|
@ -107,7 +108,7 @@ export class SpeechConnectionFactory extends ConnectionFactoryBase {
|
|||
|
||||
const enableCompression: boolean = config.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true";
|
||||
|
||||
const webSocketConnection = new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, this.privAgent, connectionId);
|
||||
const webSocketConnection = new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, agent, connectionId);
|
||||
|
||||
// Set the value of SpeechServiceConnection_Url to webSocketConnection.uri (and not to `endpoint`), since this value is the final
|
||||
// URI that was used to make the connection (including query parameters).
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import * as http from "http";
|
||||
import {
|
||||
ProxyInfo,
|
||||
WebsocketConnection
|
||||
|
@ -26,15 +25,10 @@ import {
|
|||
export class SpeechSynthesisConnectionFactory implements ISynthesisConnectionFactory {
|
||||
|
||||
private readonly synthesisUri: string = "/cognitiveservices/websocket/v1";
|
||||
private privAgent: http.Agent;
|
||||
|
||||
public constructor(agent: http.Agent) {
|
||||
this.privAgent = agent;
|
||||
}
|
||||
|
||||
public create(
|
||||
config: SynthesizerConfig,
|
||||
authInfo: AuthInfo,
|
||||
agent: object,
|
||||
connectionId?: string): IConnection {
|
||||
|
||||
let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint, undefined);
|
||||
|
@ -62,6 +56,6 @@ export class SpeechSynthesisConnectionFactory implements ISynthesisConnectionFac
|
|||
config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);
|
||||
|
||||
const enableCompression: boolean = config.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true";
|
||||
return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromParameters(config.parameters), enableCompression, this.privAgent, connectionId);
|
||||
return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromParameters(config.parameters), enableCompression, agent, connectionId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -512,7 +512,7 @@ export class SynthesisAdapterBase implements IDisposable {
|
|||
this.privConnectionPromise = authPromise.then(async (result: AuthInfo): Promise<IConnection> => {
|
||||
this.privSynthesisTurn.onAuthCompleted(false);
|
||||
|
||||
const connection: IConnection = this.privConnectionFactory.create(this.privSynthesizerConfig, result, this.privConnectionId);
|
||||
const connection: IConnection = this.privConnectionFactory.create(this.privSynthesizerConfig, result, this.privSpeechSynthesizer.internalAgent, this.privConnectionId);
|
||||
|
||||
// Attach to the underlying event. No need to hold onto the detach pointers as in the event the connection goes away,
|
||||
// it'll stop sending events.
|
||||
|
|
|
@ -34,6 +34,7 @@ export class TranscriberConnectionFactory extends ConnectionFactoryBase {
|
|||
public create(
|
||||
config: RecognizerConfig,
|
||||
authInfo: AuthInfo,
|
||||
agent: object,
|
||||
connectionId?: string): IConnection {
|
||||
|
||||
let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint, undefined);
|
||||
|
@ -58,7 +59,7 @@ export class TranscriberConnectionFactory extends ConnectionFactoryBase {
|
|||
config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);
|
||||
|
||||
const enableCompression: boolean = config.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true";
|
||||
return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, this.privAgent, connectionId);
|
||||
return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, agent, connectionId);
|
||||
}
|
||||
|
||||
public setQueryParams(queryParams: IStringDictionary<string>, config: RecognizerConfig, endpointUrl: string): void {
|
||||
|
|
|
@ -16,7 +16,7 @@ import { ConversationWebsocketMessageFormatter } from "./ConversationWebsocketMe
|
|||
*/
|
||||
export class ConversationConnectionFactory extends ConnectionFactoryBase {
|
||||
|
||||
public create(config: RecognizerConfig, authInfo: AuthInfo, connectionId?: string): IConnection {
|
||||
public create(config: RecognizerConfig, authInfo: AuthInfo, agent: object, connectionId?: string): IConnection {
|
||||
|
||||
const endpointHost: string = config.parameters.getProperty(PropertyId.ConversationTranslator_Host, ConversationConnectionConfig.host);
|
||||
const correlationId: string = config.parameters.getProperty(PropertyId.ConversationTranslator_CorrelationId, createGuid());
|
||||
|
@ -30,7 +30,7 @@ export class ConversationConnectionFactory extends ConnectionFactoryBase {
|
|||
queryParams[ConversationConnectionConfig.configParams.token] = token;
|
||||
queryParams[ConversationConnectionConfig.configParams.correlationId] = correlationId;
|
||||
const enableCompression: boolean = config.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true";
|
||||
return new WebsocketConnection(endpoint, queryParams, {}, new ConversationWebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, this.privAgent, connectionId);
|
||||
return new WebsocketConnection(endpoint, queryParams, {}, new ConversationWebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, agent, connectionId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import * as http from "http";
|
||||
import {
|
||||
ProxyInfo,
|
||||
RestConfigBase,
|
||||
|
@ -42,14 +41,14 @@ export class ConversationTranslatorConnectionFactory extends ConnectionFactoryBa
|
|||
|
||||
private privConvGetter: () => ConversationImpl;
|
||||
|
||||
public constructor(convGetter: () => ConversationImpl, agent: http.Agent) {
|
||||
super(agent);
|
||||
public constructor(convGetter: () => ConversationImpl) {
|
||||
super();
|
||||
|
||||
Contracts.throwIfNullOrUndefined(convGetter, "convGetter");
|
||||
this.privConvGetter = convGetter;
|
||||
}
|
||||
|
||||
public create(config: RecognizerConfig, authInfo: AuthInfo, connectionId?: string): IConnection {
|
||||
public create(config: RecognizerConfig, authInfo: AuthInfo, agent: object, connectionId?: string): IConnection {
|
||||
const isVirtMicArrayEndpoint = config.parameters.getProperty("ConversationTranslator_MultiChannelAudio", "").toUpperCase() === "TRUE";
|
||||
|
||||
const convInfo = this.privConvGetter().room;
|
||||
|
@ -89,7 +88,7 @@ export class ConversationTranslatorConnectionFactory extends ConnectionFactoryBa
|
|||
queryParams[key] = val;
|
||||
});
|
||||
|
||||
const connFactory = new TranscriberConnectionFactory(this.privAgent);
|
||||
const connFactory = new TranscriberConnectionFactory();
|
||||
connFactory.setQueryParams(queryParams, config, endpointUrl);
|
||||
|
||||
// Some query parameters are required for the CTS endpoint, let's explicity set them here
|
||||
|
@ -112,7 +111,7 @@ export class ConversationTranslatorConnectionFactory extends ConnectionFactoryBa
|
|||
|
||||
} else {
|
||||
// connecting to regular translation endpoint
|
||||
const connFactory = new TranslationConnectionFactory(this.privAgent);
|
||||
const connFactory = new TranslationConnectionFactory();
|
||||
|
||||
endpointUrl = connFactory.getEndpointUrl(config, true);
|
||||
endpointUrl = StringUtils.formatString(endpointUrl, replacementValues);
|
||||
|
@ -127,6 +126,6 @@ export class ConversationTranslatorConnectionFactory extends ConnectionFactoryBa
|
|||
}
|
||||
|
||||
const enableCompression = config.parameters.getProperty("SPEECH-EnableWebsocketCompression", "").toUpperCase() === "TRUE";
|
||||
return new WebsocketConnection(endpointUrl, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, this.privAgent, connectionId);
|
||||
return new WebsocketConnection(endpointUrl, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, agent, connectionId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ export class ConversationTranslatorRecognizer extends Recognizer implements Conv
|
|||
const conversationImpl = conversation as ConversationImpl;
|
||||
Contracts.throwIfNull(conversationImpl, "conversationImpl");
|
||||
|
||||
super(audioConfig, serviceConfigImpl.properties, new ConversationConnectionFactory(serviceConfigImpl.agent));
|
||||
super(audioConfig, serviceConfigImpl.properties, new ConversationConnectionFactory(), serviceConfigImpl.agent);
|
||||
|
||||
this.privConversation = conversationImpl;
|
||||
this.privIsDisposed = false;
|
||||
|
|
|
@ -58,7 +58,7 @@ export class TranscriberRecognizer extends Recognizer {
|
|||
speechTranslationConfigImpl.speechRecognitionLanguage,
|
||||
PropertyId[PropertyId.SpeechServiceConnection_RecoLanguage]);
|
||||
|
||||
super(audioConfig, speechTranslationConfigImpl.properties, new TranscriberConnectionFactory(speechTranslationConfig.agent));
|
||||
super(audioConfig, speechTranslationConfigImpl.properties, new TranscriberConnectionFactory(), speechTranslationConfig.agent);
|
||||
this.privDisposedRecognizer = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ export class TranslationConnectionFactory extends ConnectionFactoryBase {
|
|||
public create(
|
||||
config: RecognizerConfig,
|
||||
authInfo: AuthInfo,
|
||||
agent: object,
|
||||
connectionId?: string): IConnection {
|
||||
|
||||
const endpoint: string = this.getEndpointUrl(config);
|
||||
|
@ -45,7 +46,7 @@ export class TranslationConnectionFactory extends ConnectionFactoryBase {
|
|||
config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);
|
||||
|
||||
const enableCompression: boolean = config.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true";
|
||||
return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, this.privAgent, connectionId);
|
||||
return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, agent, connectionId);
|
||||
}
|
||||
|
||||
public getEndpointUrl(config: RecognizerConfig, returnRegionPlaceholder?: boolean): string {
|
||||
|
|
|
@ -49,7 +49,7 @@ export class DialogServiceConnector extends Recognizer {
|
|||
const dialogServiceConfigImpl = dialogConfig as DialogServiceConfigImpl;
|
||||
Contracts.throwIfNull(dialogConfig, "dialogConfig");
|
||||
|
||||
super(audioConfig, dialogServiceConfigImpl.properties, new DialogConnectionFactory(dialogServiceConfigImpl.agent));
|
||||
super(audioConfig, dialogServiceConfigImpl.properties, new DialogConnectionFactory(), dialogServiceConfigImpl.agent);
|
||||
|
||||
this.isTurnComplete = true;
|
||||
this.privIsDisposed = false;
|
||||
|
|
|
@ -51,7 +51,7 @@ export class IntentRecognizer extends Recognizer {
|
|||
const configImpl: SpeechConfigImpl = speechConfig as SpeechConfigImpl;
|
||||
Contracts.throwIfNullOrUndefined(configImpl, "speechConfig");
|
||||
|
||||
super(audioConfig, configImpl.properties, new IntentConnectionFactory(configImpl.agent));
|
||||
super(audioConfig, configImpl.properties, new IntentConnectionFactory(), configImpl.agent);
|
||||
this.privAddedIntents = [];
|
||||
this.privAddedLmIntents = {};
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ export abstract class Recognizer {
|
|||
protected audioConfig: AudioConfig;
|
||||
protected privReco: ServiceRecognizerBase;
|
||||
protected privProperties: PropertyCollection;
|
||||
private privAgent: object;
|
||||
private privConnectionFactory: IConnectionFactory;
|
||||
|
||||
/**
|
||||
|
@ -45,11 +46,12 @@ export abstract class Recognizer {
|
|||
* @constructor
|
||||
* @param {AudioConfig} audioInput - An optional audio input stream associated with the recognizer
|
||||
*/
|
||||
protected constructor(audioConfig: AudioConfig, properties: PropertyCollection, connectionFactory: IConnectionFactory) {
|
||||
protected constructor(audioConfig: AudioConfig, properties: PropertyCollection, connectionFactory: IConnectionFactory, agent: object) {
|
||||
this.audioConfig = (audioConfig !== undefined) ? audioConfig : AudioConfig.fromDefaultMicrophoneInput();
|
||||
this.privDisposed = false;
|
||||
this.privProperties = properties.clone();
|
||||
this.privConnectionFactory = connectionFactory;
|
||||
this.privAgent = agent;
|
||||
this.implCommonRecognizerSetup();
|
||||
}
|
||||
|
||||
|
@ -96,6 +98,15 @@ export abstract class Recognizer {
|
|||
marshalPromiseToCallbacks(this.dispose(true), cb, errorCb);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Internal
|
||||
* Internal data member to support advanced agent setting scenarios.
|
||||
* Do not use externally, object returned will change without warning or notice.
|
||||
*/
|
||||
public get internalAgent(): object {
|
||||
return this.privAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Internal
|
||||
* Internal data member to support fromRecognizer* pattern methods on other classes.
|
||||
|
|
|
@ -43,7 +43,7 @@ export class SpeakerRecognizer extends Recognizer {
|
|||
const configImpl: SpeechConfigImpl = speechConfig as SpeechConfigImpl;
|
||||
Contracts.throwIfNullOrUndefined(configImpl, "speechConfig");
|
||||
|
||||
super(audioConfig, configImpl.properties, new SpeakerRecognitionConnectionFactory(configImpl.agent));
|
||||
super(audioConfig, configImpl.properties, new SpeakerRecognitionConnectionFactory(), configImpl.agent);
|
||||
this.privAudioConfigImpl = audioConfig as AudioConfigImpl;
|
||||
Contracts.throwIfNull(this.privAudioConfigImpl, "audioConfig");
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ export class SpeechRecognizer extends Recognizer {
|
|||
speechConfigImpl.properties.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage),
|
||||
PropertyId[PropertyId.SpeechServiceConnection_RecoLanguage]);
|
||||
|
||||
super(audioConfig, speechConfigImpl.properties, new SpeechConnectionFactory(speechConfigImpl.agent));
|
||||
super(audioConfig, speechConfigImpl.properties, new SpeechConnectionFactory(), speechConfigImpl.agent);
|
||||
this.privDisposedRecognizer = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ export class SpeechSynthesizer {
|
|||
protected privRestAdapter: SynthesisRestAdapter;
|
||||
protected privProperties: PropertyCollection;
|
||||
protected synthesisRequestQueue: Queue<SynthesisRequest>;
|
||||
protected privAgent: object;
|
||||
|
||||
/**
|
||||
* Defines event handler for synthesis start events.
|
||||
|
@ -194,8 +195,9 @@ export class SpeechSynthesizer {
|
|||
this.privProperties = speechConfigImpl.properties.clone();
|
||||
this.privDisposed = false;
|
||||
this.privSynthesizing = false;
|
||||
this.privConnectionFactory = new SpeechSynthesisConnectionFactory(speechConfig.agent);
|
||||
this.privConnectionFactory = new SpeechSynthesisConnectionFactory();
|
||||
this.synthesisRequestQueue = new Queue<SynthesisRequest>();
|
||||
this.privAgent = speechConfigImpl.agent;
|
||||
this.implCommonSynthesizeSetup();
|
||||
}
|
||||
|
||||
|
@ -416,6 +418,17 @@ export class SpeechSynthesizer {
|
|||
marshalPromiseToCallbacks(this.dispose(true), cb, err);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Internal
|
||||
* Do not use externally, object returned will change without warning or notice.
|
||||
*/
|
||||
public get internalAgent(): object {
|
||||
return this.privAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method performs cleanup of resources.
|
||||
* The Boolean parameter disposing indicates whether the method is called
|
||||
/**
|
||||
* @Internal
|
||||
* Do not use externally, object returned will change without warning or notice.
|
||||
|
|
|
@ -53,7 +53,7 @@ class ConversationTranslationRecognizer extends TranslationRecognizer {
|
|||
|
||||
public constructor(speechConfig: SpeechTranslationConfig, audioConfig: AudioConfig, translator: ConversationTranslator, convGetter: () => ConversationImpl) {
|
||||
|
||||
super(speechConfig, audioConfig, new ConversationTranslatorConnectionFactory(convGetter, speechConfig.agent));
|
||||
super(speechConfig, audioConfig, new ConversationTranslatorConnectionFactory(convGetter));
|
||||
|
||||
this.privSpeechState = SpeechState.Inactive;
|
||||
if (!!translator) {
|
||||
|
|
|
@ -77,7 +77,7 @@ export class TranslationRecognizer extends Recognizer {
|
|||
const configImpl = speechConfig as SpeechTranslationConfigImpl;
|
||||
Contracts.throwIfNull(configImpl, "speechConfig");
|
||||
|
||||
super(audioConfig, configImpl.properties, connectionFactory || new TranslationConnectionFactory(configImpl.agent));
|
||||
super(audioConfig, configImpl.properties, connectionFactory || new TranslationConnectionFactory(), configImpl.agent);
|
||||
|
||||
this.privDisposedTranslationRecognizer = false;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ export class VoiceProfileClient extends Recognizer {
|
|||
const speechConfigImpl: SpeechConfigImpl = speechConfig as SpeechConfigImpl;
|
||||
Contracts.throwIfNull(speechConfigImpl, "speechConfig");
|
||||
|
||||
super(AudioConfig.fromStreamInput(AudioInputStream.createPushStream()), speechConfigImpl.properties, new VoiceProfileConnectionFactory(speechConfigImpl.agent));
|
||||
super(AudioConfig.fromStreamInput(AudioInputStream.createPushStream()), speechConfigImpl.properties, new VoiceProfileConnectionFactory(), speechConfigImpl.agent);
|
||||
|
||||
this.privProperties = speechConfigImpl.properties.clone();
|
||||
this.privVoiceAdapter = this.privReco as VoiceServiceRecognizer;
|
||||
|
|
Загрузка…
Ссылка в новой задаче