Скрипт получает ответ с сервера (находится в прикрепленном файле)

и обрабатывет его на выходе я получаю

"transcript": "number six six "

а нужно еще

"transcript": "number six weeks "

"transcript": "number six "

вообщем все transcript

         jsonObject = json.loads(payload.decode('utf8'))

         if 'state' in jsonObject:

            self.listeningMessages += 1

            if (self.listeningMessages == 2):

               print "sending close 1000"

               # close the connection

               self.sendClose(1000)

              

         # if in streaming

         elif 'results' in jsonObject:

            jsonObject = json.loads(payload.decode('utf8'))           

            hypothesis = ""

            # empty hypothesis

            if (len(jsonObject['results']) == 0):

               print "empty hypothesis!"

            # regular hypothesis

            else:

               # dump the message to the output directory

               jsonObject = json.loads(payload.decode('utf8'))

               f = open(self.fileJson,"a")

               f.write(json.dumps(jsonObject, indent=4, sort_keys=True))

               f.close()

               hypothesis = jsonObject['results'][0]['alternatives'][0]['transcript']

               bFinal = (jsonObject['results'][0]['final'] == True)

               if bFinal:

                  print "final hypothesis: \"" + hypothesis + "\""

                  self.summary[self.uttNumber]['hypothesis'] += hypothesis

               else:

                  print "interim hyp: \"" + hypothesis + "\""

9 лет назад
jorah
49 лет
12 лет в сервисе
Был
3 года назад

Заявки фрилансеров

Нет заявок фрилансеров