如何在Python中接收Watson Speech to Text SDK的整个输出?

如何在Python中接收Watson Speech to Text SDK的整个输出?,python,speech-recognition,ibm-watson,Python,Speech Recognition,Ibm Watson,经过大量测试后,我能够从我用python创建的应用程序接收输出,以使用IBMBlueMix将语音转换为文本。代码: import json from os.path import join, dirname from ibm_watson import SpeechToTextV1 from ibm_watson.websocket import RecognizeCallback, AudioSource import threading from ibm_cloud_sdk_core.aut

经过大量测试后,我能够从我用python创建的应用程序接收输出,以使用IBMBlueMix将语音转换为文本。代码:

import json
from os.path import join, dirname
from ibm_watson import SpeechToTextV1
from ibm_watson.websocket import RecognizeCallback, AudioSource
import threading
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator

authenticator = IAMAuthenticator('xxxx')
service = SpeechToTextV1(authenticator=authenticator)
service.set_service_url('https://api.us-east.speech-to-text.watson.cloud.ibm.com')

models = service.list_models().get_result()
print(json.dumps(models, indent=2))

model = service.get_model('en-US_BroadbandModel').get_result()
print(json.dumps(model, indent=2))

with open(join(dirname('__file__'), 'testvoice3.wav'),
          'rb') as audio_file:
    print(json.dumps(
        service.recognize(
            audio=audio_file,
            content_type='audio/wav',
            timestamps=True,
            word_confidence=True,model='en-US_NarrowbandModel',
        continuous=True).get_result(),
        indent=2))
我收到的输出如下所示:

            [
              "no",
            [
              "their",
              0.41
            ],
            [
              "lives",
              0.1
            ],
            [
              "you",
              0.56
            ],
            [
              "take",
              1.0
            ],
            [
              "Kerr",
              0.95
            ],
            [
              "bye",
              0.4
            ],
            [
              "bye",
              0.99
            ]
          ]
        }
      ],
      "final": true
    }
  ],
  "result_index": 0
}

我只想在一个地方接收整个输出,而不是这种格式。我只想把成绩单和信心分数分开。所以我可以把它导出到一个文本文件中。我该怎么做呢?

这个输出就是单词自信。输出中应该有一个包含全文的条目,很可能在列表的更高位置


要将输出压缩为仅成绩单,请去掉选项
word\u confidence=True
timestamps=True

,但我该如何调用?我不了解输出存储在
results[0]中的数据FRME。备选方案[0]。转录本
NameError:未定义名称“results”添加查看对您的问题的答复的代码,以便我们可以看到您在做什么。