Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) VoiceBase -- Retrieve JSON TranscriptRetrieves a JSON transcript for a media file.
Use ChilkatAx-win32.pkg Procedure Test String sAccessToken Handle hoHttp Handle hoSbAuth Boolean iSuccess Handle hoSbUrl Integer iReplaceCount String sStrJson Handle hoJson Integer iNumWords Integer i String sTemp1 Integer iTemp1 Boolean bTemp1 // This example assumes the Chilkat HTTP API to have been previously unlocked. // See Global Unlock Sample for sample code. // Insert your Bearer token here: Move "VOICEBASE_TOKEN" To sAccessToken Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End // Add the access (bearer) token to the request, which is a header // having the following format: // Authorization: Bearer <userAccessToken> Get Create (RefClass(cComChilkatStringBuilder)) To hoSbAuth If (Not(IsComObjectCreated(hoSbAuth))) Begin Send CreateComObject of hoSbAuth End Get ComAppend Of hoSbAuth "Bearer " To iSuccess Get ComAppend Of hoSbAuth sAccessToken To iSuccess Get ComGetAsString Of hoSbAuth To sTemp1 Send ComSetRequestHeader To hoHttp "Authorization" sTemp1 Get Create (RefClass(cComChilkatStringBuilder)) To hoSbUrl If (Not(IsComObjectCreated(hoSbUrl))) Begin Send CreateComObject of hoSbUrl End Get ComAppend Of hoSbUrl "https://apis.voicebase.com/v2-beta/media/$MEDIA_ID/transcripts/latest" To iSuccess Get ComReplace Of hoSbUrl "$MEDIA_ID" "f9b9bb88-d52c-4960-bcef-d516a9f85594" To iReplaceCount Get ComGetAsString Of hoSbUrl To sTemp1 Get ComQuickGetStr Of hoHttp sTemp1 To sStrJson Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End // The response should be JSON, even if an error. Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComLoad Of hoJson sStrJson To iSuccess Set ComEmitCompact Of hoJson To False Get ComLastStatus Of hoHttp To iTemp1 Showln "Response status code = " iTemp1 Get ComLastStatus Of hoHttp To iTemp1 If (iTemp1 <> 200) Begin Get ComEmit Of hoJson To sTemp1 Showln sTemp1 Showln "Failed" Procedure_Return End // See the sample JSON response below.. // Iterate over the words.. Get ComSizeOfArray Of hoJson "transcripts.latest.words" To iNumWords Move 0 To i While (i < iNumWords) Set ComI Of hoJson To i Get ComStringOf Of hoJson "transcripts.latest.words[i].w" To sTemp1 Showln sTemp1 Move (i + 1) To i Loop Showln "Success." // A sample JSON response: // { // "_links": { // "self": { // "href": "/v2-beta/media/f9b9bb88-d52c-4960-bcef-d516a9f85594/transcripts/latest" // } // }, // "transcripts": { // "latest": { // "revision": "b25e81dc-ae3e-4f9d-8008-1d56a283c17f", // "engine": "standard", // "confidence": 2.196210728898151, // "words": [ // { // "p": 0, // "s": 830, // "c": 0.14, // "e": 870, // "w": "You" // }, // { // "p": 1, // "s": 1860, // "c": 0.432, // "e": 1920, // "w": "know" // }, // { // "p": 2, // "s": 1930, // "c": 0.288, // "e": 2250, // "w": "that's" // }, // { // "p": 3, // "s": 2250, // "c": 0.923, // "e": 2300, // "w": "a" // }, // ... End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.