Skip to content

Commit 2433956

Browse files
committed
fix(Speech to Text V1): Updated double parsing for word confidence
The service sends an int for word confidence rather than a double. We now convert this to a string and parse the double from the string.
1 parent 730bcc4 commit 2433956

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Scripts/Services/SpeechToText/v1/SpeechToText.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,6 @@ private SpeechRecognitionEvent ParseRecognizeResponse(IDictionary resp)
12981298
if (ialternative.Contains("word_confidence"))
12991299
{
13001300
IList iconfidence = ialternative["word_confidence"] as IList;
1301-
13021301
WordConfidence[] confidence = new WordConfidence[iconfidence.Count];
13031302
for (int i = 0; i < iconfidence.Count; ++i)
13041303
{
@@ -1308,7 +1307,9 @@ private SpeechRecognitionEvent ParseRecognizeResponse(IDictionary resp)
13081307

13091308
WordConfidence wc = new WordConfidence();
13101309
wc.Word = (string)iwordconf[0];
1311-
wc.Confidence = (double)iwordconf[1];
1310+
string wordConf = iwordconf[1].ToString();
1311+
double.TryParse(wordConf, out double wordConfDouble);
1312+
wc.Confidence = wordConfDouble;
13121313
confidence[i] = wc;
13131314
}
13141315

0 commit comments

Comments
 (0)