in nlsCsharpSdk/nlsCsharpSdkDemo/nlsCsharpSdkDemo.cs [1195:1287]
private void button6_Click(object sender, EventArgs e)
{
int ret = -1;
if (srList == null)
{
nlsResult.Text = "recognizer list is null, create first...";
return;
}
else
{
if (File.Exists(cur_sr_file_path))
{
}
else
{
cur_sr_completed = "cannot open file: " + cur_sr_file_path;
return;
}
LinkedListNode<DemoSpeechRecognizerStruct> srStruct = srList.First;
int sr_count = srList.Count;
for (int i = 0; i < sr_count; i++)
{
DemoSpeechRecognizerStruct sr = srStruct.Value;
if (sr.srPtr.native_request != IntPtr.Zero)
{
if (appKey == null || appKey.Length == 0)
{
appKey = tAppKey.Text;
}
if (token == null || token.Length == 0)
{
token = tToken.Text;
}
if (appKey == null || token == null ||
appKey.Length == 0 || token.Length == 0)
{
nlsResult.Text = "Start failed, token or appkey is empty";
return;
}
sr.srPtr.SetAppKey(sr.srPtr, appKey);
sr.srPtr.SetToken(sr.srPtr, token);
sr.srPtr.SetUrl(sr.srPtr, url);
sr.srPtr.SetFormat(sr.srPtr, "pcm");
sr.srPtr.SetSampleRate(sr.srPtr, 16000);
sr.srPtr.SetIntermediateResult(sr.srPtr, true);
sr.srPtr.SetPunctuationPrediction(sr.srPtr, true);
sr.srPtr.SetInverseTextNormalization(sr.srPtr, true);
sr.srPtr.SetOnRecognitionStarted(sr.srPtr, DemoOnRecognitionStarted, sr.uuid);
sr.srPtr.SetOnChannelClosed(sr.srPtr, DemoOnRecognitionClosed, sr.uuid);
sr.srPtr.SetOnTaskFailed(sr.srPtr, DemoOnRecognitionTaskFailed, sr.uuid);
sr.srPtr.SetOnRecognitionResultChanged(sr.srPtr, DemoOnRecognitionResultChanged, sr.uuid);
sr.srPtr.SetOnRecognitionCompleted(sr.srPtr, DemoOnRecognitionCompleted, sr.uuid);
ret = sr.srPtr.Start(sr.srPtr);
if (ret != 0)
{
nlsResult.Text = "recognizer Start failed";
}
else
{
if (globalRunParams[sr.uuid].audio_loop_flag == false)
{
RunParams demo_params = new RunParams();
demo_params.audio_loop_flag = true;
demo_params.send_audio_flag = globalRunParams[sr.uuid].send_audio_flag;
globalRunParams.Remove(sr.uuid);
globalRunParams.Add(sr.uuid, demo_params);
sr.sr_send_audio = new Thread(new ParameterizedThreadStart(SRAudioLab));
sr.sr_send_audio.Start((object)sr);
btnSRstart.Enabled = false;
btnSRstop.Enabled = true;
}
nlsResult.Text = "Recognizer Start success";
}
}
else
{
}
srStruct = srStruct.Next;
if (srStruct == null)
{
break;
}
}
}
}