M
M
madmaga2021-02-14 00:50:43
Unity
madmaga, 2021-02-14 00:50:43

Unity how to record audio and play like in Talking Tom?

Hello! I want to create an app like "Talking Tom".
I need the Recording to stop if there is no sound, say 2 seconds. I have a 10 second timer. When I say, the recording starts and lasts for 10 seconds and then plays. Even if I stopped saying something, it records and reproduces empty silence. How to make the recording stop if the sound stops coming for 2 seconds. and what I said was reproduced in N number of seconds.
The maximum recording time I want is 10 seconds.
On one forum, I was offered the following solution. But I don't know how to do it.
"Record several times for 2 seconds and that's it. You check if there was any sound in the last recording. If there was, you leave it and still record it. If not, delete it. Then you connect and play back"
And another problem is poor audibility. You have to speak very loudly for the recording to start. When the recording is played back, the sound is very weak. In the "Talking Tom" application, for example, you do not need to speak so loudly for the recording to start. And when the recording is played the sound is also good.

Here is the script that I am using.
on the 1st photo script GameConstants. on the other 4 pictures, the GameControler script. I just couldn’t screen everything, so I posted it in parts.
I hope legible.

I can give you a full link to the project if needed.
602848e3434a8821090961.jpeg
602848ef2d8e4560694829.jpeg
602848fcb2db1762836170.jpeg
60284955d1a04560196688.jpeg
6028497a6e9f3985980400.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-02-14
@vabka

I suppose that you need to play around with the SoundThreshold constant, as its name suggests.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question