def send_audio_packet(self, data, *, encode=True):
        """Sends an audio packet composed of the data.

        You must be connected to play audio.

        Parameters
        ----------
        data: bytes
            The :term:`py:bytes-like object` denoting PCM or Opus voice data.
        encode: bool
            Indicates if ``data`` should be encoded into Opus.

        Raises
        -------
        ClientException
            You are not connected.
        OpusError
            Encoding the data failed.
        """

        self.checked_add('sequence', 1, 65535)
        if encode:
            encoded_data = self.encoder.encode(data, self.encoder.SAMPLES_PER_FRAME)
        else:
            encoded_data = data
        packet = self._get_voice_packet(encoded_data)
        try:
            self.socket.sendto(packet, (self.endpoint_ip, self.voice_port))
        except BlockingIOError:
            log.warning('A packet has been dropped (seq: %s, timestamp: %s)', self.sequence, self.timestamp)

        self.checked_add('timestamp', self.encoder.SAMPLES_PER_FRAME, 4294967295)
def send_audio_packet ( self , data , * , encode = True ) : self . checked_add ( 'sequence' , 1 , 65535 ) if encode : encoded_data = self . encoder . encode ( data , self . encoder . SAMPLES_PER_FRAME ) else : encoded_data = data packet = self . _get_voice_packet ( encoded_data ) try : self . socket . sendto ( packet , ( self . endpoint_ip , self . voice_port ) ) except BlockingIOError : log . warning ( 'A packet has been dropped (seq: %s, timestamp: %s)' , self . sequence , self . timestamp ) self . checked_add ( 'timestamp' , self . encoder . SAMPLES_PER_FRAME , 4294967295 )
Sends an audio packet composed of the data.

        You must be connected to play audio.

        Parameters
        ----------
        data: bytes
            The :term:`py:bytes-like object` denoting PCM or Opus voice data.
        encode: bool
            Indicates if ``data`` should be encoded into Opus.

        Raises
        -------
        ClientException
            You are not connected.
        OpusError
            Encoding the data failed.