I would like to retrieve the transcript from the JSON DUMP so that I can put it in a varaible (string) so that I can later use it with the IBM Watson NLU service
My code:
class MyRecognizeCallback(RecognizeCallback):
def __init__(self):
RecognizeCallback.__init__(self
def on_transcription(self, transcript):
print(transcript)
def on_connected(self):
print('Connection was successful')
def on_error(self, error):
print('Error received: {}'.format(error))
def on_inactivity_timeout(self, error):
print('Inactivity timeout: {}'.format(error))
def on_listening(self):
print('Service is listening')
def on_hypothesis(self, hypothesis):
print(hypothesis)
def on_data(self, data):
print(json.dumps(data, indent=2))
def on_close(self):
print("Connection closed")
myRecognizeCallback = MyRecognizeCallback()
with open(join(dirname(__file__), './.', 'output.wav'),
'rb') as audio_file:
audio_source = AudioSource(audio_file)
speech_to_text.recognize_using_websocket(
audio=audio_source,
content_type='audio/wav',
recognize_callback=myRecognizeCallback,
model='fr-FR_BroadbandModel')
API WATSON return this Json dump:
{
"results": [
{
"alternatives": [
{
"confidence": 0.87
"transcript": "several tornadoes touch down as a line of
severe thunderstorms swept through colorado on sunday "
}
],
"final": true
}
],
"result_index": 0
}
Thank you in advance !