Search code examples
jsongoogle-cloud-platformjqspeech-to-textgoogle-speech-to-text-api

"Cannot iterate over null" when using jq to extract google speech-to-text transcript data from json file


I'm trying to extract all the "transcript" data from this file which is the result of a Google Speech-to-Text request : https://pastebin.com/MFF1Dav8 (Not sensitive data, just from an interview I conducted).

To do so I found a prewritten command which I'm using :

jq <interview.json '.response.results[].alternatives[].transcript' -r > interview.txt

Except I get :

jq: error (at <stdin>:111181): Cannot iterate over null (null)

How can I work around this ? All I want is the raw transcript text. Thank you


Solution

  • The JSON you posted does not have a top-level "response" key.

    This seems to do the trick:

    .results[].alternatives[].transcript