Esempio n. 1
0
    def post(self):
        print('---------------enter post...')
        try:
            audio = RequestHandler.get_body_argument(self, name='audio')  # '1,1,1,...,11,2'
            audio_lst_str = audio.split(',')  # [str*32000]
            audio_lst_int = [float(i) for i in audio_lst_str]
            audio_array = np.asarray(audio_lst_int)
            audio_array = np.expand_dims(audio_array, axis=1)
            try:
                os.remove(filePath)
            except OSError:
                pass
            sf.write(filePath, audio_array, fs)
            helper = IdentificationServiceHttpClientHelper.IdentificationServiceHttpClientHelper('ccc2411ed1bb496fbc3aaf42540e81ac')
            identification_response = helper.identify_file(filePath, profile_ids, 'true')
            id = identification_response.get_identified_profile_id()

            name = profile_nms[profile_ids.index(id)] if id in profile_ids else 'stranger'
            print('result:', name)
            print('c onfidence:', identification_response.get_confidence())
            self.write(name + '\n')

        except Exception as e:
            print('receieve post but something error:' + str(e))
            self.write('error' + '\n')
            pass
Esempio n. 2
0
 def get_body_argument(self, name, default=None, strip=True):
     return RequestHandler.get_body_argument(self, name, default, strip)