def transcribe_bytes(self, byte_data, clip_length=None, audio_mimetype='', compress=True):

        '''
            a method to transcribe text from audio byte data
            
        :param byte_data: byte data in buffer with audio data 
        :param clip_length: [optional] integer with seconds to divide clips into
        :param compress: [optional] boolean to convert file to audio/ogg
        :param audio_mimetype: [optional] string with byte data mimetype
        :return: dictionary with transcribed text segments in 'segments' key
        '''

        title = '%s.transcribe_bytes' % self.__class__.__name__
        bytes_arg = "%s(byte_data=b'...')" % title

    # validate inputs
        input_fields = {
            'clip_length': clip_length,
            'audio_mimetype': audio_mimetype
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)

    # validate data mimetype
        if audio_mimetype:
            file_extension = ''
            for key, value in self.fields.schema['audio_extensions'].items():
                if value['mimetype'] == audio_mimetype:
                    file_extension = value['extension']
        else:
            if self.magic:
                magic_details = self.magic.analyze(byte_data=byte_data)
                file_name = magic_details['name']
                if not file_name:
                    file_name = 'audio'
                file_name += magic_details['extension']
                ext_kwargs = {
                    'file_name': file_name,
                    'extension_map': self.fields.schema['audio_extensions'],
                    'method_title': title,
                    'argument_title': 'byte_data'
                }
                file_details = self._validate_extension(**ext_kwargs)
                audio_mimetype = file_details['mimetype']
                file_extension = file_details['extension']
            else:
                raise ValueError('%s argument requires audio_mimetype (or magic) to determine its mimetype.' % bytes_arg)

    # construct default return
        transcript_details = {
            'error': '',
            'segments': []
        }

    # transcribe entire buffer
        if clip_length is None:
            try:
                transcript = self.client.recognize(byte_data, audio_mimetype, continuous=True)
                if transcript['results']:
                    for result in transcript['results']:
                        transcript_details['segments'].append(result['alternatives'][0])
            except Exception as err:
                transcript_details['error'] = err

    # save buffer to disk, segment and transcribe in multiple threads
        else:
            import os
            from time import sleep
            from math import ceil
            from moviepy.editor import AudioFileClip

        # save buffer to disk
            clip_folder = self._create_folder()
            full_name = 'audio_full.%s' % file_extension
            full_path = os.path.join(clip_folder, full_name)
            with open(full_path, 'wb') as f:
                f.write(byte_data)
                f.close()

        # convert file
            if compress:
                file_name, file_extension = os.path.splitext(full_path)
                if file_extension != '.ogg':
                    full_path = self.convert_audio(full_path, 'audio/ogg', True)
                    file_details = {
                        'name': 'audio_full.ogg',
                        'extension': '.ogg',
                        'mimetype': 'audio/ogg'
                    }
                    audio_mimetype = file_details['mimetype']
                    file_extension = file_details['extension']

        # open audio file
            count = 0
            retry_count = 10
            while True:
                try:
                    audio = AudioFileClip(full_path)
                    break
                except PermissionError:
                    sleep(.05)
                    count += 1
                    if count > retry_count:
                        raise
            audio_duration = audio.duration

        # construct list of files to transcribe
            file_list = []
            if audio_duration < clip_length:
                file_list.append(full_path)
            else:

        # create temporary audio files
                count = 0
                t_start = 0
                while t_start < audio_duration:
                    t_end = t_start + clip_length
                    if t_end > audio_duration:
                        t_end = ceil(audio_duration)
                        segment = audio.subclip(t_start)
                    else:
                        segment = audio.subclip(t_start, t_end)
                    clip_name = 'audio%s.%s' % (count, file_extension)
                    clip_path = os.path.join(clip_folder, clip_name)
                    segment.write_audiofile(clip_path, verbose=False)
                    file_list.append(clip_path)
                    count += 1
                    t_start = t_end

        # run file transcription method
            transcript_details = self._transcribe_files(file_list, audio_mimetype)

        # remove temp files
            if len(file_list) > 1:
                from labpack.records.settings import remove_settings
                for file in file_list:
                    remove_settings(file, remove_dir=True)

        return transcript_details
a method to transcribe text from audio byte data
            
        :param byte_data: byte data in buffer with audio data 
        :param clip_length: [optional] integer with seconds to divide clips into
        :param compress: [optional] boolean to convert file to audio/ogg
        :param audio_mimetype: [optional] string with byte data mimetype
        :return: dictionary with transcribed text segments in 'segments' key