Skip to content

Commit 36a7cba

Browse files
author
Brian Mouncer
committed
Merge branch 'master' of https://github.com/microsoft/cognitive-services-speech-sdk-js into release/1.43
2 parents d01546c + 305f4d0 commit 36a7cba

7 files changed

Lines changed: 66 additions & 2 deletions

File tree

cspell.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"words": [
3+
"viseme"
4+
]
5+
}

src/common.speech/AvatarSynthesisAdapter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export class AvatarSynthesisAdapter extends SynthesisAdapterBase {
7777
character: this.privAvatarConfig.character,
7878
customized: this.privAvatarConfig.customized,
7979
style: this.privAvatarConfig.style,
80+
useBuiltInVoice: this.privAvatarConfig.useBuiltInVoice,
8081
}
8182
} as ISynthesisSectionVideo;
8283
}

src/common.speech/SpeechServiceConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export interface ISynthesisSectionVideo {
167167
talkingAvatar: {
168168
character: string;
169169
customized: boolean;
170+
useBuiltInVoice: boolean;
170171
style: string;
171172
background: {
172173
color: string;

src/sdk/AvatarConfig.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { AvatarVideoFormat } from "./Exports.js";
1313
*/
1414
export class AvatarConfig {
1515
private privCustomized: boolean = false;
16+
private privUseBuiltInVoice: boolean = false;
1617
private privBackgroundColor: string;
1718
private privBackgroundImage: URL;
1819
private privRemoteIceServers: RTCIceServer[];
@@ -44,6 +45,20 @@ export class AvatarConfig {
4445
this.privCustomized = value;
4546
}
4647

48+
/**
49+
* Indicates whether to use built-in voice for custom avatar.
50+
*/
51+
public get useBuiltInVoice(): boolean {
52+
return this.privUseBuiltInVoice;
53+
}
54+
55+
/**
56+
* Sets whether to use built-in voice for custom avatar.
57+
*/
58+
public set useBuiltInVoice(value: boolean) {
59+
this.privUseBuiltInVoice = value;
60+
}
61+
4762
/**
4863
* Gets the background color.
4964
*/

src/sdk/Exports.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export { SpeechSynthesisBookmarkEventArgs } from "./SpeechSynthesisBookmarkEvent
9898
export { SpeechSynthesisVisemeEventArgs } from "./SpeechSynthesisVisemeEventArgs.js";
9999
export { SpeechSynthesisBoundaryType } from "./SpeechSynthesisBoundaryType.js";
100100
export { SynthesisVoicesResult } from "./SynthesisVoicesResult.js";
101-
export { VoiceInfo } from "./VoiceInfo.js";
101+
export { SynthesisVoiceGender, SynthesisVoiceType, VoiceInfo } from "./VoiceInfo.js";
102102
export { IPlayer } from "./Audio/IPlayer.js";
103103
export { SpeakerAudioDestination } from "./Audio/SpeakerAudioDestination.js";
104104
export { CancellationEventArgs } from "./CancellationEventArgs.js";

src/sdk/VoiceInfo.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,35 @@ export enum SynthesisVoiceGender {
2323
}
2424

2525
export enum SynthesisVoiceType {
26+
/**
27+
* Voice type is not known.
28+
*/
29+
Unknown = 0,
30+
31+
/**
32+
* Online neural voices.
33+
*/
2634
OnlineNeural = 1,
35+
36+
/**
37+
* Online standard voices. These voices are deprecated.
38+
*/
2739
OnlineStandard = 2,
40+
41+
/**
42+
* Offline neural voices.
43+
*/
2844
OfflineNeural = 3,
45+
46+
/**
47+
* Offline standard voices.
48+
*/
2949
OfflineStandard = 4,
50+
51+
/**
52+
* High definition (HD) voices. Refer to https://learn.microsoft.com/azure/ai-services/speech-service/high-definition-voices
53+
*/
54+
OnlineNeuralHD = 5,
3055
}
3156

3257
const GENDER_LOOKUP: Record<string, SynthesisVoiceGender> = {
@@ -35,6 +60,11 @@ const GENDER_LOOKUP: Record<string, SynthesisVoiceGender> = {
3560
[SynthesisVoiceGender[SynthesisVoiceGender.Female]]: SynthesisVoiceGender.Female,
3661
};
3762

63+
const VOICE_TYPE_LOOKUP: Record<string, SynthesisVoiceType> = {
64+
Neural: SynthesisVoiceType.OnlineNeural,
65+
NeuralHD: SynthesisVoiceType.OnlineNeuralHD,
66+
};
67+
3868
/**
3969
* Information about Speech Synthesis voice
4070
* Added in version 1.20.0.
@@ -66,7 +96,7 @@ export class VoiceInfo {
6696
this.privLocaleName = json.LocaleName;
6797
this.privDisplayName = json.DisplayName;
6898
this.privLocalName = json.LocalName;
69-
this.privVoiceType = json.VoiceType.endsWith("Standard") ? SynthesisVoiceType.OnlineStandard : SynthesisVoiceType.OnlineNeural;
99+
this.privVoiceType = VOICE_TYPE_LOOKUP[json.VoiceType] || SynthesisVoiceType.Unknown;
70100
this.privGender = GENDER_LOOKUP[json.Gender] || SynthesisVoiceGender.Unknown;
71101

72102
if (!!json.StyleList && Array.isArray(json.StyleList)) {

tests/SpeechSynthesisTests.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@ test("testGetVoicesAsyncDefault", async () => {
165165
expect(voicesResult.resultId).not.toBeUndefined();
166166
expect(voicesResult.voices.length).toBeGreaterThan(0);
167167
expect(voicesResult.reason).toEqual(sdk.ResultReason.VoicesListRetrieved);
168+
169+
for (const voice of voicesResult.voices) {
170+
expect(voice.name).not.toBeUndefined();
171+
expect(voice.locale).not.toBeUndefined();
172+
expect(voice.shortName).not.toBeUndefined();
173+
expect(voice.displayName).not.toBeUndefined();
174+
expect(voice.localName).not.toBeUndefined();
175+
expect(voice.gender).not.toEqual(sdk.SynthesisVoiceGender.Unknown);
176+
expect(voice.voiceType).not.toEqual(sdk.SynthesisVoiceType.Unknown);
177+
}
168178
});
169179

170180
test("testGetVoicesAsyncAuthWithToken", async () => {
@@ -228,6 +238,8 @@ test("testGetVoicesAsyncUS", async () => {
228238
expect(ava).not.toBeUndefined();
229239
expect(ava.voiceTag.TailoredScenarios).not.toBeUndefined();
230240
expect(ava.voiceTag.TailoredScenarios[0]).toEqual("Chat");
241+
expect(ava.gender).toEqual(sdk.SynthesisVoiceGender.Female);
242+
expect(ava.voiceType).toEqual(sdk.SynthesisVoiceType.OnlineNeural);
231243
});
232244

233245
Settings.testIfDOMCondition("testSpeechSynthesizer1", () => {

0 commit comments

Comments
 (0)