Beispiel #1
0
        private void processRecord(MemoryStream record)
        {
            var wav  = SoundTools.ConvertSamplesToWavFileFormat(record, sampleRate);
            var flac = new MemoryStream();

            SoundTools.Wav2Flac(wav, flac);
            try
            {
                var result = GoogleVoice.GoogleSpeechRequest(flac, sampleRate, Language, MaxResults);
                if (result.Length > 0)
                {
                    if (OnSpeechRecognized != null)
                    {
                        OnSpeechRecognized(result);
                    }
                }
                else if (OnSpeechRecognizeFailed != null)
                {
                    OnSpeechRecognizeFailed();
                }
            }
            catch (Exception ex)
            {
                if (OnGoogleError != null)
                {
                    OnGoogleError(ex);
                }
            }
        }
Beispiel #2
0
 private void EmptyRequest()
 {
     try
     {
         GoogleVoice.GoogleSpeechRequest(new MemoryStream(), sampleRate);
     }
     catch { }
 }
Beispiel #3
0
        private void SendFile(String filePath)
        {
            try
            {
                ReportOnProgress(10, "İstek başladı!");
                string responseFromServer = GoogleVoice.GoogleSpeechRequest(filePath, "tmp.flac");
                responseFromServer = responseFromServer
                                     .Replace("{\"result\":[]}\n{\"result\":[", "")
                                     .Replace("],\"result_index\":0}", "");

                var table = JsonConvert.DeserializeObject <Results>(responseFromServer).Alternatives;
                txtLog.Clear();
                //AddLog(table.Rows[0].ItemArray[0].ToString());

                for (int i = 0; i < table.Rows.Count; i++)
                {
                    var item = table.Rows[i];
                    if (item.ItemArray.Count() > 1)
                    {
                        if (item.ItemArray[1].ToString() != "")
                        {
                            AddLog(item.ItemArray[0].ToString());

                            //AddLog(item.ItemArray[0].ToString() + "--" + item.ItemArray[1].ToString() + System.Environment.NewLine);
                            return;
                        }
                    }
                    else
                    {
                        AddLog(item.ItemArray[0].ToString() + System.Environment.NewLine);
                    }
                }

                ReportOnProgress(100, "Sorgu başarıyla tamamlandı");
            }
            catch (Exception e)
            {
                ReportOnProgress(100, "İstek başarısız! Hata Sebebi : " + e.Message);
                AddLog(e.ToString());
            }
        }