Merge branch 'master' of github.com:microsoft/cognitive-services-speech-sdk-js into yulin/avatar

This commit is contained in:
Yulin Li 2023-07-19 16:45:34 +08:00
Родитель b676e4daa5 447c986acf
Коммит 2444ecaa6e
6 изменённых файлов: 108 добавлений и 16 удалений

72
package-lock.json сгенерированный
Просмотреть файл

@ -1,12 +1,12 @@
{
"name": "microsoft-cognitiveservices-speech-sdk",
"version": "1.30.0-alpha.0.1",
"version": "1.31.0-alpha.0.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "microsoft-cognitiveservices-speech-sdk",
"version": "1.30.0-alpha.0.1",
"version": "1.31.0-alpha.0.1",
"license": "MIT",
"dependencies": {
"agent-base": "^6.0.1",
@ -8767,6 +8767,12 @@
"node": ">=6"
}
},
"node_modules/querystringify": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==",
"dev": true
},
"node_modules/queue-microtask": {
"version": "1.2.3",
"dev": true,
@ -8980,6 +8986,12 @@
"dev": true,
"license": "ISC"
},
"node_modules/requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==",
"dev": true
},
"node_modules/resolve": {
"version": "1.20.0",
"dev": true,
@ -10149,13 +10161,15 @@
}
},
"node_modules/tough-cookie": {
"version": "4.0.0",
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz",
"integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
"psl": "^1.1.33",
"punycode": "^2.1.1",
"universalify": "^0.1.2"
"universalify": "^0.2.0",
"url-parse": "^1.5.3"
},
"engines": {
"node": ">=6"
@ -10538,9 +10552,10 @@
}
},
"node_modules/universalify": {
"version": "0.1.2",
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz",
"integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 4.0.0"
}
@ -10642,6 +10657,16 @@
"dev": true,
"license": "MIT"
},
"node_modules/url-parse": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
"integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==",
"dev": true,
"dependencies": {
"querystringify": "^2.1.1",
"requires-port": "^1.0.0"
}
},
"node_modules/use": {
"version": "3.1.1",
"dev": true,
@ -16971,6 +16996,12 @@
"version": "2.1.1",
"dev": true
},
"querystringify": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==",
"dev": true
},
"queue-microtask": {
"version": "1.2.3",
"dev": true
@ -17103,6 +17134,12 @@
"version": "1.0.1",
"dev": true
},
"requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==",
"dev": true
},
"resolve": {
"version": "1.20.0",
"dev": true,
@ -17880,12 +17917,15 @@
}
},
"tough-cookie": {
"version": "4.0.0",
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz",
"integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==",
"dev": true,
"requires": {
"psl": "^1.1.33",
"punycode": "^2.1.1",
"universalify": "^0.1.2"
"universalify": "^0.2.0",
"url-parse": "^1.5.3"
}
},
"tr46": {
@ -18125,7 +18165,9 @@
}
},
"universalify": {
"version": "0.1.2",
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz",
"integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==",
"dev": true
},
"unset-value": {
@ -18189,6 +18231,16 @@
"version": "0.1.0",
"dev": true
},
"url-parse": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
"integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==",
"dev": true,
"requires": {
"querystringify": "^2.1.1",
"requires-port": "^1.0.0"
}
},
"use": {
"version": "3.1.1",
"dev": true

Просмотреть файл

@ -2,7 +2,7 @@
"name": "microsoft-cognitiveservices-speech-sdk",
"author": "Microsoft Corporation",
"homepage": "https://docs.microsoft.com/azure/cognitive-services/speech-service/",
"version": "1.30.0-alpha.0.1",
"version": "1.31.0-alpha.0.1",
"license": "MIT",
"description": "Microsoft Cognitive Services Speech SDK for JavaScript",
"keywords": [

Просмотреть файл

@ -15,6 +15,7 @@ import {
ConversationExpirationEventArgs,
ConversationTranslationCanceledEventArgs,
ConversationTranslationResult,
ResultReason,
Translations
} from "../../sdk/Exports";
import {
@ -191,10 +192,11 @@ export class ConversationServiceAdapter extends ServiceRecognizerBase {
}
const sessionId: string = this.privConversationRequestSession.sessionId;
const conversationMessageType: string = message.conversationMessageType.toLowerCase();
let sendFinal: boolean = false;
try {
switch (message.conversationMessageType.toLowerCase()) {
switch (conversationMessageType) {
case "info":
case "participant_command":
case "command":
@ -432,12 +434,13 @@ export class ConversationServiceAdapter extends ServiceRecognizerBase {
case "final":
const speechPayload: SpeechResponsePayload = SpeechResponsePayload.fromJSON(message.textBody);
const conversationResultReason: ResultReason = (conversationMessageType === "final") ? ResultReason.TranslatedParticipantSpeech : ResultReason.TranslatingParticipantSpeech;
const speechResult: ConversationTranslationResult = new ConversationTranslationResult(speechPayload.participantId,
this.getTranslations(speechPayload.translations),
speechPayload.language,
undefined,
undefined,
speechPayload.id,
conversationResultReason,
speechPayload.recognition,
undefined,
undefined,
@ -478,6 +481,7 @@ export class ConversationServiceAdapter extends ServiceRecognizerBase {
case "translated_message":
const textPayload: TextResponsePayload = TextResponsePayload.fromJSON(message.textBody);
// TODO: (Native parity) a result reason should be set based whether the participantId is ours or not
const textResult: ConversationTranslationResult = new ConversationTranslationResult(textPayload.participantId,
this.getTranslations(textPayload.translations),

Просмотреть файл

@ -125,4 +125,34 @@ export enum ResultReason {
* @member ResultReason.VoicesListRetrieved
*/
VoicesListRetrieved,
/**
* Indicates the transcription result contains hypothesis text and its translation(s) for
* other participants in the conversation.
* @member ResultReason.TranslatingParticipantSpeech
*/
TranslatingParticipantSpeech,
/**
* Indicates the transcription result contains final text and corresponding translation(s)
* for other participants in the conversation. Speech Recognition and Translation are now
* complete for this phrase.
* @member ResultReason.TranslatedParticipantSpeech
*/
TranslatedParticipantSpeech,
/**
* <summary>
* Indicates the transcription result contains the instant message and corresponding
* translation(s).
* @member ResultReason.TranslatedInstantMessage
*/
TranslatedInstantMessage,
/**
* Indicates the transcription result contains the instant message for other participants
* in the conversation and corresponding translation(s).
* @member ResultReason.TranslatedParticipantInstantMessage
*/
TranslatedParticipantInstantMessage,
}

Просмотреть файл

@ -22,7 +22,7 @@ export class SynthesisVoicesResult extends SynthesisResult {
super(requestId, ResultReason.VoicesListRetrieved, undefined, new PropertyCollection());
this.privVoices = [];
for (const item of json) {
this.privVoices.push(new VoiceInfo(item as { Name: string; LocalName: string; LocaleName: string; ShortName: string; Gender: string; VoiceType: string; Locale: string; StyleList: string[] }));
this.privVoices.push(new VoiceInfo(item as { Name: string; LocalName: string; DisplayName: string; LocaleName: string; ShortName: string; Gender: string; VoiceType: string; Locale: string; StyleList: string[] }));
}
} else {
super(requestId, ResultReason.Canceled, errorDetails ? errorDetails : "Error information unavailable", new PropertyCollection());

Просмотреть файл

@ -33,6 +33,7 @@ export class VoiceInfo {
private privName: string;
private privLocale: string;
private privShortName: string;
private privDisplayName: string;
private privLocalName: string;
private privLocaleName: string;
private privGender: SynthesisVoiceGender;
@ -40,13 +41,14 @@ export class VoiceInfo {
private privStyleList: string[] = [];
private privVoicePath: string;
public constructor(json: { Name: string; LocalName: string; ShortName: string; Gender: string; VoiceType: string; LocaleName: string ; Locale: string; StyleList: string[] }) {
public constructor(json: { Name: string; LocalName: string; DisplayName: string; ShortName: string; Gender: string; VoiceType: string; LocaleName: string ; Locale: string; StyleList: string[] }) {
this.privVoicePath = "";
if (!!json) {
this.privName = json.Name;
this.privLocale = json.Locale;
this.privShortName = json.ShortName;
this.privLocaleName = json.LocaleName;
this.privDisplayName = json.DisplayName;
this.privLocalName = json.LocalName;
this.privVoiceType = json.VoiceType.endsWith("Standard") ? SynthesisVoiceType.OnlineStandard : SynthesisVoiceType.OnlineNeural;
this.privGender = json.Gender === "Male" ? SynthesisVoiceGender.Male : json.Gender === "Female" ? SynthesisVoiceGender.Female : SynthesisVoiceGender.Unknown;
@ -70,6 +72,10 @@ export class VoiceInfo {
return this.privShortName;
}
public get displayName(): string {
return this.privDisplayName;
}
public get localName(): string {
return this.privLocalName;
}