- Home /
Has anyone used windows bing speech to text in Unity for hololens?
Hi, I am trying to build a voice enabled interactive chat application on hololens. For speech to text conversion i am using Unity's built-in class DictationRecognizer for now. But its perfomance is very poor. When i try to use Bing REST API, i am getting error.
try { var token = auth.GetAccessToken(); Console.WriteLine("Token: {0}\n", token); Console.WriteLine("Request Uri: " + requestUri + Environment.NewLine);
HttpWebRequest request = null;
request = (HttpWebRequest)HttpWebRequest.Create(requestUri);
request.SendChunked = true;
request.Accept = @"application/json;text/xml";
request.Method = "POST";
request.ProtocolVersion = HttpVersion.Version11;
//request.Host = host;
request.ContentType = contentType;
request.Headers["Authorization"] = "Bearer " + token;
//request.UseDefaultCredentials = true;
request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
using (fs = new FileStream(audioFile, FileMode.Open, FileAccess.Read))
{
/*
* Open a request stream and write 1024 byte chunks in the stream one at a time.
*/
byte[] buffer = null;
int bytesRead = 0;
using (Stream requestStream = request.GetRequestStream())
{
/*
* Read 1024 raw bytes from the input audio file.
*/
buffer = new Byte[checked((uint)Math.Min(1024, (int)fs.Length))];
while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) != 0)
{
requestStream.Write(buffer, 0, bytesRead);
}
// Flush
requestStream.Flush();
}
/*
* Get the response from the service.
*/
Console.WriteLine("Response:");
using (WebResponse response = request.GetResponse())
{
Console.WriteLine(((HttpWebResponse)response).StatusCode);
using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
responseString = sr.ReadToEnd();
}
Console.WriteLine(responseString);
Console.ReadLine();
File.Delete(filePath);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Console.WriteLine(ex.Message);
Console.ReadLine();
File.Delete(filePath);
}
Answer by Deftsoft1 · Feb 27, 2018 at 12:33 PM
i dont know what is your target but for speech to text in hololens its better to use IBM watson it can be used for microsoft hololens also.
IB$$anonymous$$ Watson i have tried. But i feel DictationRecognizer is better than that
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
error cs0236 field initializer cannot reference a nonestatic field, method or property 1 Answer
Entering/Exiting Vehicles Part 2 1 Answer
Compiler errors? 2 Answers