Uploads a recording file. Currently only wav files are supported. The file can either be uploaded as 1) a json object with audio encoded in base64 with an optional transcript (see example below) or directly as 2) bytes in the the request body. For the first option set Content-Type header to application/json, for the second option set the Content-Type header to audio/wav.
This endpoint should be called with a generated url, see /v3/api/assessment/begin for how to generate these urls.
Header Key | Description | Example |
---|---|---|
Content-Type | The content type for this request. If set to application/json it will expect the audio in base64 (example below). If set to audio/wav it will expect the audio as bytes in the request body. | application/json |
Name | Type | Description |
---|---|---|
p | string | The signed encoded payload for this request. Obtained from call to /v3/api/assessment/begin. |
Name | Type | Description |
---|---|---|
transcript | object | The transcript information for the recording. |
* audio | string | The Base64-encoded audio file. |
A successful response
Field Name | Type | Description |
---|---|---|
message | string | "OK" |
curl \
-X PUT "https://rest.eus.canaryspeech.com/v3/api/upload-recording-signed?p=eyJvcml..." \
-H "Content-Type: application/json" \
-d "{ \"audio\": \"Q2FuYXJ5IFNwZWVjaOKAmXMgdm9jYWwgYmlvbWFya2VyIHRlY2hub2xvZ3kgdW5sb2...\" }"
function putV3ApiUploadRecordingSigned() {
const url = 'https://rest.eus.canaryspeech.com/v3/api/upload-recording-signed?p=eyJvcml...';
const headers = { 'Content-Type': 'application/json' };
const body = {
audio: 'Q2FuYXJ5IFNwZWVjaOKAmXMgdm9jYWwgYmlvbWFya2VyIHRlY2hub2xvZ3kgdW5sb2...'
};
fetch(url, {
method: 'PUT',
headers: headers,
body: JSON.stringify(body)
}).then((response) => {
if (!response.ok) throw new Error(response.status);
return response.json()
}).then((json) => {
const { message } = json;
// ...
});
}
const https = require('https');
function putV3ApiUploadRecordingSigned() {
const headers = { 'Content-Type': 'application/json' };
const body = {
audio: 'Q2FuYXJ5IFNwZWVjaOKAmXMgdm9jYWwgYmlvbWFya2VyIHRlY2hub2xvZ3kgdW5sb2...'
};
const options = {
hostname: 'rest.eus.canaryspeech.com',
port: 443,
path: '/v3/api/upload-recording-signed',
method: 'PUT',
qs: { 'p': 'eyJvcml...' },
headers: headers
};
const request = https.request(options, (response) => {
if (response.statusCode !== 200) throw new Error(response.statusCode);
response.on('data', (d) => {
const { message } = JSON.parse(d);
// ...
});
});
request.on('error', (err) => {
throw new Error(err);
});
request.write(JSON.stringify(body));
request.end();
}
const axios = require('axios').default;
async function putV3ApiUploadRecordingSigned() {
const url = 'https://rest.eus.canaryspeech.com/v3/api/upload-recording-signed?p=eyJvcml...';
const headers = { 'Content-Type': 'application/json' };
const body = {
audio: 'Q2FuYXJ5IFNwZWVjaOKAmXMgdm9jYWwgYmlvbWFya2VyIHRlY2hub2xvZ3kgdW5sb2...'
};
const response = await axios.put(url, body, { headers });
if (response.status !== 200) throw new Error(response.status);
const { message } = response.data;
// ...
}
import * as https from 'https';
function putV3ApiUploadRecordingSigned(): void {
const headers = { 'Content-Type': 'application/json' };
const body = {
audio: 'Q2FuYXJ5IFNwZWVjaOKAmXMgdm9jYWwgYmlvbWFya2VyIHRlY2hub2xvZ3kgdW5sb2...'
};
const options = {
hostname: 'rest.eus.canaryspeech.com',
port: 443,
path: '/v3/api/upload-recording-signed',
method: 'PUT',
qs: { 'p': 'eyJvcml...' },
headers: headers
};
const request = https.request(options, (response) => {
if (response.statusCode !== 200) throw new Error(response.statusCode);
response.on('data', (d) => {
const { message } = JSON.parse(d) as Record<string, unknown>;
// ...
});
});
request.on('error', (err) => {
throw new Error(err);
});
request.write(JSON.stringify(body));
request.end();
}
import axios from 'axios';
async function putV3ApiUploadRecordingSigned(): Promise<void> {
const url = 'https://rest.eus.canaryspeech.com/v3/api/upload-recording-signed?p=eyJvcml...';
const headers = { 'Content-Type': 'application/json' };
const body = {
audio: 'Q2FuYXJ5IFNwZWVjaOKAmXMgdm9jYWwgYmlvbWFya2VyIHRlY2hub2xvZ3kgdW5sb2...'
};
const response = await axios.put(url, body, { headers });
if (response.status !== 200) throw new Error(response.status);
const { message } = response.data;
// ...
}
import requests
def put_v3_api_upload_recording_signed():
url = 'https://rest.eus.canaryspeech.com/v3/api/upload-recording-signed'
headers = {
'Content-Type': 'application/json'
}
body = {
'audio': 'Q2FuYXJ5IFNwZWVjaOKAmXMgdm9jYWwgYmlvbWFya2VyIHRlY2hub2xvZ3kgdW5sb2...'
}
response = requests.put(
url,
params={
'p': 'eyJvcml...'
},
headers=headers,
data=body,
)
if response.status_code !== 200:
raise Exception(response.status_code)
response_obj = response.json()
message = response_obj['message']
# ...
import org.json.simple.JSONObject;
import org.json.simple.JSONArray;
import org.json.simple.JSONParser;
import org.json.simple.JSONValue;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
public class CanarySpeechApi {
public void putV3ApiUploadRecordingSigned() {
URI uri = new URI("https://rest.eus.canaryspeech.com/v3/api/upload-recording-signed?p=eyJvcml...");
JSONObject body = new JSONObject();
body.put("audio", "Q2FuYXJ5IFNwZWVjaOKAmXMgdm9jYWwgYmlvbWFya2VyIHRlY2hub2xvZ3kgdW5sb2...");
byte[] bodyBytes = JSONValue.toJSONString(body).getBytes(StandardCharsets.UTF_8);
HttpRequest request = HttpRequest.newBuilder()
.uri(uri)
.version(HttpClient.Version.HTTP_2)
.header("Content-Type", "application/json")
.PUT(BodyPublishers.ofByteArray(bodyBytes))
.build();
HttpClient client = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_1_1)
.build();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
if (client.status != 200) {
throw new Exception(client.status.toString());
}
JSONParser parser = new JSONParser();
JSONObject responseBody = (JSONObject) parser.parse(client.body());
String message = (String) responseBody.get("message");
// ...
}
}
import org.json.JSONObject
import java.lang.StringBuilder
import java.net.URL
import javax.net.ssl.HttpsURLConnection
suspend fun putV3ApiUploadRecordingSigned() = runCatching {
val url = URL.create("https://rest.eus.canaryspeech.com/v3/api/upload-recording-signed?p=eyJvcml...")
with(url.openConnection() as HttpsURLConnection) {
requestMethod = "PUT"
instanceFollowRedirects = true
setRequestProperty("Content-Type", "application/json")
doInput = true
setChunkedStreamingMode(0)
val body = JSONObject()
body.put("audio", String("Q2FuYXJ5IFNwZWVjaOKAmXMgdm9jYWwgYmlvbWFya2VyIHRlY2hub2xvZ3kgdW5sb2..."))
outputStream.bufferedWriter(Charsets.UTF_8).use {
it.write(body.toString())
it.flush()
}
doOutput = true
if (responseCode != 200) throw Error(responseMessage)
val buffer = StringBuilder()
var line: String?
inputStream.bufferedReader(Charsets.UTF-8).use {
do {
line = it.readLine()
if (line != null) buffer.appendLine(line)
} while (line != null)
}
val responseBody = JSONObject(buffer.toString())
val message = responseBody.get("message") as String
// ...
}
}
import UIKit
func putV3ApiUploadRecordingSigned() -> void {
let url = URL("https://rest.eus.canaryspeech.com/v3/api/upload-recording-signed?p=eyJvcml...")
let headers: [String: String] = [ "Content-Type": "application/json" ]
let body: [String: Any] = [
"audio": "Q2FuYXJ5IFNwZWVjaOKAmXMgdm9jYWwgYmlvbWFya2VyIHRlY2hub2xvZ3kgdW5sb2..."
]
var request = URLRequest(url: url)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = JSONEncoder().encode(body)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard
let data = data,
let response = response as? HTTPURLResponse,
error == nil
else {
print("error", error ?? URLError(.badServerResponse)
return
}
guard (200 ... 299) ~= response.statusCode else {
print("statusCode = \(response.statusCode)")
print("response = \(response)")
return
}
do {
let responseObj = try JSONDecoder().decode(PutV3ApiUploadRecordingSignedResponse.self, data)
// ...
} catch {
print(error)
}
}
}
}
struct PutV3ApiUploadRecordingSignedResponse: Decodable {
let message: String
}
using System.Collections.Generic;
using System.Net.Http;
using System.Text.Encoding;
using System.Text.Json;
using System.Text.Json.Serialization;
public static class CanarySpeechAPI
{
public static readonly HttpClient client = new HttpClient();
public static async Task putV3ApiUploadRecordingSigned()
{
var url = "https://rest.eus.canaryspeech.com/v3/api/upload-recording-signed?p=eyJvcml...\"";
var body = new Dictionary<string, dynamic> {
{ "audio": "Q2FuYXJ5IFNwZWVjaOKAmXMgdm9jYWwgYmlvbWFya2VyIHRlY2hub2xvZ3kgdW5sb2..."
};
var bodyString = JsonConvert.Serialize(body);
var request = new HttpRequestMessage(HttpMethod.Put, url);
request.Headers.Add("Content-Type", "application/json");
request.Content = new ByteArrayContent(Encoding.UTF8.GetBytes(bodyString));
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
var responseJson = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(responseBody);
var message = (String)responseJson["message"];
// ...
}
}
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> function putV3ApiUploadRecordingSigned() async {
final queryParams = { 'p': 'eyJvcml...' };
final uri = Uri.https('rest.eus.canaryspeech.com', 'v3/api/upload-recording-signed', queryParams);
final headers = { 'Content-Type': 'application/json' };
final body = {
'audio': 'Q2FuYXJ5IFNwZWVjaOKAmXMgdm9jYWwgYmlvbWFya2VyIHRlY2hub2xvZ3kgdW5sb2...'
};
final request = http.Request('PUT', uri);
request.headers.addAll(headers)
request.body = json.encode(body);
final client = http.Client();
try {
final responseStream = await client.send(request);
final statusCode = responseStream.statusCode;
if (statusCode < 200 || statusCode >= 300) {
throw Error(statusCode.toString());
}
final responseBytes = await responseStream.stream.toBytes();
final responseString = utf8.decode(responseBytes);
final response = json.decode(responseString);
final message = response['message'] as String;
// ...
} catch (e) {
print(e);
}
}