private IEnumerator InitializeMicrophone()
        {
            Debug.Log("Trying to initialize microphone");

            yield return(Application.RequestUserAuthorization(UserAuthorization.Microphone));

            if (Application.HasUserAuthorization(UserAuthorization.Microphone))
            {
                Debug.Log("Microphone access was granted");

                foreach (var device in recorder.Devices)
                {
                    Debug.Log(device);
                }

                sampleFrequency = recorder.Start(recorder.Devices.First(), (data, count) =>
                {
                    if (audioEncoder == null)
                    {
                        audioEncoder = new SpeexAudioEncoder(false, BandMode.Wide, false, 10);
                        audioStream  = new EventStream((buffer, bufferOffset, bufferCount) =>
                        {
                            var playerNetworkBehaviour = GetComponent <PlayerNetworkBehaviour>();
                            if (playerNetworkBehaviour != null)
                            {
                                playerNetworkBehaviour.SendVoiceInput(buffer, bufferOffset, bufferCount, sampleFrequency);
                            }
                        });

                        audioEncoder.Open(audioStream, 1, sampleFrequency);
                    }

                    audioEncoder.Write(data, count);
                });
            }
        }