How to download audio files

Is it possible to download the created voice prompt as an audio file?

Hello

Yes, it is. Of course, you can click the download button manually in the Architect UI. You can also call out to GET /api/v2/architect/prompts/{promptId}, retrieve a mediaUri from the resources array, perform a basic http GET request to this media URI, and write the response to a file (I attached an example of this operation in Golang below).

resp, err := http.Get(mediaUri)
if err != nil {
	log.Fatal(err)
}

defer resp.Body.Close()

out, err := os.Create("audioFile.wav")
if err != nil {
	log.Fatal(err)
}
defer out.Close()

_, err = io.Copy(out, resp.Body)
if err != nil {
	log.Fatal(err)
}

Hope this helps!
Charlie

Thank you for your reply!!
I would like to know additionally, is there an API to get the promptId?

Yes, you could use GET /api/v2/architect/prompts?name=name_of_your_prompt

Thank you very much!
All good, purpose achieved!

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.