Error in Teams Bot when getting audio - MS Graph

Copper Contributor

Hi guys, I'm having issues using PsiBot project (https://github.com/microsoftgraph/microsoft-graph-comms-samples/tree/master/Samples/PublicSamples/Ps...) as base. JUST happening on some MS accounts. When I'm trying to get audio from a Teams meeting using the bot I'm not getting any data, just silence.

 

 

public void Received(AudioMediaBuffer audioFrame)
{
	//Console.WriteLine("Receiving audio");
	if (audioFrame.Timestamp == 0)
	{
		this.logger.Warn($"Audio buffer timestamp is zero.");
		return;
	}

	var audioFormat = audioFrame.AudioFormat == Microsoft.Skype.Bots.Media.AudioFormat.Pcm44KStereo ?
		Microsoft.Psi.Audio.WaveFormat.Create16BitPcm(44000, 2) :
		Microsoft.Psi.Audio.WaveFormat.Create16kHz1Channel16BitPcm();

	var buffers = new Dictionary<string, (AudioBuffer, DateTime)>();
	try
	{
		unsafe
		{
			FileStream file = new FileStream(MediaFrameSourceComponent.BASE_PATH + "audio_" + callHandler.Call.Id + ".raw", FileMode.Append, FileAccess.Write);
			UnmanagedMemoryStream ustream = new UnmanagedMemoryStream((byte*)audioFrame.Data, audioFrame.Length);
			ustream.CopyTo(file);
			ustream.Close();
			file.Close();

		}
	}
	catch (Exception e)
	{
		Console.WriteLine("Error receiving audio" + e.StackTrace);
	}
}

 

 

This is the error log: 

pablomoreno700_0-1671530466903.png

This is the list of permissions the MS app has:

  • Calls.JoinGroupCall.All
  • OnlineMeetings.ReadWrite.All
  • Calls.JoinGroupCallAsGuest.All
  • Calls.AccessMedia.All

 

At this moment I don't have any clue because as I said before this is not happening in all MS accounts, just in a few ones.

 

Can anyone bring any idea?

Thanks

 

8 Replies
We are looking into this, we will get back to you.
We found that this error throwing is just happening when someone is talking, in that moment audioFrame.Length is 0, when people are muted then we receive Silence sound correctly.
Thank you for the additional details, we will check internally and get back to you. Thank you.

@pablomoreno700 - Engieerning team has said that the sample by default is using an older version (1.19.0.25) of the Microsoft.Skype.Bots.Media SDK. Team has suggested that the user should upgrade their program to the latest version (1.24.0.36). Can you please try and confirm if it works.

@Meghana-MSFT I was using this new version already.

We will check with engineering team and get back to you.

@pablomoreno700 

When you capture the error exception, can you please log and report the following properties:

 

audioFrame.Length

audioFrame.IsSilence

audioFrame.ActiveSpeakers?.Length

whether audioFrame.Data is null (IntPtr.Zero) or not

audioFrame.UnmixedAudioBuffers?.Length

 

and also the corresponding value of mediaSessionId from when the call session is setup:

                // create media session object, this is needed to establish call connections
                return this.Client.CreateMediaSession(
                    new AudioSocketSettings
                    {
                        StreamDirections = StreamDirection.Sendrecv,
                        // Note! Currently, the only audio format supported when receiving unmixed audio is Pcm16K
                        SupportedAudioFormat = AudioFormat.Pcm16K,
                        ReceiveUnmixedMeetingAudio = true //get the extra buffers for the speakers
                    },
                    videoSocketSettings,
                    vbssSocketSettings,
                    mediaSessionId: mediaSessionId);

 

Also, does your bot join the Teams meeting directly always, or do you know if it sometimes joins via the lobby? If the bot joins both ways, sometimes directly (lobby bypass) and sometimes via the lobby, do you know if there is any correlation between the join method and the problem you are observing?

 

Thanks

 

I cannot replicate the issue right now because was a customer environment but I can answer some of your questions.
audioFrame.Length = 0
audioFrame.IsSilence = False
audioFrame.Data I think was null
audioFrame.UnmixedAudioBuffers.Length = 0

We found that issue was happening when even joining using guest mode, the bot was autojoining (not asking to be admitted). For the moment we solved it by changing MS config to keep guests on lobby.