int main() { cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! FileStream fileStream = File.OpenRead("recorded.flac");//my.flac MemoryStream memoryStream = new MemoryStream(); memoryStream.SetLength(fileStream.Length); fileStream.Read(memoryStream.GetBuffer(), 0, (int)fileStream.Length); byte[] BA_AudioFile = memoryStream.GetBuffer(); HttpWebRequest _HWR_SpeechToText = null; _HWR_SpeechToText = (HttpWebRequest)HttpWebRequest.Create("https://www.google.com/speech-api/v2/recognize?output=json&lang=en-us&key=" + ACCESS_GOOGLE_SPEECH_KEY); _HWR_SpeechToText.Credentials = CredentialCache.DefaultCredentials; _HWR_SpeechToText.Method = "POST"; _HWR_SpeechToText.ContentType = "audio/x-flac; rate=44100"; _HWR_SpeechToText.ContentLength = BA_AudioFile.Length; Stream stream = _HWR_SpeechToText.GetRequestStream(); stream.Write(BA_AudioFile, 0, BA_AudioFile.Length); stream.Close(); HttpWebResponse HWR_Response = (HttpWebResponse)_HWR_SpeechToText.GetResponse(); StreamReader SR_Response = new StreamReader(HWR_Response.GetResponseStream()); string responseFromServer = (SR_Response.ReadToEnd()); String[] jsons = responseFromServer.Split('\n'); foreach (String j in jsons) { dynamic jsonObject = JsonConvert.DeserializeObject(j); if (jsonObject == null || jsonObject.result.Count <= 0) { continue; } text = jsonObject.result[0].alternative[0].transcript; jsons = null; }
static PyObject *SpectrumMS2(PyObject *self, PyObject *args) { const char *szFileName; long nWidth, nHeight; float nMinTime = -1.0f, nMaxTime = -1.0f, nMinMz = -1.0f, nMaxMz = -1.0f; if (!PyArg_ParseTuple(args, "sll|ffff", &szFileName, &nWidth, &nHeight, &nMinTime, &nMaxTime, &nMinMz, &nMaxMz)) { return NULL; } if (nWidth <= 0 || nHeight <= 0) { return Py_BuildValue(""); } MemoryStream *pStream = MS2Plot::RenderFromFile(szFileName, nWidth, nHeight, nMinTime, nMaxTime, nMinMz, nMaxMz); PyObject *pRet = pStream == NULL ? Py_BuildValue("") : Py_BuildValue("s#", pStream->GetBuffer(), pStream->GetLength()); delete pStream; return pRet; }