Skip to content

Commit 65c75a2

Browse files
authored
Remove redundant speech response in Inventory and Automotive CC portals. (#450)
* Remove redundant speech response in Inventory and Automotive CC portals. * Add Change log section in root README.md. * Update Change log section at make a new line. * Reformat Change log section.
1 parent 64647de commit 65c75a2

File tree

6 files changed

+108
-154
lines changed

6 files changed

+108
-154
lines changed

custom-commands/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,16 @@ The Custom Commands application was created from the json file [../skill/hospita
182182

183183
Our Powershell deployment script is intended to make getting started easier. For further customization you should edit the Powershell scripts to fit your needs.
184184

185-
Another useful thing might be to update the Azure SKU's in the azuredeploy.json to allow higher usage and other things such as multiple speech resources, and App Service plans in different regions. The script has a region check for the supported regions of the free App Service plan, which will need to be removed if you do this.
185+
Another useful thing might be to update the Azure SKU's in the azuredeploy.json to allow higher usage and other things such as multiple speech resources, and App Service plans in different regions. The script has a region check for the supported regions of the free App Service plan, which will need to be removed if you do this.
186+
187+
## Change log
188+
189+
* [May 26, 2020](https://github.com/Azure-Samples/Cognitive-Services-Voice-Assistant/pull/439/commits/83d6606eeea44ec46a4d8eb49ff831a7467fee62):
190+
* Updated HospitalityDemo.cs to not to turn on TV, lights, air condition that are already on, etc.
191+
* Updated HospitalityDemo.json to use message returned from web endpoint for onSuccess SpeechResponse for CallHttpEndpoint actions, and remove redundant SpeechResponse.
192+
* [May 29, 2020](https://github.com/Azure-Samples/Cognitive-Services-Voice-Assistant/pull/450/commits/cd5a08748ac05fa4b4b89782565e2959f1a8c738):
193+
* Updated AutomotiveDemo.cs to not to turn on defroster, seat warmer that are already on, etc.
194+
* Updated InventoryDemo.cs to not allow to ship items if requested quantity is larger than stock quantity.
195+
* Updated AutomotiveDemo.json to use message returned from web endpoint for onSuccess SpeechResponse for CallHttpEndpoint actions, and remove redundant SpeechResponse.
196+
* Updated InventoryDemo.json to use message returned from web endpoint for onSuccess SpeechResponse for CallHttpEndpoint actions, and remove redundant SpeechResponse.
197+
* Updated AutomotiveDemo.json, HospitalityDemo.json, and InventoryDemo.json to remove entityResolver, recognizer, speechOutput sections to avoid TTS malfunction.

custom-commands/automotive/azure-function/AutomotiveApp/AutomotiveDemo.cs

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,23 @@ public static async Task<HttpResponseMessage> Run(
7575
currentAutomotiveData = (AutomotiveData)(await table.ExecuteAsync(getRoom)).Result;
7676
}
7777

78-
var operation = req.Query["operation"].ToString().ToLower();
79-
var updated = false;
78+
string operation = req.Query["operation"].ToString().ToLower();
79+
string strValue = req.Query["value"].ToString().ToLower();
80+
int.TryParse(strValue, out int intValue);
81+
bool updated = false;
8082

8183
if (!string.IsNullOrEmpty(operation))
8284
{
8385
if (operation.Equals("reset"))
8486
{
8587
currentAutomotiveData.LoadDefaultData();
88+
currentAutomotiveData.Message = "Okay, reset to default state.";
8689
updated = true;
8790
}
8891
else if (operation.Equals("help"))
8992
{
9093
currentAutomotiveData.Help = true;
94+
currentAutomotiveData.Message = "You're in a virtual car and able to control features with your voice. Try saying \"Turn on the seat warmers\" or \"Set the temperature to 73 degrees\"";
9195
updated = true;
9296
}
9397
else
@@ -96,41 +100,54 @@ public static async Task<HttpResponseMessage> Run(
96100

97101
if (operation.Equals("settemperature"))
98102
{
99-
currentAutomotiveData.Temperature = int.Parse(req.Query["value"]);
100-
currentAutomotiveData.Message = "set temperature to " + req.Query["value"];
103+
currentAutomotiveData.Temperature = intValue;
104+
currentAutomotiveData.Message = $"Okay, set temperature to {intValue} degrees";
101105
updated = true;
102106
}
103107
else if (operation.Equals("increasetemperature"))
104108
{
105-
currentAutomotiveData.Temperature += int.Parse(req.Query["value"]);
106-
currentAutomotiveData.Message = "raised temperature by " + req.Query["value"] + " degrees";
109+
currentAutomotiveData.Temperature += intValue;
110+
currentAutomotiveData.Message = $"All right, raise the temperature by {intValue} degrees";
107111
updated = true;
108112
}
109113
else if (operation.Equals("decreasetemperature"))
110114
{
111-
currentAutomotiveData.Temperature -= int.Parse(req.Query["value"]);
112-
currentAutomotiveData.Message = "decreased temperature by " + req.Query["value"] + " degrees";
115+
currentAutomotiveData.Temperature -= intValue;
116+
currentAutomotiveData.Message = $"All right, lower the temperature by {intValue} degrees";
113117
updated = true;
114118
}
115119
else if (operation.Equals("defrost") || operation.Equals("seatwarmer"))
116120
{
117-
var value = req.Query["value"].ToString().ToLower();
118-
bool? valueBool = (value.Equals("on")) ? true : ((value.Equals("off")) ? (bool?)false : null);
121+
bool? valueBool = (strValue.Equals("on")) ? true : ((strValue.Equals("off")) ? (bool?)false : null);
119122

120123
if (valueBool == null)
121124
{
122125
updated = false;
123126
}
124127
else if (operation.Equals("defrost"))
125128
{
126-
currentAutomotiveData.Defrost = (bool)valueBool;
127-
currentAutomotiveData.Message = "Defrost " + value;
129+
if (currentAutomotiveData.Defrost == (bool)valueBool)
130+
{
131+
currentAutomotiveData.Message = $"Defrost already {strValue}";
132+
}
133+
else
134+
{
135+
currentAutomotiveData.Defrost = (bool)valueBool;
136+
currentAutomotiveData.Message = $"Ok, turn defroster {strValue}";
137+
}
128138
updated = true;
129139
}
130140
else if (operation.Equals("seatwarmer"))
131141
{
132-
currentAutomotiveData.SeatWarmers = (bool)valueBool;
133-
currentAutomotiveData.Message = "Seat warmer " + value;
142+
if (currentAutomotiveData.SeatWarmers == (bool)valueBool)
143+
{
144+
currentAutomotiveData.Message = $"Seat warmer already {strValue}";
145+
}
146+
else
147+
{
148+
currentAutomotiveData.SeatWarmers = (bool)valueBool;
149+
currentAutomotiveData.Message = $"Ok, turn seat warmer {strValue}";
150+
}
134151
updated = true;
135152
}
136153
}
@@ -153,7 +170,7 @@ public static async Task<HttpResponseMessage> Run(
153170
Content = new StringContent(JsonConvert.SerializeObject(currentAutomotiveData, Formatting.Indented), Encoding.UTF8, "application/json")
154171
};
155172
}
156-
catch(Exception e)
173+
catch (Exception e)
157174
{
158175
log.LogError(e.Message);
159176
return new HttpResponseMessage(HttpStatusCode.BadRequest)

custom-commands/automotive/skill/AutomotiveDemo.json

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
{
22
"type": "CommandsDialogModel",
33
"culture": "en-us",
4-
"entityResolver": {
5-
"searchConfiguration": {
6-
"maxEdits": 0
7-
},
8-
"type": "internal",
9-
"isGenerated": true
10-
},
114
"httpEndpoints": [
125
{
136
"name": "AutomotiveEndpoint",
@@ -55,14 +48,10 @@
5548
"# AdjustTemperatureTemperature",
5649
"- How much do you want to change the temperature by?",
5750
"- By how many degrees?",
58-
"# AdjustTemperature9ea389f028de11ea83cf95b9c7d5480f",
59-
"- All right, {Operation} the temperature by {Temperature} degrees",
6051
"# AdjustTemperatureAutomotiveEndpointonSuccess64368a3028e111eaaf158b43807e75e2",
6152
"- Type your response(s) here.",
6253
"# AdjustTemperatureAutomotiveEndpointonFailure64368a3028e111eaaf158b43807e75e2",
6354
"- Sorry, not able to connect to the room control service right now",
64-
"# AdjustTemperatureff5431a028de11ea83cf95b9c7d5480f",
65-
"- All right, {Operation} the temperature by {Temperature} degrees",
6655
"# AdjustTemperatureAutomotiveEndpointonSuccess958d9ce028e111eaaf158b43807e75e2",
6756
"- Type your response(s) here.",
6857
"# AdjustTemperatureAutomotiveEndpointonFailure958d9ce028e111eaaf158b43807e75e2",
@@ -76,27 +65,25 @@
7665
"# AdjustTemperature571bc8a028e211eaaf158b43807e75e2",
7766
"- What temperature do you want to set it to?",
7867
"# AdjustTemperatureAutomotiveEndpointonSuccess287895e028e311ea8db34fd5c8a135ab",
79-
"- ",
68+
"- {AutomotiveEndpoint.Message}",
8069
"# AdjustTemperatureAutomotiveEndpointonFailure287895e028e311ea8db34fd5c8a135ab",
8170
"- Sorry, not able to connect to the room control service right now",
8271
"# AdjustTemperatureAutomotiveEndpointonSuccess43dd866028e311ea8db34fd5c8a135ab",
83-
"- ",
72+
"- {AutomotiveEndpoint.Message}",
8473
"# AdjustTemperatureAutomotiveEndpointonFailure43dd866028e311ea8db34fd5c8a135ab",
8574
"- Sorry, not able to connect to the room control service right now",
8675
"# AdjustTemperatureAutomotiveEndpointonSuccess76ee7e1028e311ea8db34fd5c8a135ab",
8776
"- ",
8877
"# AdjustTemperatureAutomotiveEndpointonFailure76ee7e1028e311ea8db34fd5c8a135ab",
8978
"- Sorry, unable to connect to the room control service right now",
90-
"# AdjustTemperaturec221460028df11ea83cf95b9c7d5480f",
91-
"- Okay, setting it to {Temperature} degrees",
9279
"# AdjustTemperature4519903028e011ea83cf95b9c7d5480f",
9380
"- I can only set between 68 and 80 degrees. What temperature would you like?",
9481
"# AdjustTemperatureAutomotiveEndpointonSuccessfd34ee9028f311ea88cde3d2ef24c102",
95-
"- ",
82+
"- {AutomotiveEndpoint.Message}",
9683
"# AdjustTemperatureAutomotiveEndpointonFailurefd34ee9028f311ea88cde3d2ef24c102",
9784
"- Sorry, unable to connect to the room control service right now",
9885
"# Help-AutomotiveEndpointonSuccess-77e2e7a08a7411eab5f27787a0c205ba",
99-
"- You're in a virtual car and able to control features with your voice. Try saying \"Turn on the seat warmers\" or \"Set the temperature to 73 degrees\"",
86+
"- {AutomotiveEndpoint.Message}",
10087
"# Help-AutomotiveEndpointonFailure-77e2e7a08a7411eab5f27787a0c205ba",
10188
"- Unable to connect to virtual automotive",
10289
"- Unable to connect to virtual car",
@@ -120,17 +107,17 @@
120107
"# ControlDefroster-DefrosterOnOff",
121108
"- Turn the defroster on or off?",
122109
"# ControlSeatWarmer-AutomotiveEndpointonSuccess-----8d295000962611eab32ec9b90e43d4b9",
123-
"- Ok, turning the seat warmer {SeatWarmerOnOff}",
110+
"- {AutomotiveEndpoint.Message}",
124111
"# ControlSeatWarmer-AutomotiveEndpointonFailure-----8d295000962611eab32ec9b90e43d4b9",
125112
"- Sorry, not able to connect to the room control service right now",
126113
"# ControlSeatWarmer-SeatWarmerOnOff",
127114
"- Turn the seat warmer on or off?",
128115
"# ControlDefroster-AutomotiveEndpointonSuccess---d0f56c10962611eab32ec9b90e43d4b9",
129-
"- Ok, turning the defroster {DefrosterOnOff}",
116+
"- {AutomotiveEndpoint.Message}",
130117
"# ControlDefroster-AutomotiveEndpointonFailure---d0f56c10962611eab32ec9b90e43d4b9",
131118
"- Sorry, not able to connect to the room control service right now",
132119
"# Reset-AutomotiveEndpointonSuccess-84949550963311ea912b91373fe5483a",
133-
"- Okay, resetting to default state.",
120+
"- {AutomotiveEndpoint.Message}",
134121
"# Reset-AutomotiveEndpointonFailure-84949550963311ea912b91373fe5483a",
135122
"- Sorry, unable to connect to the virtual automotive at this time.",
136123
"# FallbackResponse",
@@ -250,13 +237,6 @@
250237
}
251238
],
252239
"actions": [
253-
{
254-
"type": "SpeechResponse",
255-
"response": {
256-
"type": "Template",
257-
"templateName": "# AdjustTemperature9ea389f028de11ea83cf95b9c7d5480f"
258-
}
259-
},
260240
{
261241
"type": "CallHttpEndpoint",
262242
"name": "AutomotiveEndpoint",
@@ -306,13 +286,6 @@
306286
}
307287
],
308288
"actions": [
309-
{
310-
"type": "SpeechResponse",
311-
"response": {
312-
"type": "Template",
313-
"templateName": "# AdjustTemperatureff5431a028de11ea83cf95b9c7d5480f"
314-
}
315-
},
316289
{
317290
"type": "CallHttpEndpoint",
318291
"name": "AutomotiveEndpoint",
@@ -394,13 +367,6 @@
394367
}
395368
],
396369
"actions": [
397-
{
398-
"type": "SpeechResponse",
399-
"response": {
400-
"type": "Template",
401-
"templateName": "# AdjustTemperaturec221460028df11ea83cf95b9c7d5480f"
402-
}
403-
},
404370
{
405371
"type": "CallHttpEndpoint",
406372
"name": "AutomotiveEndpoint",

custom-commands/hospitality/skill/HospitalityDemo.json

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
{
22
"type": "CommandsDialogModel",
33
"culture": "en-us",
4-
"recognizer": {
5-
"application": "",
6-
"isStaging": false,
7-
"versionId": "1.0",
8-
"endpointKey": "",
9-
"region": "westeurope",
10-
"type": "luis"
11-
},
12-
"speechOutput": {
13-
"font": "Microsoft Server Speech Text to Speech Voice (en-US, AriaNeural)",
14-
"locale": "en-US"
15-
},
164
"httpEndpoints": [
175
{
186
"name": "RoomControlBackend",
@@ -78,8 +66,6 @@
7866
"- Type your response(s) here.",
7967
"# AdjustTemperatureRoomControlBackendonFailure6f417f9028d511ea8118bdb0a739e346",
8068
"- Type your response(s) here.",
81-
"# AdjustTemperatureRoomControlBackendonSuccessa574afc028de11ea83cf95b9c7d5480f",
82-
"-",
8369
"# AdjustTemperatureRoomControlBackendonFailurea574afc028de11ea83cf95b9c7d5480f",
8470
"- Sorry, not able to connect to the room control service right now",
8571
"# AdjustTemperatureRoomControlBackendonSuccess09d9fb0028df11ea83cf95b9c7d5480f",
@@ -97,14 +83,10 @@
9783
"# AdjustTemperatureTemperature",
9884
"- How much do you want to change the temperature by?",
9985
"- By how many degrees?",
100-
"# AdjustTemperature9ea389f028de11ea83cf95b9c7d5480f",
101-
"- All right, {Operation} the temperature by {Temperature} degrees",
10286
"# AdjustTemperatureRoomControlBackendonSuccess64368a3028e111eaaf158b43807e75e2",
10387
"- Type your response(s) here.",
10488
"# AdjustTemperatureRoomControlBackendonFailure64368a3028e111eaaf158b43807e75e2",
10589
"- Sorry, not able to connect to the room control service right now",
106-
"# AdjustTemperatureff5431a028de11ea83cf95b9c7d5480f",
107-
"- All right, {Operation} the temperature by {Temperature} degrees",
10890
"# AdjustTemperatureRoomControlBackendonSuccess958d9ce028e111eaaf158b43807e75e2",
10991
"- Type your response(s) here.",
11092
"# AdjustTemperatureRoomControlBackendonFailure958d9ce028e111eaaf158b43807e75e2",
@@ -118,23 +100,19 @@
118100
"# AdjustTemperature571bc8a028e211eaaf158b43807e75e2",
119101
"- What temperature do you want to set it to?",
120102
"# AdjustTemperatureRoomControlBackendonSuccess287895e028e311ea8db34fd5c8a135ab",
121-
"- ",
103+
"- {RoomControlBackend.Message}",
122104
"# AdjustTemperatureRoomControlBackendonFailure287895e028e311ea8db34fd5c8a135ab",
123105
"- Sorry, not able to connect to the room control service right now",
124106
"# AdjustTemperatureRoomControlBackendonSuccess43dd866028e311ea8db34fd5c8a135ab",
125-
"- ",
107+
"- {RoomControlBackend.Message}",
126108
"# AdjustTemperatureRoomControlBackendonFailure43dd866028e311ea8db34fd5c8a135ab",
127109
"- Sorry, not able to connect to the room control service right now",
128-
"# AdjustTemperatureRoomControlBackendonSuccess76ee7e1028e311ea8db34fd5c8a135ab",
129-
"- ",
130110
"# AdjustTemperatureRoomControlBackendonFailure76ee7e1028e311ea8db34fd5c8a135ab",
131111
"- Sorry, unable to connect to the room control service right now",
132-
"# AdjustTemperaturec221460028df11ea83cf95b9c7d5480f",
133-
"- Okay, setting it to {Temperature} degrees",
134112
"# AdjustTemperature4519903028e011ea83cf95b9c7d5480f",
135113
"- I can only set between 68 and 80 degrees. What temperature would you like?",
136114
"# AdjustTemperatureRoomControlBackendonSuccessfd34ee9028f311ea88cde3d2ef24c102",
137-
"- ",
115+
"- {RoomControlBackend.Message}",
138116
"# AdjustTemperatureRoomControlBackendonFailurefd34ee9028f311ea88cde3d2ef24c102",
139117
"- Sorry, unable to connect to the room control service right now",
140118
"# TurnOnOff-RoomControlBackendonSuccess-7ca4cca000e411ea97e43706794592d8",
@@ -354,7 +332,7 @@
354332
"type": "SpeechResponse",
355333
"response": {
356334
"type": "Template",
357-
"templateName": "# TurnOnOff-RoomControlBackendonSuccess-7ca4cca000e411ea97e43706794592d8"
335+
"templateName": "# TurnOnOff-RoomControlBackendonSuccess-7ca4cca000e411ea97e43706794592d8"
358336
}
359337
},
360338
"onFailure": {
@@ -548,13 +526,6 @@
548526
}
549527
],
550528
"actions": [
551-
{
552-
"type": "SpeechResponse",
553-
"response": {
554-
"type": "Template",
555-
"templateName": "# AdjustTemperature9ea389f028de11ea83cf95b9c7d5480f"
556-
}
557-
},
558529
{
559530
"type": "CallHttpEndpoint",
560531
"name": "RoomControlBackend",
@@ -604,13 +575,6 @@
604575
}
605576
],
606577
"actions": [
607-
{
608-
"type": "SpeechResponse",
609-
"response": {
610-
"type": "Template",
611-
"templateName": "# AdjustTemperatureff5431a028de11ea83cf95b9c7d5480f"
612-
}
613-
},
614578
{
615579
"type": "CallHttpEndpoint",
616580
"name": "RoomControlBackend",
@@ -692,13 +656,6 @@
692656
}
693657
],
694658
"actions": [
695-
{
696-
"type": "SpeechResponse",
697-
"response": {
698-
"type": "Template",
699-
"templateName": "# AdjustTemperaturec221460028df11ea83cf95b9c7d5480f"
700-
}
701-
},
702659
{
703660
"type": "CallHttpEndpoint",
704661
"name": "RoomControlBackend",
@@ -922,7 +879,8 @@
922879
],
923880
"close": [
924881
"lower",
925-
"down"
882+
"down",
883+
"shut"
926884
]
927885
}
928886
}

0 commit comments

Comments
 (0)