I have the following data taken from an API. I am trying to access the "transcript" parts using a Python script with a loop. My aim is to print all "transcript" plain text. I working on that still, I have this error:
TypeError: list indices must be integers or slices, not str.
code:
import json
filename = "1transcript.json"
with open(filename, "r") as data_file:
data = json.load(data_file)
for output in data['results']:
print(output['alternatives']['transcript']) #updated
json:
{
"@type": "type.googleapis.com/google.cloud.speech.v1p1beta1.LongRunningRecognizeResponse",
"results": [
{
"alternatives": [
{
"confidence": 0.9172556,
"transcript": "The Joe Rogan Experience reacting to him knocking out volkov. This is one of my favorite one of my favorite Clips because that knockout was so crazy. We were in the middle here is or here. I'm so too right now, Jamie."
}
],
"languageCode": "en-us"
},
{
"alternatives": [
{
"confidence": 0.7491517,
"transcript": " Yeah, I just airdrop tattoo."
}
],
"languageCode": "en-us"
},
{
"alternatives": [
{
"confidence": 0.8975618,
"transcript": " I would not working."
}
],
"languageCode": "en-us"
},
{
"alternatives": [
{
"confidence": 0.8619629,
"transcript": " Is it going through?"
}
],
"languageCode": "en-us"
},
)of your print