Skip to content

Commit 9f9074f

Browse files
authored
Merge pull request #528 from watson-developer-cloud/527-speech-issues
Speech issues
2 parents dce6bc0 + 2433956 commit 9f9074f

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

Examples/ServiceExamples/Scripts/ExampleCustomHeaders.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public bool Active
182182
_speechToText.EnableWordConfidence = true;
183183
_speechToText.EnableTimestamps = true;
184184
_speechToText.SilenceThreshold = 0.01f;
185-
_speechToText.MaxAlternatives = 0;
185+
_speechToText.MaxAlternatives = 1;
186186
_speechToText.EnableInterimResults = true;
187187
_speechToText.OnError = OnError;
188188
_speechToText.InactivityTimeout = -1;

Examples/ServiceExamples/Scripts/ExampleStreaming.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public bool Active
102102
_service.EnableWordConfidence = true;
103103
_service.EnableTimestamps = true;
104104
_service.SilenceThreshold = 0.01f;
105-
_service.MaxAlternatives = 0;
105+
_service.MaxAlternatives = 1;
106106
_service.EnableInterimResults = true;
107107
_service.OnError = OnError;
108108
_service.InactivityTimeout = -1;

Examples/ServiceExamples/Scripts/ExampleStreamingSplitSamples.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public bool Active
108108
_service.EnableWordConfidence = true;
109109
_service.EnableTimestamps = true;
110110
_service.SilenceThreshold = 0.01f;
111-
_service.MaxAlternatives = 0;
111+
_service.MaxAlternatives = 1;
112112
_service.EnableInterimResults = true;
113113
_service.OnError = OnError;
114114
_service.InactivityTimeout = -1;

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)