Sundar_Krishna:

The mel spectogram will be continuously generating and plotting the graph for the sound coming from the mic and for every 5 seconds i could create a window to cut or extract the spectogram and send it inside my trained network?


Yes, that should be generally possible. Note however, that the implementation would be out of scope for PyTorch and you would need to use your audio processing libraries for it.



 Sundar_Krishna:

Of course I will lose the middle 5 seconds of the audio data but its ok as of now!


Not necessarily. Once you have the initial 5s (and the minimal latency of the system), you could use a sliding window approach to create overlapping windows. This could create a feeling of a “real time” system for the user.
E.g. assuming that the window length is 5s and the model needs 1s to create the predictions, you could shift the window by 1s and produce the next output.