コード例 #1
0
    def __process_base64(self, base_64):
        """Private method to decode and return the auto data wrapped in the base64 message

        Note:
            This will remove the blob prefix if the data is returned from a browser

        Arguments:
            base_64 (str): The base64 str that needs to be processed

        Returns: (bytes)
            The raw wav data of the base64 wrapped audio
        """

        try:
            # Web blob prefix to detect and remove
            audio_prefix = Configs.get_stt()["audio_prefix"]

            if audio_prefix is None:
                raise TypeError("AudioPrefix cannot be none")

            return b64decode(
                base_64.replace(Configs.get_stt()["audio_prefix"], ""))
        except Exception as err:
            log.error("Error processing base64 audio packet: (err: %s)" %
                      str(err))