@@ -1176,10 +1176,10 @@ private SpeakerRecognitionEvent ParseSpeakerRecognitionResponse(IDictionary resp
1176
1176
continue ;
1177
1177
1178
1178
SpeakerLabelsResult result = new SpeakerLabelsResult ( ) ;
1179
- result . confidence = ( double ) iresult [ "confidence" ] ;
1179
+ result . confidence = Utility . StringToDouble ( iresult [ "confidence" ] . ToString ( ) ) ;
1180
1180
result . final = ( bool ) iresult [ "final" ] ;
1181
- result . from = ( double ) iresult [ "from" ] ;
1182
- result . to = ( double ) iresult [ "to" ] ;
1181
+ result . from = Utility . StringToDouble ( iresult [ "from" ] . ToString ( ) ) ;
1182
+ result . to = Utility . StringToDouble ( iresult [ "to" ] . ToString ( ) ) ;
1183
1183
result . speaker = ( Int64 ) iresult [ "speaker" ] ;
1184
1184
1185
1185
results . Add ( result ) ;
@@ -1229,9 +1229,9 @@ private SpeechRecognitionEvent ParseRecognizeResponse(IDictionary resp)
1229
1229
1230
1230
WordAlternativeResults wordAlternativeResults = new WordAlternativeResults ( ) ;
1231
1231
if ( iwordAlternative . Contains ( "start_time" ) )
1232
- wordAlternativeResults . start_time = ( double ) iwordAlternative [ "start_time" ] ;
1232
+ wordAlternativeResults . start_time = Utility . StringToDouble ( iwordAlternative [ "start_time" ] . ToString ( ) ) ;
1233
1233
if ( iwordAlternative . Contains ( "end_time" ) )
1234
- wordAlternativeResults . end_time = ( double ) iwordAlternative [ "end_time" ] ;
1234
+ wordAlternativeResults . end_time = Utility . StringToDouble ( iwordAlternative [ "end_time" ] . ToString ( ) ) ;
1235
1235
if ( iwordAlternative . Contains ( "alternatives" ) )
1236
1236
{
1237
1237
List < WordAlternativeResult > wordAlternativeResultList = new List < WordAlternativeResult > ( ) ;
@@ -1246,7 +1246,7 @@ private SpeechRecognitionEvent ParseRecognizeResponse(IDictionary resp)
1246
1246
if ( ialternative . Contains ( "word" ) )
1247
1247
wordAlternativeResult . word = ( string ) ialternative [ "word" ] ;
1248
1248
if ( ialternative . Contains ( "confidence" ) )
1249
- wordAlternativeResult . confidence = ( double ) ialternative [ "confidence" ] ;
1249
+ wordAlternativeResult . confidence = Utility . StringToDouble ( ialternative [ "confidence" ] . ToString ( ) ) ;
1250
1250
wordAlternativeResultList . Add ( wordAlternativeResult ) ;
1251
1251
}
1252
1252
@@ -1273,7 +1273,7 @@ private SpeechRecognitionEvent ParseRecognizeResponse(IDictionary resp)
1273
1273
SpeechRecognitionAlternative alternative = new SpeechRecognitionAlternative ( ) ;
1274
1274
alternative . transcript = ( string ) ialternative [ "transcript" ] ;
1275
1275
if ( ialternative . Contains ( "confidence" ) )
1276
- alternative . confidence = ( double ) ialternative [ "confidence" ] ;
1276
+ alternative . confidence = Utility . StringToDouble ( ialternative [ "confidence" ] . ToString ( ) ) ;
1277
1277
1278
1278
if ( ialternative . Contains ( "timestamps" ) )
1279
1279
{
@@ -1288,8 +1288,8 @@ private SpeechRecognitionEvent ParseRecognizeResponse(IDictionary resp)
1288
1288
1289
1289
TimeStamp ts = new TimeStamp ( ) ;
1290
1290
ts . Word = ( string ) itimestamp [ 0 ] ;
1291
- ts . Start = ( double ) itimestamp [ 1 ] ;
1292
- ts . End = ( double ) itimestamp [ 2 ] ;
1291
+ ts . Start = Utility . StringToDouble ( itimestamp [ 1 ] . ToString ( ) ) ;
1292
+ ts . End = Utility . StringToDouble ( itimestamp [ 2 ] . ToString ( ) ) ;
1293
1293
timestamps [ i ] = ts ;
1294
1294
}
1295
1295
@@ -1307,9 +1307,7 @@ private SpeechRecognitionEvent ParseRecognizeResponse(IDictionary resp)
1307
1307
1308
1308
WordConfidence wc = new WordConfidence ( ) ;
1309
1309
wc . Word = ( string ) iwordconf [ 0 ] ;
1310
- string wordConf = iwordconf [ 1 ] . ToString ( ) ;
1311
- double . TryParse ( wordConf , out double wordConfDouble ) ;
1312
- wc . Confidence = wordConfDouble ;
1310
+ wc . Confidence = Utility . StringToDouble ( iwordconf [ 1 ] . ToString ( ) ) ;
1313
1311
confidence [ i ] = wc ;
1314
1312
}
1315
1313
@@ -1340,9 +1338,9 @@ private SpeechRecognitionEvent ParseRecognizeResponse(IDictionary resp)
1340
1338
IDictionary iKeywordDictionary = k as IDictionary ;
1341
1339
KeywordResult keywordResult = new KeywordResult ( ) ;
1342
1340
keywordResult . keyword = keyword ;
1343
- keywordResult . confidence = ( double ) iKeywordDictionary [ "confidence" ] ;
1344
- keywordResult . end_time = ( double ) iKeywordDictionary [ "end_time" ] ;
1345
- keywordResult . start_time = ( double ) iKeywordDictionary [ "start_time" ] ;
1341
+ keywordResult . confidence = Utility . StringToDouble ( iKeywordDictionary [ "confidence" ] . ToString ( ) ) ;
1342
+ keywordResult . end_time = Utility . StringToDouble ( iKeywordDictionary [ "end_time" ] . ToString ( ) ) ;
1343
+ keywordResult . start_time = Utility . StringToDouble ( iKeywordDictionary [ "start_time" ] . ToString ( ) ) ;
1346
1344
keywordResult . normalized_text = ( string ) iKeywordDictionary [ "normalized_text" ] ;
1347
1345
keywordResults . Add ( keywordResult ) ;
1348
1346
}
0 commit comments