Im using hume.ai for TTS. I got the response back in a json file with base64 output.I can’t figure out how to extract it because I cant get the right expression to work. None of the expressions I use work so I cant get to the data nor can any of the LLMs I use (ChatGPT, Gemini, Claude, Manus). This expression does not work {{ $json.generations[0].audio }}
Any ideas?
Could you post the whole json which you get back?
How exactly this doesn’t work? Doesn’t pick up the correct field from the JSON or isn’t recognized by the AI that you send it to? What doesn’t work?
it doesnt correspond to anything in the previous output. I did it in python on colab and it works, that should be the structure but there is something on n8n that might be changing it.
Could you still post the JSON with that data (maybe trim the base64 portion to a reasonable length)?
to answer your original question, if order to turn base64 string to mp3 file, you could use “Convert to file” node. For example:
I am using a local mp3 file, which I send to an API to turn to base64, so the response coming from the http request node is base64 encoded mp3 (you obviously don’t need to do this dance, you already have your b64), then I convert it to a file and transcribe with open ai.
the main problem Im having now I think is that I cant find the right expression to get to the data in the json file
In n8n, to extract the Base64 audio string from the generations
array, use the expression {{ $json["generations"][0]["audio"] }}
inside a Set or Function node. If you’re referencing a previous node like an HTTP Request, use {{ $node["HTTP Request"].json["generations"][0]["audio"] }}
instead. Just ensure the node name matches exactly. This will give you the correct audio value from the response.
it didnt work, I used {{ $node[“Record Podcast1”].json[“generations”][0][“audio”] }} and it doesnt find anything
I found what was wrong! The response format was set to File instead of JSON! I spent a whole day on this! 