How can pause/resume recording audio from microphone in unity engine - unity3d

In unity engine I want record audio from microphone with pause/resume ability; I want to have all of recorded audio in one AudioClip at final; and I don't know how many time it will pause and play (it's depend to user, not me) (also length of it) what can I do ?

Don't have ready made solution, but the way you should start is to use Microphone class and use its Start and End function to record audio. This returns an audio clip which can be save to a numbered file (e.g., audio_datetime_00001,audio_datetime_00002,...). Once user Play/Pause/Stop you can create a new audio file. Later you can merge them using NAudio (try Mark Heath's solution).
Happy coding!!!

Related

How to get duration of specific audio in AudioSourse just_audio Flutter?

I am building a project can play audios with just_audio.
I have a list of audios put in AudioSource and I need to create a control dash (a play button and a progress bar) for each of audio in the list, instead of using a common for the playlist as usual.
But I have no idea how to get duration/duration stream of each audio in the list and every time I click the play button of a specific audio, only that audio will be played?
enter image description here
In the picture, I can only get duration of current state, using player.durationStream, and when I click the play button, only current audio of sequenceState be played.
Please help, tkx a lot!!!
This feature isn't yet supported, but there is an open feature request for it:
https://github.com/ryanheise/just_audio/issues/141
However, this may not be what you actually want. Be aware that querying the duration directly from the media file can be inefficient in some cases, and so if you actually know the duration in advance, it may be better for the app to maintain its own local database of metadata which includes the durations:
If the audio is coming from a podcast, note that the podcast feed should report a medium-fidelity duration for each item in the XML file, measured in seconds(*).
If the audio was recorded by your app, you could save the duration metadata into your database at the same time the recording is made.
If the audio is on the device, you can query it using flutter_audio_query.
If the audio is an asset packaged with the app, then the durations are known by implication and can also be packaged with the app (i.e. hard coded).
(*) If the podcast feed omitted the duration field, you can still query it by extracting just enough of the audio file to read its duration and then disposing of the temporary player:
final disposablePlayer = Player();
final duration = await disposablePlayer.setAudioSource(...);
disposablePlayer.dispose();

How to record mic input and an audio track on iPhone at the same time

I am looking to record and save a music/song file with one or more audio track(s) let's say a max of two tracks playing simultaneously while recording my vocals via the headset or the microphone. The finished product will be a single song file(mp3 or other format).
Also, the code should have the ability to filter out outside noise/interferance and add basic effects.
Appreciate any and all Xcode help!
I have done same thing using AVAudioSessionCategoryPlayAndRecord.
in my code, played karaoke file in MPMoviePlayer and at same time takes input from mic.
output is audio from MPMoviePlayer and it will be used as input also + input from mic.
i started to save this input in caf file, and upon finish product should be single file.

AVAudioRecorder

I have been working on an Audio Application where a user can record and play the recorded audio file. In my app during recording a user can pause the recording and play it to listen what he has recorded and then again he can continue the recording.
So now my question is that if a user have recorded a 20 seconds audio and when he plays the audio and wants to resume recording from over 10 seconds overlapping/discarding the next 10 seconds audio. ?
I have looked into the AVAudioRecorder documentation and there is not property to set the duration of the recorder to start recording from specific time. So please someone tell me if it is possible or not. ?
Thanks
Maybe there’s an easier solution, but you may want to look at AVMutableComposition. You can easily create an empty mutable composition, insert the recorded sound into an audio track and then edit the track as needed – delete segments, add another recording, etc.

How do you handle pause and resume of speech when using the Flite libraries?

i have developed sample application in which i have used Flite libraries for Text to Speech conversion. But now i am not able to get how can i pause and resume speech using API/Classes of Flite, because i think Flite convert our text string as a wav file and then once recording completed then it plays that sound file in background. So when i press button "Pause" how can i know how much of text will be converted into audio output, so that i can start with remaining texts when pressing a resume.
In the FliteTTS.m file you can uncomment the preload audio player and comment out the AV player "play". Then make a new method that calls AV player to play. That way you will have your whole string converted into a file and you can play and pause it at will.
If you are asking how you know which word it will be on when your user hits "pause" - that is tricky - since it is all one audio file you can't.
Maybe you could send flite TTS each word separately, covert them and play them back in series keping track along the way - I have no idea if that will sound very good.
Or use speech recognition to listen to the AV player and guess. Or maybe analyze the string length and time the audioplayer and guess.

Play audio and video at a same time in iPhone application

Is it possible to play audio and video file at a same time? I want to play different audio file and video file at a same time and also want control for both, so is it possible?
Sorry, not that I know of. The movie view automatically stops all audio files and takes up the whole screen, so you are forced to listen to the audio for the video.
If the audio is part of the video file, yes.
If it's an MP3 file or some other external type how are you planning on playing it? The phone might allow this to happen depending on what you're up too.
You might be in luck soon though...
Another helpful link is here.