Sample code for 30+ languages & platforms
Lua

VoiceBase -- Retrieve Plain Text Transcript

See more VoiceBase Examples

Retrieves a plain text transcript for a media file.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

-- This example assumes the Chilkat HTTP API to have been previously unlocked.
-- See Global Unlock Sample for sample code.

-- Insert your Bearer token here:
local accessToken = "VOICEBASE_TOKEN"

local http = chilkat.Http.new()

-- Add the access (bearer) token to the request, which is a header
-- having the following format:
-- Authorization: Bearer <userAccessToken>
local sbAuth = chilkat.StringBuilder.new()
sbAuth:append("Bearer ")
sbAuth:append(accessToken)
http:set_request_header("Authorization", sbAuth:get_as_string())

local sbUrl = chilkat.StringBuilder.new()
sbUrl:append("https://apis.voicebase.com/v2-beta/media/$MEDIA_ID/transcripts/latest")
local replaceCount = sbUrl:replace("$MEDIA_ID", "f9b9bb88-d52c-4960-bcef-d516a9f85594")

http.accept = "text/plain"

local strText = http:quick_get_str(sbUrl:get_as_string())
if not http.last_method_success then
    print(http.last_error_text)
    return
end

print("Response status code = " .. http.last_status)
print(strText)

if http.last_status ~= 200 then
    print("Failed")
else
    print("Success")
end