Skip to content

Commit b8fe2d0

Browse files
committed
Changes done for v2.3.4.
1 parent b5a07b3 commit b8fe2d0

File tree

9 files changed

+234
-38
lines changed

9 files changed

+234
-38
lines changed

com.ibm.streamsx.sttgateway/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changes
22

3+
## v2.3.4
4+
* May/11/2022
5+
* Added code and logic necessary to handle certain error situations where the SpeechProcessor will send much more than the required two transcriptionCompleted signals.
6+
* Added code to make the call-started and call-completed files' open mode as append/update instead of write/update. This will allow us to get more details about the same VgwSessionId arriving as two different back-to-back calls.
7+
38
## v2.3.3
49
* May/10/2022
510
* Added code and logic necessary to scale the VgwDataRouter to process more voice calls with reduced use of CPU cycles.

com.ibm.streamsx.sttgateway/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
**Note:** This toolkit requires c++11 support.
1616
</description>
17-
<version>2.3.3</version>
17+
<version>2.3.4</version>
1818
<requiredProductVersion>4.2.1.6</requiredProductVersion>
1919
</identity>
2020
<dependencies>

samples/VgwDataRouterToWatsonSTT/com.ibm.streamsx.sttgateway.sample.watsonstt/VgwDataRouterToWatsonSTT.spl

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/*
99
==============================================
1010
First created on: Nov/27/2020
11-
Last modified on: May/10/2022
11+
Last modified on: May/11/2022
1212

1313
IMPORTANT NOTE
1414
--------------
@@ -1015,13 +1015,15 @@ public composite VgwDataRouterToWatsonSTT {
10151015

10161016
rstring socsFileName = dataDirectory() + "/" +
10171017
BSD.vgwSessionId + "-call-started.txt";
1018-
uint64 fileHandle = fopen (socsFileName, "w+", err);
1018+
uint64 fileHandle = fopen (socsFileName, "a+", err);
10191019

10201020
if(err == 0) {
10211021
fwriteString ("VGW call session id " + BSD.vgwSessionId +
10221022
" started at " + BSD.callStartDateTime + ".\n",
10231023
fileHandle, err);
1024-
fwriteString("VGW voice channel number=" +
1024+
fwriteString("Call sequence number=" +
1025+
(rstring)BSD.callSequenceNumber +
1026+
", VGW voice channel number=" +
10251027
(rstring)BSD.vgwVoiceChannelNumber +
10261028
", Speech processor id=" +
10271029
(rstring)$idOfThisSpeechProcessor +
@@ -1032,7 +1034,9 @@ public composite VgwDataRouterToWatsonSTT {
10321034
fclose(fileHandle, err);
10331035
}
10341036

1035-
appTrc(Trace.error, "A new voice call has started. vgwSessionId=" + BSD.vgwSessionId);
1037+
appTrc(Trace.error, "A new voice call has started. vgwSessionId=" +
1038+
BSD.vgwSessionId + ", callSequenceNumber=" +
1039+
(rstring)BSD.callSequenceNumber);
10361040
} else if (has(_vgwSessionIdToUdpChannelMap, key1) == false ||
10371041
has(_vgwSessionIdToUdpChannelMap, key2) == false) {
10381042
// This means, one of the two voice channels in a
@@ -1047,7 +1051,9 @@ public composite VgwDataRouterToWatsonSTT {
10471051
uint64 fileHandle = fopen (socsFileName, "a+", err);
10481052

10491053
if(err == 0) {
1050-
fwriteString("VGW voice channel number=" +
1054+
fwriteString("Call sequence number=" +
1055+
(rstring)BSD.callSequenceNumber +
1056+
", VGW voice channel number=" +
10511057
(rstring)BSD.vgwVoiceChannelNumber +
10521058
", Speech processor id=" +
10531059
(rstring)$idOfThisSpeechProcessor +
@@ -1066,11 +1072,14 @@ public composite VgwDataRouterToWatsonSTT {
10661072
} // End of if (has(_vgwSessionIdToUdpChannelMap, _key)
10671073

10681074
appTrc(Trace.debug, "vgwSessionId=" + BSD.vgwSessionId +
1075+
", callSequenceNumber=" + (rstring)BSD.callSequenceNumber +
10691076
", isCustomerSpeechData=" + (rstring)BSD.isCustomerSpeechData +
10701077
", vgwVoiceChannelNumber=" + (rstring)BSD.vgwVoiceChannelNumber +
10711078
", speechDataFragmentCnt=" + (rstring)BSD.speechDataFragmentCnt +
10721079
", totalSpeechDataBytesReceived=" +
10731080
(rstring)BSD.totalSpeechDataBytesReceived +
1081+
", speechProcessorId=" +
1082+
(rstring)$idOfThisSpeechProcessor +
10741083
", speechEngineId=" + (rstring)BSD.speechEngineId +
10751084
", speechResultProcessorId=" + (rstring)BSD.speechResultProcessorId);
10761085
// Set the call start date time values to the tuple attributes.
@@ -1086,6 +1095,7 @@ public composite VgwDataRouterToWatsonSTT {
10861095
appTrc(Trace.error, "Received an EOCS at the speech processor id " +
10871096
(rstring)$idOfThisSpeechProcessor +
10881097
". vgwSessionId=" + BSD.vgwSessionId +
1098+
", callSequenceNumber=" + (rstring)BSD.callSequenceNumber +
10891099
", voiceChannelNumber=" + (rstring)BSD.vgwVoiceChannelNumber);
10901100
//
10911101
// Process the end of voice call signal.
@@ -1246,15 +1256,18 @@ public composite VgwDataRouterToWatsonSTT {
12461256
mutable int32 err = 0ul;
12471257
rstring eocsFileName = dataDirectory() + "/" +
12481258
BSD.vgwSessionId + "-call-completed.txt";
1249-
uint64 fileHandle = fopen (eocsFileName, "w+", err);
1259+
uint64 fileHandle = fopen (eocsFileName, "a+", err);
12501260

12511261
if(err == 0) {
1252-
fwriteString ("VGW call session id " + BSD.vgwSessionId +
1253-
" ended at " + ctime(getTimestamp()) + ".", fileHandle, err);
1262+
fwriteString ("VGW call session id " + BSD.vgwSessionId +
1263+
", Call sequence number=" + (rstring)BSD.callSequenceNumber +
1264+
" ended at " + ctime(getTimestamp()) + ".\n", fileHandle, err);
12541265
fclose(fileHandle, err);
12551266
}
12561267

1257-
appTrc(Trace.error, "An ongoing voice call has completed. vgwSessionId=" + BSD.vgwSessionId);
1268+
appTrc(Trace.error, "An ongoing voice call has completed. vgwSessionId=" +
1269+
BSD.vgwSessionId + ", callSequenceNumber=" +
1270+
(rstring)BSD.callSequenceNumber);
12581271
}
12591272
}
12601273
} // End of if(BSD.endOfCallSignal == false)
@@ -1702,9 +1715,60 @@ public composite STTResultProcessor(input MyTranscriptionResult, BinarySpeechDat
17021715
mutable rstring _ciscoGuid = "";
17031716
mutable rstring _callStartDateTime = "";
17041717
mutable int64 _callStartTimeInEpochSeconds = 0l;
1718+
mutable boolean _sttErrorObserved = false;
17051719
}
17061720

17071721
onTuple MTR: {
1722+
// WatsonSTT operator invocation done above is susceptible for
1723+
// encountering errors while attempting to transcribe a
1724+
// speech payload due to any critical errors happening in
1725+
// the backend STT infrastructure. Such errors can include
1726+
// "Unable to transcode the Mulaw speech data" (OR)
1727+
// "Session timed out with the STT backend" and so on.
1728+
// When that situation occurs, WatsonSTT operator will
1729+
// set a descriptive error message in the sttErrorMessage tuple
1730+
// attribute that will arrive here. After encountering such
1731+
// critical error, WatsonSTT operator will also send an
1732+
// immediate next tuple by setting the transcriptionCompleted
1733+
// tuple attribute to true.
1734+
// We have to take care of such error conditions here by
1735+
// tracking two such consecutive tuples (a tuple with its
1736+
// sttErrorMessage attribute set to a non-empty string and an
1737+
// immediate next tuple with its transcriptionCompleted attribute
1738+
// set to true) and then by not sending that intermittent
1739+
// transcription completed signal to the downstream application logic.
1740+
//
1741+
if (MTR.sttErrorMessage != "") {
1742+
// This tuple indicates that a critical error occurred in
1743+
// the upstream WatsonSTT operator. Let us record this
1744+
// condition in our state variable and look out for the
1745+
// immediate next tuple that will arrive here with its
1746+
// transcriptionCompleted attribute set to true.
1747+
_sttErrorObserved = true;
1748+
1749+
// We will let this tuple carrying the error message propagate
1750+
// to the downstream application logic so that it can get written
1751+
// to the full transcription result file.
1752+
}
1753+
1754+
// Look out for the immediate next tuple that arrives here after
1755+
// we observed any STT backend critical error.
1756+
if (_sttErrorObserved == true && MTR.transcriptionCompleted == true) {
1757+
// This tuple is the one that comes right after a tuple that
1758+
// carried an STT critical error message. We don't have to propagate
1759+
// this tuple to downstream logic as this is not the real end of a
1760+
// voice call as it is only indicating an intermittent error condition.
1761+
// Reset the STT error observed state variable.
1762+
_sttErrorObserved = false;
1763+
return;
1764+
}
1765+
1766+
// If there is no STT error message present in the received tuple,
1767+
// we will safely reset this particular state variable.
1768+
if (MTR.sttErrorMessage == "") {
1769+
_sttErrorObserved = false;
1770+
}
1771+
17081772
// In some cases, it was observed during testing that the
17091773
// call start time details arrive here with empty and 0 values.
17101774
// To compensate for that, we are going to keep a local copy

samples/VgwDataRouterToWatsonSTT/info.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
<info:identity>
55
<info:name>VgwDataRouterToWatsonSTT</info:name>
66
<info:description>Example that showcases STT on Cloud and STT on CP4D</info:description>
7-
<info:version>1.0.6</info:version>
7+
<info:version>1.0.7</info:version>
88
<info:requiredProductVersion>4.2.1.6</info:requiredProductVersion>
99
</info:identity>
1010
<info:dependencies>
1111
<info:toolkit>
1212
<common:name>com.ibm.streamsx.sttgateway</common:name>
13-
<common:version>[2.3.3,7.0.0]</common:version>
13+
<common:version>[2.3.4,7.0.0]</common:version>
1414
</info:toolkit>
1515
<info:toolkit>
1616
<common:name>com.ibm.streamsx.json</common:name>

samples/VgwDataRouterToWatsonSTTMini/com.ibm.streamsx.sttgateway.sample.watsonstt/VgwDataRouterToWatsonSTT.spl

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/*
99
==============================================
1010
First created on: Nov/27/2020
11-
Last modified on: May/10/2022
11+
Last modified on: May/11/2022
1212

1313
IMPORTANT NOTE
1414
--------------
@@ -932,13 +932,15 @@ public composite VgwDataRouterToWatsonSTT {
932932

933933
rstring socsFileName = dataDirectory() + "/" +
934934
BSD.vgwSessionId + "-call-started.txt";
935-
uint64 fileHandle = fopen (socsFileName, "w+", err);
935+
uint64 fileHandle = fopen (socsFileName, "a+", err);
936936

937937
if(err == 0) {
938938
fwriteString ("VGW call session id " + BSD.vgwSessionId +
939939
" started at " + BSD.callStartDateTime + ".\n",
940940
fileHandle, err);
941-
fwriteString("VGW voice channel number=" +
941+
fwriteString("Call sequence number=" +
942+
(rstring)BSD.callSequenceNumber +
943+
", VGW voice channel number=" +
942944
(rstring)BSD.vgwVoiceChannelNumber +
943945
", Speech processor id=" +
944946
(rstring)$idOfThisSpeechProcessor +
@@ -949,7 +951,9 @@ public composite VgwDataRouterToWatsonSTT {
949951
fclose(fileHandle, err);
950952
}
951953

952-
appTrc(Trace.error, "A new voice call has started. vgwSessionId=" + BSD.vgwSessionId);
954+
appTrc(Trace.error, "A new voice call has started. vgwSessionId=" +
955+
BSD.vgwSessionId + ", callSequenceNumber=" +
956+
(rstring)BSD.callSequenceNumber);
953957
} else if (has(_vgwSessionIdToUdpChannelMap, key1) == false ||
954958
has(_vgwSessionIdToUdpChannelMap, key2) == false) {
955959
// This means, one of the two voice channels in a
@@ -964,7 +968,9 @@ public composite VgwDataRouterToWatsonSTT {
964968
uint64 fileHandle = fopen (socsFileName, "a+", err);
965969

966970
if(err == 0) {
967-
fwriteString("VGW voice channel number=" +
971+
fwriteString("Call sequence number=" +
972+
(rstring)BSD.callSequenceNumber +
973+
", VGW voice channel number=" +
968974
(rstring)BSD.vgwVoiceChannelNumber +
969975
", Speech processor id=" +
970976
(rstring)$idOfThisSpeechProcessor +
@@ -983,11 +989,14 @@ public composite VgwDataRouterToWatsonSTT {
983989
} // End of if (has(_vgwSessionIdToUdpChannelMap, _key)
984990

985991
appTrc(Trace.debug, "vgwSessionId=" + BSD.vgwSessionId +
992+
", callSequenceNumber=" + (rstring)BSD.callSequenceNumber +
986993
", isCustomerSpeechData=" + (rstring)BSD.isCustomerSpeechData +
987994
", vgwVoiceChannelNumber=" + (rstring)BSD.vgwVoiceChannelNumber +
988995
", speechDataFragmentCnt=" + (rstring)BSD.speechDataFragmentCnt +
989996
", totalSpeechDataBytesReceived=" +
990997
(rstring)BSD.totalSpeechDataBytesReceived +
998+
", speechProcessorId=" +
999+
(rstring)$idOfThisSpeechProcessor +
9911000
", speechEngineId=" + (rstring)BSD.speechEngineId +
9921001
", speechResultProcessorId=" + (rstring)BSD.speechResultProcessorId);
9931002
// Set the call start date time values to the tuple attributes.
@@ -1003,6 +1012,7 @@ public composite VgwDataRouterToWatsonSTT {
10031012
appTrc(Trace.error, "Received an EOCS at the speech processor id " +
10041013
(rstring)$idOfThisSpeechProcessor +
10051014
". vgwSessionId=" + BSD.vgwSessionId +
1015+
", callSequenceNumber=" + (rstring)BSD.callSequenceNumber +
10061016
", voiceChannelNumber=" + (rstring)BSD.vgwVoiceChannelNumber);
10071017
//
10081018
// Process the end of voice call signal.
@@ -1158,15 +1168,18 @@ public composite VgwDataRouterToWatsonSTT {
11581168
mutable int32 err = 0ul;
11591169
rstring eocsFileName = dataDirectory() + "/" +
11601170
BSD.vgwSessionId + "-call-completed.txt";
1161-
uint64 fileHandle = fopen (eocsFileName, "w+", err);
1171+
uint64 fileHandle = fopen (eocsFileName, "a+", err);
11621172

11631173
if(err == 0) {
1164-
fwriteString ("VGW call session id " + BSD.vgwSessionId +
1165-
" ended at " + ctime(getTimestamp()) + ".", fileHandle, err);
1174+
fwriteString ("VGW call session id " + BSD.vgwSessionId +
1175+
", Call sequence number=" + (rstring)BSD.callSequenceNumber +
1176+
" ended at " + ctime(getTimestamp()) + ".\n", fileHandle, err);
11661177
fclose(fileHandle, err);
11671178
}
11681179

1169-
appTrc(Trace.error, "An ongoing voice call has completed. vgwSessionId=" + BSD.vgwSessionId);
1180+
appTrc(Trace.error, "An ongoing voice call has completed. vgwSessionId=" +
1181+
BSD.vgwSessionId + ", callSequenceNumber=" +
1182+
(rstring)BSD.callSequenceNumber);
11701183
}
11711184
}
11721185
} // End of if(BSD.endOfCallSignal == false)
@@ -1525,9 +1538,60 @@ public composite STTResultProcessor(input MyTranscriptionResult) {
15251538
mutable rstring _ciscoGuid = "";
15261539
mutable rstring _callStartDateTime = "";
15271540
mutable int64 _callStartTimeInEpochSeconds = 0l;
1541+
mutable boolean _sttErrorObserved = false;
15281542
}
15291543

15301544
onTuple MTR: {
1545+
// WatsonSTT operator invocation done above is susceptible for
1546+
// encountering errors while attempting to transcribe a
1547+
// speech payload due to any critical errors happening in
1548+
// the backend STT infrastructure. Such errors can include
1549+
// "Unable to transcode the Mulaw speech data" (OR)
1550+
// "Session timed out with the STT backend" and so on.
1551+
// When that situation occurs, WatsonSTT operator will
1552+
// set a descriptive error message in the sttErrorMessage tuple
1553+
// attribute that will arrive here. After encountering such
1554+
// critical error, WatsonSTT operator will also send an
1555+
// immediate next tuple by setting the transcriptionCompleted
1556+
// tuple attribute to true.
1557+
// We have to take care of such error conditions here by
1558+
// tracking two such consecutive tuples (a tuple with its
1559+
// sttErrorMessage attribute set to a non-empty string and an
1560+
// immediate next tuple with its transcriptionCompleted attribute
1561+
// set to true) and then by not sending that intermittent
1562+
// transcription completed signal to the downstream application logic.
1563+
//
1564+
if (MTR.sttErrorMessage != "") {
1565+
// This tuple indicates that a critical error occurred in
1566+
// the upstream WatsonSTT operator. Let us record this
1567+
// condition in our state variable and look out for the
1568+
// immediate next tuple that will arrive here with its
1569+
// transcriptionCompleted attribute set to true.
1570+
_sttErrorObserved = true;
1571+
1572+
// We will let this tuple carrying the error message propagate
1573+
// to the downstream application logic so that it can get written
1574+
// to the full transcription result file.
1575+
}
1576+
1577+
// Look out for the immediate next tuple that arrives here after
1578+
// we observed any STT backend critical error.
1579+
if (_sttErrorObserved == true && MTR.transcriptionCompleted == true) {
1580+
// This tuple is the one that comes right after a tuple that
1581+
// carried an STT critical error message. We don't have to propagate
1582+
// this tuple to downstream logic as this is not the real end of a
1583+
// voice call as it is only indicating an intermittent error condition.
1584+
// Reset the STT error observed state variable.
1585+
_sttErrorObserved = false;
1586+
return;
1587+
}
1588+
1589+
// If there is no STT error message present in the received tuple,
1590+
// we will safely reset this particular state variable.
1591+
if (MTR.sttErrorMessage == "") {
1592+
_sttErrorObserved = false;
1593+
}
1594+
15311595
// In some cases, it was observed during testing that the
15321596
// call start time details arrive here with empty and 0 values.
15331597
// To compensate for that, we are going to keep a local copy

samples/VgwDataRouterToWatsonSTTMini/info.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
<info:identity>
44
<info:name>VgwDataRouterToWatsonSTTMini</info:name>
55
<info:description>Example that showcases STT on Cloud and STT on CP4D</info:description>
6-
<info:version>1.0.6</info:version>
6+
<info:version>1.0.7</info:version>
77
<info:requiredProductVersion>4.2.1.6</info:requiredProductVersion>
88
</info:identity>
99
<info:dependencies>
1010
<info:toolkit>
1111
<common:name>com.ibm.streamsx.sttgateway</common:name>
12-
<common:version>[2.3.3,7.0.0]</common:version>
12+
<common:version>[2.3.4,7.0.0]</common:version>
1313
</info:toolkit>
1414
<info:toolkit>
1515
<common:name>com.ibm.streamsx.websocket</common:name>

0 commit comments

Comments
 (0)