Record/Save/Playback of Audio clips....

Hi All

I am making an Educational game to teach a language for it , in a moment of this one will appear one text word phrase and then the gamer will click a button to hear it.

So , I would need to do the following

1 Record the voice gamer using Microphone.
2 Save this one, to get this saved file into the project (saved) during run-time and play it.
3 Add a text saying the following
Very well !!! ( if the gamer say it well) or Try again !!! ( if the gamer say it badly)

If it is possible?
Thanks in advance
Castana1962
Ps. Hopefully you can understand me …Sorry for my little english

  1. Should not be that difficult:
    Unity - Scripting API: Microphone.Start
  2. Also no problem, but it’s not required to save the file to play it:
    https://www.google.nl/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwjW4ZOeg57XAhXHAxoKHfEeDm8QFggnMAA&url=http%3A%2F%2Fanswers.unity3d.com%2Fquestions%2F354401%2Fsave-audio-to-a-file.html&usg=AOvVaw0jdxpFlO9e7jTGhG8AChA3
    (Indirect link, because Unity answers is taking ages to load here.)
    3a. Playing a sound is also easy:
    Unity - Scripting API: AudioClip
    3b. Detecting whether the player said it well or not is very tricky indeed. Beyond this forum really and you’d be looking at trained neural networks to recognize what the player said. You could use speech to text, but that would change the difficulty based on how close the phrase is to other phrases.
1 Like

Hi jvo3dc
Thank you very much for our help !!!
According to your answer to the 3b point, I know that it is very hard to do it. I guess maybe if I could to compare both audio files ( original and gamer voice) and if the sound it is similar is ok or if it is not is baddly.Hope that anybody can have some idea about this topic…
Have a nice day !!!
Castana1962

Unity doesn’t have any built in functionality for voice recognition or in depth audio comparison. Its a very complex issue that I don’t expect anyone just starting on would have any chance of developing from scratch in any reasonable amount of time.

I’d be looking for 3rd party voice recognition plugins, but I’d be surprised if you found any specifically built with Unity in mind. Rather you’ll probably find something that can work once you figure out how to get it to work at all with Unity, likely with no instructions for doing so provided. That’s my guess at least, I hope you find something easier than that. The problem is this type of detailed voice recognition isn’t a typical game feature and is not easy to do, which is why I don’t expect you’ll find a ready made solution for a game engine like Unity.

A speech to text plug could get you part of the way, but it won’t tell you how well they spoke, only if what they said is understandable at all by the plug in. That might not be good enough for your project.

As far as detailed audio file comparisons on your own, you’re dealing with an enormous number of variables such as how fast they speak, any background sounds, any mic audio artifacts, differences in the pitch of the speaker vs your reference file, audio balance between your player’s mic and the mic used to create your reference file, etc. There’s a rather large list of things you’d have to account for before you even get into actually comparing what they said to what you’re expecting them to say. Big companies have spent decades working on this exact problem before things like voice commands to your phone were even possible.

Hi Joe-Censored
First of All. thanks for your comments.
On the other hand, my main goal is not if the gamer pronounce the same that the Audio original but to encourage him to talk and to lose the fear of doing it. If I could do something that compares both audios whose sound is similar is good for my project, for it Do you think there is a unity plugin that compares only if the sound is similar?
One more time thanks for your help…
Castana