Skip to content

Commit 31c42cc

Browse files
author
Josh Gummersall
committed
port: remove lang from set speak middleware
Fixes #3507
1 parent 263fa48 commit 31c42cc

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

libraries/botbuilder-dialogs-adaptive-runtime/src/index.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,13 @@ function addFeatures(services: ServiceCollection, configuration: Configuration):
6969
['setSpeak'],
7070
t.Record({
7171
voiceFontName: t.String.Or(t.Undefined),
72-
lang: t.String,
7372
fallbackToTextForSpeechIfEmpty: t.Boolean,
7473
})
7574
);
7675

7776
if (setSpeak) {
7877
middlewareSet.use(
79-
new SetSpeakMiddleware(
80-
setSpeak.voiceFontName ?? null,
81-
setSpeak.lang,
82-
setSpeak.fallbackToTextForSpeechIfEmpty
83-
)
78+
new SetSpeakMiddleware(setSpeak.voiceFontName ?? null, setSpeak.fallbackToTextForSpeechIfEmpty)
8479
);
8580
}
8681

libraries/botbuilder/src/setSpeakMiddleware.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,9 @@ export class SetSpeakMiddleware implements Middleware {
3535
* Initializes a new instance of the SetSpeakMiddleware class.
3636
*
3737
* @param voiceName The SSML voice name attribute value.
38-
* @param lang The xml:lang value.
3938
* @param fallbackToTextForSpeak true if an empty Activity.Speak is populated with Activity.Text.
4039
*/
41-
constructor(
42-
private readonly voiceName: string | null,
43-
private readonly lang: string,
44-
private readonly fallbackToTextForSpeak: boolean
45-
) {
46-
if (!lang) throw new TypeError('`lang` must be a non-empty string');
47-
}
40+
constructor(private readonly voiceName: string | null, private readonly fallbackToTextForSpeak: boolean) {}
4841

4942
/**
5043
* Processes an incoming activity.
@@ -75,7 +68,9 @@ export class SetSpeakMiddleware implements Middleware {
7568
activity.speak = `<voice name='${this.voiceName}'>${activity.speak}</voice>`;
7669
}
7770

78-
activity.speak = `<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='${this.lang}'>${activity.speak}</speak>`;
71+
activity.speak = `<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='${
72+
activity.locale ?? 'en-US'
73+
}'>${activity.speak}</speak>`;
7974
}
8075
}
8176
})

libraries/botbuilder/tests/setSpeakMiddleware.test.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ const { MessageFactory, TestAdapter } = require('botbuilder-core');
88
describe('SetSpeakMiddleware', function () {
99
describe('constructor', function () {
1010
it('works', function () {
11-
new SetSpeakMiddleware('voiceName', 'lang', false);
12-
});
13-
14-
it('throws for falsy lang param', function () {
15-
assert.throws(() => new SetSpeakMiddleware('voiceName', '', false));
11+
new SetSpeakMiddleware('voiceName', false);
1612
});
1713
});
1814

@@ -25,7 +21,7 @@ describe('SetSpeakMiddleware', function () {
2521
},
2622
voice = 'male',
2723
} = {}) {
28-
return new TestAdapter(logic, { channelId }).use(new SetSpeakMiddleware(voice, 'en-us', fallback));
24+
return new TestAdapter(logic, { channelId }).use(new SetSpeakMiddleware(voice, fallback));
2925
}
3026

3127
it('no fallback does nothing to speak', async function () {

0 commit comments

Comments
 (0)