UNPKG

@voice-ping/cognitive-services-speech

Version:

VoicePing Cognitive Services Speech SDK for JavaScript forked from Microsoft

1 lines 12.4 kB
{"version":3,"sources":["src/common.speech/Transcription/ConversationTranslatorInterfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAGH,wCAAwC,EAExC,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACH,wCAAwC,EACxC,iBAAiB,EACjB,gBAAgB,EAChB,6BAA6B,EAC7B,oBAAoB,EACpB,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAElC,wBAAwB,EAAE,MAAM,CAAC;IAEjC,qBAAqB,EAAE,MAAM,CAAC;IAE9B,aAAa,EAAE,MAAM,CAAC;IAEtB,IAAI,EAAE,MAAM,CAAC;IAEb,WAAW,EAAE,MAAM,CAAC;IAEpB,WAAW,EAAE,MAAM,CAAC;IAEpB,UAAU,EAAE,MAAM,CAAC;IAEnB,UAAU,EAAE,OAAO,CAAC;IAEpB,OAAO,EAAE,OAAO,CAAC;IAEjB,MAAM,EAAE,MAAM,CAAC;IAEf,MAAM,EAAE,MAAM,CAAC;IAEf,KAAK,EAAE,MAAM,CAAC;IAEd,aAAa,EAAE,MAAM,CAAC;IAEtB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,8CAA8C;AAC9C,qBAAa,oBAAoB;IAEV,YAAY,EAAE,oBAAoB,EAAE;IAAc,IAAI,CAAC,EAAE,MAAM;gBAA/D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M,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,eAAe;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,eAAe;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;CAQ9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;CAe9C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACnB","file":"ConversationTranslatorInterfaces.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport {\n ConversationExpirationEventArgs,\n ConversationParticipantsChangedEventArgs,\n ConversationTranslationCanceledEventArgs,\n ConversationTranslationEventArgs,\n SessionEventArgs } from \"../../sdk/Exports\";\n// import { ConversationClient } from \"./ConversationConnection\";\nimport {\n ConversationReceivedTranslationEventArgs,\n LockRoomEventArgs,\n MuteAllEventArgs,\n ParticipantAttributeEventArgs,\n ParticipantEventArgs,\n ParticipantsListEventArgs } from \"./ConversationTranslatorEventArgs\";\n\n/**\n * Internal conversation data\n */\nexport interface IInternalConversation {\n // the token to use for connecting to the Speech Service\n cognitiveSpeechAuthToken: string;\n // the region to use for connecting to the Speech Service\n cognitiveSpeechRegion: string;\n // the unique id of the user who started or joined the Conversation\n participantId: string;\n // a descriptive name for the Conversation\n name: string;\n // a descriptive name for the Conversation\n description: string;\n // the speech model ID for custom speech\n speechModel: string;\n // represents the level of speech supported in the Conversation (0: everyone can speak, 2: only host can speak, 3: no-one can speak)\n modalities: number;\n // ?\n isApproved: boolean;\n // the mute flag has been set at conversation level and only the host can speak\n isMuted: boolean;\n // the 5 character conversation Id\n roomId: string;\n // the hex color string to represent a user. If there are many users this hex color may be reused (?).\n avatar: string;\n // the token to use when calling the websocket\n token: string;\n // used for tracking the session and help with troubleshooting problems in the logs\n correlationId: string;\n // extracted from the headers\n requestId: string;\n}\n\n/**\n * The user who is participating in the conversation.\n */\nexport interface IInternalParticipant {\n avatar?: string;\n displayName?: string;\n id?: string;\n isHost?: boolean;\n isMuted?: boolean;\n isUsingTts?: boolean;\n preferredLanguage?: string;\n}\n\n/** Users participating in the conversation */\nexport class InternalParticipants {\n\n constructor(public participants: IInternalParticipant[] = [], public meId?: string) {\n\n }\n\n /**\n * Add or update a participant\n * @param value\n */\n public addOrUpdateParticipant(value: IInternalParticipant): IInternalParticipant {\n if (value === undefined) {\n return;\n }\n\n const exists: number = this.getParticipantIndex(value.id);\n if (exists > -1) {\n this.participants.splice(exists, 1, value);\n } else {\n this.participants.push(value);\n }\n\n // ensure it was added ok\n return this.getParticipant(value.id);\n }\n\n /**\n * Find the participant's position in the participants list.\n * @param id\n */\n public getParticipantIndex(id: string): number {\n return this.participants.findIndex((p: IInternalParticipant) => p.id === id);\n }\n\n /**\n * Find the participant by id.\n * @param id\n */\n public getParticipant(id: string): IInternalParticipant {\n return this.participants.find((p: IInternalParticipant) => p.id === id);\n }\n\n /***\n * Remove a participant from the participants list.\n */\n public deleteParticipant(id: string): void {\n this.participants = this.participants.filter((p: IInternalParticipant) => p.id !== id);\n }\n\n /***\n * Helper to return the conversation host.\n */\n public get host(): IInternalParticipant {\n return this.participants.find((p: IInternalParticipant) => p.isHost === true );\n }\n\n /**\n * Helper to return the current user.\n */\n public get me(): IInternalParticipant {\n return this.getParticipant(this.meId);\n }\n}\n\n/**\n * Recognizer for handling Conversation Translator websocket messages\n */\nexport interface IConversationTranslatorRecognizer {\n canceled: (sender: IConversationTranslatorRecognizer, event: ConversationTranslationCanceledEventArgs) => void;\n connectionOpened: (sender: IConversationTranslatorRecognizer, event: SessionEventArgs) => void;\n connectionClosed: (sender: IConversationTranslatorRecognizer, event: SessionEventArgs) => void;\n participantsListReceived: (sender: IConversationTranslatorRecognizer, event: ParticipantsListEventArgs) => void;\n translationReceived: (sender: IConversationTranslatorRecognizer, event: ConversationReceivedTranslationEventArgs) => void;\n lockRoomCommandReceived: (sender: IConversationTranslatorRecognizer, event: LockRoomEventArgs) => void;\n muteAllCommandReceived: (sender: IConversationTranslatorRecognizer, event: MuteAllEventArgs) => void;\n participantJoinCommandReceived: (sender: IConversationTranslatorRecognizer, event: ParticipantEventArgs) => void;\n participantLeaveCommandReceived: (sender: IConversationTranslatorRecognizer, event: ParticipantEventArgs) => void;\n participantUpdateCommandReceived: (sender: IConversationTranslatorRecognizer, event: ParticipantAttributeEventArgs) => void;\n}\n\n/**\n * Error message returned from the Conversation Translator websocket\n */\nexport interface IConversationResponseErrorMessage {\n code: string;\n message: string;\n}\n\n/**\n * Error returned from the Conversation Translator websocket\n */\nexport interface IConversationResponseError {\n error: IConversationResponseErrorMessage;\n}\n\n/**\n * Base message command\n */\nexport interface IClientMessage {\n type: any;\n}\n\n/**\n * Command message\n */\nexport interface ICommandMessage extends IClientMessage {\n command?: string;\n}\n\n/**\n * Text message command\n */\nexport interface IInstantMessageCommand extends ICommandMessage {\n roomId: string;\n nickname?: string;\n participantId: string;\n text: string;\n}\n\n/**\n * Lock command\n */\nexport interface ILockConversationCommand extends ICommandMessage {\n id?: string; // incoming ws\n nickname?: string; // incoming ws\n participantId: string; // host - incoming ws\n roomid: string;\n value: boolean;\n}\n\n/**\n * Mute all command\n */\nexport interface IMuteAllCommand extends ICommandMessage {\n roomid: string;\n nickname?: string; // incoming ws\n participantId: string; // host\n value: boolean;\n id?: string; // incoming ws\n}\n\n/**\n * Mute participant command\n */\nexport interface IMuteCommand extends ICommandMessage {\n roomid: string;\n nickname?: string;\n participantId: string; // participant\n value: boolean;\n id?: string; // incoming ws\n}\n\n/**\n * Remove participant command\n */\nexport interface IEjectParticipantCommand extends ICommandMessage {\n roomid: string;\n participantId: string; // participant\n}\n\n/**\n * Change nickname command\n */\nexport interface IChangeNicknameCommand extends ICommandMessage {\n roomid: string;\n participantId: string;\n nickname: string;\n value: string;\n}\n\n/**\n * List of command message types\n */\nexport const ConversationTranslatorMessageTypes = {\n command: \"command\",\n final: \"final\",\n info: \"info\",\n instantMessage: \"instant_message\",\n partial: \"partial\",\n participantCommand: \"participant_command\",\n translatedMessage: \"translated_message\"\n};\n\n/**\n * List of command types\n */\nexport const ConversationTranslatorCommandTypes = {\n changeNickname: \"ChangeNickname\",\n disconnectSession: \"DisconnectSession\",\n ejectParticipant: \"EjectParticipant\",\n instant_message: \"instant_message\",\n joinSession: \"JoinSession\",\n leaveSession: \"LeaveSession\",\n participantList: \"ParticipantList\",\n roomExpirationWarning: \"RoomExpirationWarning\",\n setLockState: \"SetLockState\",\n setMute: \"SetMute\",\n setMuteAll: \"SetMuteAll\",\n setProfanityFiltering: \"SetProfanityFiltering\",\n setTranslateToLanguages: \"SetTranslateToLanguages\",\n setUseTTS: \"SetUseTTS\"\n};\n\n/**\n * HTTP response helper\n */\nexport interface IResponse {\n ok: boolean;\n status: number;\n statusText: string;\n data: string;\n json: <T>() => T;\n headers: string;\n}\n"]}