本文整理汇总了C++中MemoryStream::GetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryStream::GetBuffer方法的具体用法?C++ MemoryStream::GetBuffer怎么用?C++ MemoryStream::GetBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryStream
的用法示例。
在下文中一共展示了MemoryStream::GetBuffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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;
}
示例2: Py_BuildValue
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;
}