Unity Community


Results 1 to 13 of 13

  1. Posts
    15

    Voice recognition in Unity?

    Is there any plugin or library for Unity to do voice/speech recognition? Many thanks~


  2. Location
    Groningen, Netherlands
    Posts
    186
    1st year of Internation Game Architecture and Design (Indie Game Development), NHTV, Netherlands
    Past: 4y Game Artist education


  3. Location
    USA
    Posts
    1,224
    Quote Originally Posted by Crash-Konijn View Post
    You know, in some forums I've participated in, telling someone to "just google it" is a ban-able offense.

    If you don't know the answer, maybe you should avoid the thread entirely?


  4. Location
    Groningen, Netherlands
    Posts
    186
    Sorry my bad, I guess its not my day... I just got a littly cracky this morning about these topics. Still, there's also a thing called google first and then ask on the forum

    If you google that you can see that there are several topics about the same question so there should be an answer on this question... If I ask a question I can guarantee you that I've been on every topic/question/link I could find on google about the problem I have... It would be better if the question was something like:

    "Hey guys, I've been looking on the internet for hours but I can't find an answer that satisfies my needs. I found this, this and this info but no-one has ever posted a real answer on that so I thought I give it another shot... "

    Or he could already have found his answer. But again, sorry, I should not have done that, I'll just keep my mouth shut with such questions in future
    1st year of Internation Game Architecture and Design (Indie Game Development), NHTV, Netherlands
    Past: 4y Game Artist education


  5. Location
    Barcelona
    Posts
    94
    Maybe it's not what you are looking for, but if you are planning to use a webplayer with your project, you could try using the html5 Google Chrome voice recognition.

    Just make a text input and enable speech recognition. Then grab the text and use it in Unity.
    View our latest projects, tutorials and showcases at Catsoft Studios


  6. Posts
    15
    I would like to create a game in exe format, not for webplayer. Maybe for mobile also. Is there any good solution for that?


  7. Location
    Barcelona
    Posts
    94
    If you want to create an .apk for Android, there must be a way to do it. I've made some projects for Android and I've used Speech Recognition. The thing is that I don't know if you can use this API in Unity.

    And for Windows... no idea.
    View our latest projects, tutorials and showcases at Catsoft Studios


  8. Posts
    1
    I googled "voice recognition in unity", found this thread, found a link to the "let me google that for you" thing. Now I'm stuck in an infinite loop. Thanks a lot


  9. Location
    Russia
    Posts
    1
    If somebody is still interested, I could add some words into the thread.

    I am currently working on the project where I'm trying to use Google Voice API as a voice recognition service. Implementation is fairly simple using some external modules.

    A sequence is as following: record and save wav -> convert wav to flac -> send flac to Google -> parse JSON response. In Unity on Windo$e I'm at last step now - having some issues with parsing JSON. The rest of the process is quite ok, except it does not work as exe or apk lol (there is a problem with the Cuetools lib).

    Here is code that makes a request and gets a response:

    Code:  
    1. filepath = SavWav.Save("recording", _goAudioSource.clip); //save file from recording using SavWav lib
    2. const string flacName = "tmpFlac";
    3. int sampleRate = SoundTools.Wav2Flac(filepath, flacName); //get sample rate from SoundTools lib
    4.  
    5. private IEnumerator WwwGoogleSpeechRequest(String flacName, int sampleRate)
    6.     {
    7.         const string url = "http://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=ru-RU";
    8.  
    9.         Debug.Log("Entering request method");
    10.  
    11.         byte[] postData = File.ReadAllBytes(flacName);
    12.  
    13.         Debug.Log("Read flac file. Size: " + postData.Length + " bytes");
    14.  
    15.         //set up POST request parameters
    16.         var form = new WWWForm();
    17.  
    18.         var headers = form.headers;
    19.        
    20.         headers["Method"] = "POST";
    21.         headers["Content-Type"] = "audio/x-flac; rate=" + sampleRate;
    22.         headers["Content-Length"] = postData.Length;
    23.         headers["Accept"] = "application/json";
    24.  
    25.         form.AddBinaryData("fileUpload", postData, "flacFile", "audio/x-flac; rate=" + sampleRate);
    26.         var httpRequest = new WWW(url, form.data, headers);
    27.  
    28.         yield return httpRequest;
    29.  
    30.         if (httpRequest.isDone && string.IsNullOrEmpty(httpRequest.error))
    31.         {
    32.             //_response = String.Format("Request succeeded. Request data: {0}{1}", Environment.NewLine, httpRequest.text);
    33.             _response = httpRequest.text.Substring(1);
    34.             Debug.Log(_response);
    35.             _response = ParseResponse(_response);
    36.             Debug.Log("Request succeeded. Request data: " + _response);
    37.         }
    38.         else
    39.         {
    40.             _response = String.Format("Request failed with Error: {0}{1}", Environment.NewLine, httpRequest.error);
    41.             Debug.Log(String.Format("Request failed with Error: {0}", httpRequest.error));
    42.         }
    43.     }

    It works when I click Play in Unity, however there are still many bugs all over the whole voice-to-text process, so the solution is not quite useable when built as exe or apk or something else.
    Last edited by phil_g; 06-07-2013 at 03:28 AM.


  10. Posts
    23
    Quote Originally Posted by phil_g View Post
    If somebody is still interested, I could add some words into the thread.

    I am currently working on the project where I'm trying to use Google Voice API as a voice recognition service. Implementation is fairly simple using some external modules.

    A sequence is as following: record and save wav -> convert wav to flac -> send flac to Google -> parse JSON response. In Unity on Windo$e I'm at last step now - having some issues with parsing JSON. The rest of the process is quite ok, except it does not work as exe or apk lol (there is a problem with the Cuetools lib).

    Here is code that makes a request and gets a response:

    Code:  
    1. filepath = SavWav.Save("recording", _goAudioSource.clip); //save file from recording using SavWav lib
    2. const string flacName = "tmpFlac";
    3. int sampleRate = SoundTools.Wav2Flac(filepath, flacName); //get sample rate from SoundTools lib
    4.  
    5. private IEnumerator WwwGoogleSpeechRequest(String flacName, int sampleRate)
    6.     {
    7.         const string url = "http://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=ru-RU";
    8.  
    9.         Debug.Log("Entering request method");
    10.  
    11.         byte[] postData = File.ReadAllBytes(flacName);
    12.  
    13.         Debug.Log("Read flac file. Size: " + postData.Length + " bytes");
    14.  
    15.         //set up POST request parameters
    16.         var form = new WWWForm();
    17.  
    18.         var headers = form.headers;
    19.        
    20.         headers["Method"] = "POST";
    21.         headers["Content-Type"] = "audio/x-flac; rate=" + sampleRate;
    22.         headers["Content-Length"] = postData.Length;
    23.         headers["Accept"] = "application/json";
    24.  
    25.         form.AddBinaryData("fileUpload", postData, "flacFile", "audio/x-flac; rate=" + sampleRate);
    26.         var httpRequest = new WWW(url, form.data, headers);
    27.  
    28.         yield return httpRequest;
    29.  
    30.         if (httpRequest.isDone && string.IsNullOrEmpty(httpRequest.error))
    31.         {
    32.             //_response = String.Format("Request succeeded. Request data: {0}{1}", Environment.NewLine, httpRequest.text);
    33.             _response = httpRequest.text.Substring(1);
    34.             Debug.Log(_response);
    35.             _response = ParseResponse(_response);
    36.             Debug.Log("Request succeeded. Request data: " + _response);
    37.         }
    38.         else
    39.         {
    40.             _response = String.Format("Request failed with Error: {0}{1}", Environment.NewLine, httpRequest.error);
    41.             Debug.Log(String.Format("Request failed with Error: {0}", httpRequest.error));
    42.         }
    43.     }

    It works when I click Play in Unity, however there are still many bugs all over the whole voice-to-text process, so the solution is not quite useable when built as exe or apk or something else.
    Where is this function sampleRate = SoundTools.Wav2Flac(filepath, flacName);

    can you please post a more complete code, where did you get SoundTools?? Thanks




  11. Location
    Poland
    Posts
    11
    I try use it but not work. Its part some wider project. How can I use it in practice?
    E-learning developer, DAZ Carrara graphic designer, http://www.e-marketing.pl.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •