a helper method for multi-processing file transcription

def _transcribe_files(self, file_list, file_mimetype):

        ''' a helper method for multi-processing file transcription '''

    # import dependencies
        import queue
        from threading import Thread

    # define multithreading function
        def _recognize_file(file_path, file_mimetype, queue):

            details = {
                'error': '',
                'results': []
            }

            file_data = open(file_path, 'rb')
            try:
                transcript = self.client.recognize(file_data, file_mimetype, continuous=True)
                if transcript['results']:
                    for result in transcript['results']:
                        details['results'].append(result['alternatives'][0])
            except Exception as err:
                details['error'] = err

            queue.put(details)

    # construct queue
        q = queue.Queue()

    # send clips to watson for transcription in separate threads
        threads = []
        for file in file_list:
            watson_job = Thread(target=_recognize_file, args=(file, file_mimetype, q))
            watson_job.start()
            threads.append(watson_job)

    # wait for threads to end
        for t in threads:
            t.join()

    # construct result
        transcript_details = {
            'error': '',
            'segments': []
        }
        for i in range(len(file_list)):
            job_details = q.get()
            if job_details['error']:
                transcript_details['error'] = job_details['error']
            transcript_details['segments'].extend(job_details['results'])

        return transcript_details