Extend audio recording length

We are trying to extend the length of audio recording by modifying the "RCORDING LENGTH = 30” in the ConvaiNPC.cs. But it doesn’t work and it even didn’t record anything once I changed the length to 60. Could you help me with this. Thank you.

Hi @user3 ,

Welcome to the Convai Developer Forum!

Could you please provide us with some additional details so we can better assist you? Specifically, let us know which version of the Convai plugin you’re using and whether you are working with the WebGL SDK or the Core SDK.

Additionally, could you share more about your requirements for extending the recording length? This information will help us tailor our support to your needs.

Looking forward to your response.

Best regards,
Convai Unity Team

Hi, thanks for the reply. Currently we use convai 3.0.1 and we use the VR template for meta quest 2. We would like to have the audio recording as long as possible because we make a virtual therapist for counselling (some have a lots to ask). Currently, the character will interupt the user once the 30s end. What is the possible longest recoding length convai supports? Thank you.

it should be convai 3.1.1

Hi @user3 ,
I understand you’re trying to extend the audio recording length beyond 30 seconds in the Convai Unity SDK. While it’s technically possible to increase this length, we generally don’t recommend setting it higher than 60 seconds. Here’s why:

  • Unity’s Microphone Limitations: Unity’s built-in microphone system allocates memory based on the recording length. Setting it too high (like 60+ seconds) can cause memory allocation issues, leading to silent failures where no audio is recorded at all.
  • gRPC Connection Stability: Additionally, the gRPC connection used to stream audio data to the Convai server might become unstable or disconnect if audio is continuously streamed for longer than 60 seconds without interruption.
  • So we recommend keeping it max 60s. Implementing a custom solution might work using multiple AudioClips

Regards,
Convai Unity Team

1 Like

Currently I changed the length to 55s but I am wondering is here the only place that I need to change? because I encountered a situation like this:

If I keep the speech within 55s, like 45s, the NPC will respond me, however, once I speak longer than 55s, the NPC fail to interrupt me and don’t respond me (which she used to when the recording length was set 30s) . It seems that once I exceed the 55s, my speech will not be sent to convai server as there is not chat history for that specific speech. Thus, we want to enable the NPC to interrupt so that at least the NPC can repond to user enquiry without letting the user to repeat again.

@Dharmik_Gorsiya Hi, any reply? It is very urgent for us! Thank you!

Hi @user3, Raghuvansh this side, from Convai Team, the reason why you are not able to get a response from the Convai Server once the recording exceeds 55 seconds is that we have a timeout duration of one minute in our backend server, so it’s not possible by using the existing methods. But you can do it by recording all the audio locally and sending it all at once when the recording is finished. Please note Convai Team cannot help you with the before mentioned approach neither you will be provided any implementation.
Thanks and hope this helps

Thanks for your reply. As you said there is a one-min timeout duration and the issue of gRPC connection stability (your colleague said before), I am confused if the customed solution (“But you can do it by recording all the audio locally and sending it all at once when the recording is finished”) you said will really work? Because if we save the audio locally (e.g., 2mins) and then send to, wouldn’t it affect the stability and timeout?

I understand your concern @user3, but let me reiterate it, you can record the audio locally and only after it has been saved to a audio clip, you start a gRPC audio stream and send your audio data, and then wait for response, given the audio length is big, response may take longer than expected to come from the Convai servers
Hope this helps