🆕Recognize Speakers in Transcription
🔊 Recognizing Speakers in Your Transcription
You can create Speaker Profiles so that in your future transcriptions you won't have to manually adjust speaker names. Using clear and long audio files will help with the success of assigning Speaker Profiles in transcriptions. You can create speaker profiles either from a local audio file or from one of your transcriptions in Transkriptor.
Create a Speaker Profile From a Local Audio File - Part 1 Generate Upload URL
To create a speaker profile, upload a local audio file. This function will generate the URL that you are supposed to upload your audio file.
import requests
import json
url = f"https://api.tor.app/developer/annotations/profiles/create_url"
# Define the API key as a variable
api_key = "your_api_key" # Replace with your actual API key
speaker_label_name = "your_speaker_name"
payload = {"speaker_name": speaker_label_name}
# Set up the headers, including the API key
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}", # Use the variable here
"Accept": "application/json",
}
response = requests.post(url, headers=headers, json=payload)
upload_url = json.loads(response.text)["upload_url"]
print(f"upload url: ", upload_url)
const axios = require('axios');
const apiKey = 'your_api_key'; // Replace with your actual API key
const speakerLabelName = 'your_speaker_name';
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`,
'Accept': 'application/json'
};
const payload = {
speaker_name: speakerLabelName
};
const url = "https://api.tor.app/developer/annotations/profiles/create_url";
axios.post(url, payload, { headers })
.then(response => {
const uploadUrl = response.data.upload_url;
console.log("Upload URL:", uploadUrl);
})
.catch(error => {
console.error("Error:", error.response ? error.response.data : error.message);
});
import okhttp3.*;
import org.json.JSONObject;
public class CreateSpeakerProfile {
private static final String API_KEY = "your_api_key";
private static final String SPEAKER_LABEL_NAME = "your_speaker_name";
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient();
String url = "https://api.tor.app/developer/annotations/profiles/create_url";
JSONObject payload = new JSONObject();
payload.put("speaker_name", SPEAKER_LABEL_NAME);
RequestBody body = RequestBody.create(payload.toString(), MediaType.parse("application/json"));
Request request = new Request.Builder()
.url(url)
.post(body)
.addHeader("Authorization", "Bearer " + API_KEY)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject responseData = new JSONObject(response.body().string());
String uploadUrl = responseData.getString("upload_url");
System.out.println("Upload URL: " + uploadUrl);
} else {
System.out.println("Request failed: " + response.code());
System.out.println("Response Body: " + response.body().string());
}
}
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
public class Program
{
private static readonly string apiKey = "your_api_key";
private static readonly string speakerLabelName = "your_speaker_name";
public static async Task Main()
{
var client = new HttpClient();
var url = "https://api.tor.app/developer/annotations/profiles/create_url";
var payload = new { speaker_name = speakerLabelName };
var jsonPayload = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
client.DefaultRequestHeaders.Add("Accept", "application/json");
var response = await client.PostAsync(url, jsonPayload);
if (response.IsSuccessStatusCode)
{
var responseData = await response.Content.ReadAsStringAsync();
var data = JsonSerializer.Deserialize<JsonDocument>(responseData);
Console.WriteLine("Upload URL: " + data.RootElement.GetProperty("upload_url").GetString());
}
else
{
Console.WriteLine("Request failed with status: " + response.StatusCode);
Console.WriteLine("Response Body: " + await response.Content.ReadAsStringAsync());
}
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
const apiKey = "your_api_key"
const speakerLabelName = "your_speaker_name"
func main() {
url := "https://api.tor.app/developer/annotations/profiles/create_url"
payload := map[string]string{
"speaker_name": speakerLabelName,
}
payloadBytes, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payloadBytes))
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
var response map[string]interface{}
json.NewDecoder(resp.Body).Decode(&response)
fmt.Println("Upload URL:", response["upload_url"])
}
require 'net/http'
require 'json'
require 'uri'
api_key = "your_api_key"
speaker_label_name = "your_speaker_name"
url = URI("https://api.tor.app/developer/annotations/profiles/create_url")
body = { "speaker_name" => speaker_label_name }
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request.body = body.to_json
response = http.request(request)
upload_url = JSON.parse(response.body)["upload_url"]
puts "Upload URL: #{upload_url}"
<?php
$apiKey = "your_api_key";
$speakerLabelName = "your_speaker_name";
$url = "https://api.tor.app/developer/annotations/profiles/create_url";
$payload = json_encode(["speaker_name" => $speakerLabelName]);
$headers = [
"Authorization: Bearer $apiKey",
"Content-Type: application/json",
"Accept: application/json"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$responseData = json_decode($response, true);
$uploadUrl = $responseData['upload_url'];
echo "Upload URL: $uploadUrl\n";
?>
import okhttp3.*
import org.json.JSONObject
fun main() {
val apiKey = "your_api_key"
val speakerLabelName = "your_speaker_name"
val url = "https://api.tor.app/developer/annotations/profiles/create_url"
val payload = JSONObject().put("speaker_name", speakerLabelName)
val client = OkHttpClient()
val body = RequestBody.create(MediaType.parse("application/json"), payload.toString())
val request = Request.Builder()
.url(url)
.post(body)
.addHeader("Authorization", "Bearer $apiKey")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build()
client.newCall(request).execute().use { response ->
val responseBody = response.body()?.string()
val json = JSONObject(responseBody)
println("Upload URL: ${json.getString("upload_url")}")
}
}
import Foundation
let apiKey = "your_api_key"
let speakerLabelName = "your_speaker_name"
let url = URL(string: "https://api.tor.app/developer/annotations/profiles/create_url")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
let payload: [String: Any] = [
"speaker_name": speakerLabelName
]
request.httpBody = try! JSONSerialization.data(withJSONObject: payload, options: [])
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
let jsonResponse = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
if let uploadUrl = jsonResponse?["upload_url"] as? String {
print("Upload URL: \(uploadUrl)")
}
}
}
task.resume()
import 'dart:convert';
import 'dart:io';
void main() async {
const apiKey = 'your_api_key';
const speakerLabelName = 'your_speaker_name';
final url = Uri.parse('https://api.tor.app/developer/annotations/profiles/create_url');
final payload = jsonEncode({
"speaker_name": speakerLabelName,
});
final request = await HttpClient().postUrl(url)
..headers.set('Authorization', 'Bearer $apiKey')
..headers.set('Content-Type', 'application/json')
..headers.set('Accept', 'application/json')
..write(payload);
final response = await request.close();
if (response.statusCode == 200) {
final responseBody = await response.transform(utf8.decoder).join();
final responseData = jsonDecode(responseBody);
print("Upload URL: ${responseData['upload_url']}");
} else {
print("Request failed with status: ${response.statusCode}");
final responseBody = await response.transform(utf8.decoder).join();
print("Response Body: $responseBody");
}
}
Response
200 OK
{
"upload_url": "https://sampleurl"
}
403 Forbidden
{
"message": "Upload limit reached for this speaker"
}
500 Internal Server Error
{
"error": "Detailed error message"
}
Create a Speaker Profile From a Local Audio File - Part 2 Upload Your Audio File
You can upload your audio file to the specified URL as shown below.
# Assuming 'response' is obtained from your previous request
upload_url = json.loads(response.text)["upload_url"]
# Specify the path to your audio file
file_path = 'example.mp3'
# Open the file in binary mode
with open(file_path, 'rb') as f:
files = {'file': f}
# PUT request to upload the file using the presigned URL
upload_response = requests.put(upload_url, data=f)
# Check the response status code and print appropriate messages
if upload_response.status_code == 200:
result = {"status": "success", "code": 200, "message": "File uploaded successfully", "response": upload_response.text}
else:
result = {"status": "error", "code": upload_response.status_code, "message": "Failed to upload file", "response": upload_response.text}
# Print the result
print(result["code"])
print(result["message"])
if "response" in result:
print(result["response"])
const fs = require('fs');
const axios = require('axios');
const uploadUrl = 'your_presigned_upload_url'; // Replace with actual presigned URL
const filePath = 'example.mp3';
fs.readFile(filePath, (err, data) => {
if (err) throw err;
axios.put(uploadUrl, data, { headers: { 'Content-Type': 'application/octet-stream' } })
.then(response => {
console.log("Status Code:", response.status);
console.log("Message: File uploaded successfully");
})
.catch(error => {
console.log("Status Code:", error.response ? error.response.status : "Error");
console.log("Message: Failed to upload file");
if (error.response) console.log("Response:", error.response.data);
});
});
import okhttp3.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class UploadFile {
public static void main(String[] args) throws IOException {
String uploadUrl = "your_presigned_upload_url"; // Replace with actual presigned URL
String filePath = "example.mp3";
OkHttpClient client = new OkHttpClient();
File file = new File(filePath);
RequestBody requestBody = RequestBody.create(file, MediaType.parse("application/octet-stream"));
Request request = new Request.Builder().url(uploadUrl).put(requestBody).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
System.out.println("Status Code: " + response.code());
System.out.println("Message: File uploaded successfully");
} else {
System.out.println("Status Code: " + response.code());
System.out.println("Message: Failed to upload file");
System.out.println("Response: " + response.body().string());
}
}
}
}
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
public class Program
{
private static readonly string uploadUrl = "your_presigned_upload_url"; // Replace with actual presigned URL
public static async Task Main()
{
using var client = new HttpClient();
using var fileStream = File.OpenRead("example.mp3");
var response = await client.PutAsync(uploadUrl, new StreamContent(fileStream));
if (response.IsSuccessStatusCode)
{
Console.WriteLine("Status Code: 200");
Console.WriteLine("Message: File uploaded successfully");
}
else
{
Console.WriteLine("Status Code: " + response.StatusCode);
Console.WriteLine("Message: Failed to upload file");
Console.WriteLine("Response: " + await response.Content.ReadAsStringAsync());
}
}
}
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
uploadUrl := "your_presigned_upload_url" // Replace with actual presigned URL
filePath := "example.mp3"
file, err := os.Open(filePath)
if err != nil {
fmt.Println("Error:", err)
return
}
defer file.Close()
req, err := http.NewRequest("PUT", uploadUrl, file)
req.Header.Set("Content-Type", "application/octet-stream")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
fmt.Println("Status Code: 200")
fmt.Println("Message: File uploaded successfully")
} else {
fmt.Printf("Status Code: %d\n", resp.StatusCode)
fmt.Println("Message: Failed to upload file")
}
}
require 'net/http'
require 'uri'
upload_url = "your_presigned_upload_url" # Replace with actual presigned URL
file_path = "example.mp3"
uri = URI(upload_url)
file = File.open(file_path, "rb")
request = Net::HTTP::Put.new(uri)
request.body = file.read
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = (uri.scheme == "https")
response = http.request(request)
if response.code == "200"
puts "Status Code: 200"
puts "Message: File uploaded successfully"
else
puts "Status Code: #{response.code}"
puts "Message: Failed to upload file"
puts "Response: #{response.body}"
end
<?php
$uploadUrl = "your_presigned_upload_url"; // Replace with actual presigned URL
$filePath = "example.mp3";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $uploadUrl);
curl_setopt($ch, CURLOPT_PUT, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$file = fopen($filePath, 'r');
curl_setopt($ch, CURLOPT_INFILE, $file);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($filePath));
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
fclose($file);
curl_close($ch);
if ($httpCode == 200) {
echo "Status Code: 200\n";
echo "Message: File uploaded successfully\n";
} else {
echo "Status Code: $httpCode\n";
echo "Message: Failed to upload file\n";
echo "Response: $response\n";
}
?>
import okhttp3.*
import java.io.File
fun main() {
val uploadUrl = "your_presigned_upload_url" // Replace with actual presigned URL
val filePath = "example.mp3"
val client = OkHttpClient()
val file = File(filePath)
val request = Request.Builder()
.url(uploadUrl)
.put(RequestBody.create(MediaType.parse("application/octet-stream"), file))
.build()
client.newCall(request).execute().use { response ->
if (response.isSuccessful) {
println("Status Code: ${response.code()}")
println("Message: File uploaded successfully")
} else {
println("Status Code: ${response.code()}")
println("Message: Failed to upload file")
println("Response: ${response.body()?.string()}")
}
}
}
import Foundation
let uploadUrl = URL(string: "your_presigned_upload_url")! // Replace with actual presigned URL
let filePath = URL(fileURLWithPath: "example.mp3")
var request = URLRequest(url: uploadUrl)
request.httpMethod = "PUT"
request.setValue("application/octet-stream", forHTTPHeaderField: "Content-Type")
let task = URLSession.shared.uploadTask(with: request, fromFile: filePath) { data, response, error in
if let httpResponse = response as? HTTPURLResponse {
if httpResponse.statusCode == 200 {
print("Status Code: 200")
print("Message: File uploaded successfully")
} else {
print("Status Code: \(httpResponse.statusCode)")
print("Message: Failed to upload file")
if let data = data, let responseBody = String(data: data, encoding: .utf8) {
print("Response:", responseBody)
}
}
}
}
task.resume()
import 'dart:io';
void main() async {
const uploadUrl = 'your_presigned_upload_url'; // Replace with actual presigned URL
final file = File('example.mp3');
final request = await HttpClient().putUrl(Uri.parse(uploadUrl))
..headers.set('Content-Type', 'application/octet-stream')
..add(await file.readAsBytes());
final response = await request.close();
if (response.statusCode == 200) {
print("Status Code: 200");
print("Message: File uploaded successfully");
} else {
print("Status Code: ${response.statusCode}");
print("Message: Failed to upload file");
await for (var contents in response.transform(Utf8Decoder())) {
print("Response:", contents);
}
}
}
Response
200 OK
{
"statusCode": 200,
"body": "File uploaded successfully"
}
Create a Speaker Profile From a Local Audio File - Part 3 Generate Speaker Profile
After you have successfully uploaded your audio file, make a request to finisher API as shown below. Make sure speaker_label_name matches the name in your request in Part 1
import requests
import json
speaker_label_name = "your_speaker_name"
url = f"https://api.tor.app/developer/annotations/profiles"
# Define the API key as a variable
api_key = "your_api_key" # Replace with your actual API key
# Set up the headers, including the API key
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}", # Use the variable here
"Accept": "application/json",
}
payload = {"speaker_name": speaker_label_name}
response = requests.post(url, headers=headers, json=payload)
# Print the result
print(response.text)
const axios = require('axios');
const apiKey = 'your_api_key'; // Replace with your actual API key
const speakerLabelName = 'your_speaker_name';
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`,
'Accept': 'application/json'
};
const payload = {
speaker_name: speakerLabelName
};
const url = "https://api.tor.app/developer/annotations/profiles";
axios.post(url, payload, { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error("Error:", error.response ? error.response.data : error.message);
});
import okhttp3.*;
import org.json.JSONObject;
public class CreateSpeakerProfile {
private static final String API_KEY = "your_api_key";
private static final String SPEAKER_LABEL_NAME = "your_speaker_name";
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient();
String url = "https://api.tor.app/developer/annotations/profiles";
JSONObject payload = new JSONObject();
payload.put("speaker_name", SPEAKER_LABEL_NAME);
RequestBody body = RequestBody.create(payload.toString(), MediaType.parse("application/json"));
Request request = new Request.Builder()
.url(url)
.post(body)
.addHeader("Authorization", "Bearer " + API_KEY)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
public class Program
{
private static readonly string apiKey = "your_api_key";
private static readonly string speakerLabelName = "your_speaker_name";
public static async Task Main()
{
var client = new HttpClient();
var url = "https://api.tor.app/developer/annotations/profiles";
var payload = new { speaker_name = speakerLabelName };
var jsonPayload = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
client.DefaultRequestHeaders.Add("Accept", "application/json");
var response = await client.PostAsync(url, jsonPayload);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
const (
apiKey = "your_api_key"
speakerLabelName = "your_speaker_name"
)
func main() {
url := "https://api.tor.app/developer/annotations/profiles"
payload := map[string]string{"speaker_name": speakerLabelName}
payloadBytes, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payloadBytes))
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
var response map[string]interface{}
json.NewDecoder(resp.Body).Decode(&response)
fmt.Println(response)
}
require 'net/http'
require 'json'
require 'uri'
api_key = "your_api_key"
speaker_label_name = "your_speaker_name"
url = URI("https://api.tor.app/developer/annotations/profiles")
body = { "speaker_name" => speaker_label_name }
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request.body = body.to_json
response = http.request(request)
puts response.body
<?php
$apiKey = "your_api_key";
$speakerLabelName = "your_speaker_name";
$url = "https://api.tor.app/developer/annotations/profiles";
$payload = json_encode(["speaker_name" => $speakerLabelName]);
$headers = [
"Authorization: Bearer $apiKey",
"Content-Type: application/json",
"Accept: application/json"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import okhttp3.*
import org.json.JSONObject
fun main() {
val apiKey = "your_api_key"
val speakerLabelName = "your_speaker_name"
val url = "https://api.tor.app/developer/annotations/profiles"
val payload = JSONObject().put("speaker_name", speakerLabelName)
val client = OkHttpClient()
val body = RequestBody.create(MediaType.parse("application/json"), payload.toString())
val request = Request.Builder()
.url(url)
.post(body)
.addHeader("Authorization", "Bearer $apiKey")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build()
client.newCall(request).execute().use { response ->
println(response.body()?.string())
}
}
import Foundation
let apiKey = "your_api_key"
let speakerLabelName = "your_speaker_name"
let url = URL(string: "https://api.tor.app/developer/annotations/profiles")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
let payload: [String: Any] = [
"speaker_name": speakerLabelName
]
request.httpBody = try! JSONSerialization.data(withJSONObject: payload, options: [])
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data, let responseBody = String(data: data, encoding: .utf8) {
print(responseBody)
}
}
task.resume()
import 'dart:convert';
import 'dart:io';
void main() async {
const apiKey = 'your_api_key';
const speakerLabelName = 'your_speaker_name';
final url = Uri.parse('https://api.tor.app/developer/annotations/profiles');
final payload = jsonEncode({
"speaker_name": speakerLabelName,
});
final request = await HttpClient().postUrl(url)
..headers.set('Authorization', 'Bearer $apiKey')
..headers.set('Content-Type', 'application/json')
..headers.set('Accept', 'application/json')
..write(payload);
final response = await request.close();
if (response.statusCode == 200) {
final responseBody = await response.transform(utf8.decoder).join();
print(responseBody);
} else {
print("Request failed with status: ${response.statusCode}");
await response.transform(utf8.decoder).forEach(print);
}
}
Response
200 OK
{
"statusCode": 200,
"body": "Audio processed and uploaded successfully!"
}
403 Forbidden
{
"statusCode": 403,
"body": {
"message": "Upload limit reached for this speaker"
}
}
500 Internal Server Error
{
"statusCode": 500,
"body": "Error processing audio file: Detailed error message"
}
Create a Speaker Profile From Previous Transcriptions
As well as uploading a new audio file to create a speaker profile, you can create a speaker profile from your previous transcriptions.
import requests
import json
url = f"https://api.tor.app/developer/annotations/profiles/create_from_transcription"
order_id = "your_order_id"
old_speaker_name = "SPK_1"
new_speaker_name = "new_speaker_name"
start_time = 0 # in ms
end_time = 13000 # in ms
api_key = "your_api_key" # Replace with your actual API key
config = {
"start_time": start_time,
"end_time": end_time,
"order_id": order_id,
"old_speaker_name": old_speaker_name,
"new_speaker_name": new_speaker_name,
}
# Set up the headers, including the API key
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}", # Use the variable here
"Accept": "application/json",
}
response = requests.request("POST", url, headers=headers, json=config)
print(response.text)
const axios = require('axios');
const url = "https://api.tor.app/developer/annotations/profiles/create_from_transcription";
const apiKey = "your_api_key"; // Replace with your actual API key
const config = {
start_time: 0,
end_time: 13000,
order_id: "your_order_id",
old_speaker_name: "SPK_1",
new_speaker_name: "new_speaker_name"
};
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`,
'Accept': 'application/json'
};
axios.post(url, config, { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error("Error:", error.response ? error.response.data : error.message);
});
import okhttp3.*;
import org.json.JSONObject;
public class CreateProfileFromTranscription {
private static final String API_KEY = "your_api_key";
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient();
String url = "https://api.tor.app/developer/annotations/profiles/create_from_transcription";
JSONObject config = new JSONObject();
config.put("start_time", 0);
config.put("end_time", 13000);
config.put("order_id", "your_order_id");
config.put("old_speaker_name", "SPK_1");
config.put("new_speaker_name", "new_speaker_name");
RequestBody body = RequestBody.create(config.toString(), MediaType.parse("application/json"));
Request request = new Request.Builder()
.url(url)
.post(body)
.addHeader("Authorization", "Bearer " + API_KEY)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
public class Program
{
private static readonly string apiKey = "your_api_key";
public static async Task Main()
{
var client = new HttpClient();
var url = "https://api.tor.app/developer/annotations/profiles/create_from_transcription";
var config = new
{
start_time = 0,
end_time = 13000,
order_id = "your_order_id",
old_speaker_name = "SPK_1",
new_speaker_name = "new_speaker_name"
};
var jsonPayload = new StringContent(JsonSerializer.Serialize(config), Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
client.DefaultRequestHeaders.Add("Accept", "application/json");
var response = await client.PostAsync(url, jsonPayload);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
const apiKey = "your_api_key"
func main() {
url := "https://api.tor.app/developer/annotations/profiles/create_from_transcription"
config := map[string]interface{}{
"start_time": 0,
"end_time": 13000,
"order_id": "your_order_id",
"old_speaker_name": "SPK_1",
"new_speaker_name": "new_speaker_name",
}
payloadBytes, _ := json.Marshal(config)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payloadBytes))
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
var response map[string]interface{}
json.NewDecoder(resp.Body).Decode(&response)
fmt.Println(response)
}
require 'net/http'
require 'json'
require 'uri'
api_key = "your_api_key"
url = URI("https://api.tor.app/developer/annotations/profiles/create_from_transcription")
config = {
"start_time" => 0,
"end_time" => 13000,
"order_id" => "your_order_id",
"old_speaker_name" => "SPK_1",
"new_speaker_name" => "new_speaker_name"
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request.body = config.to_json
response = http.request(request)
puts response.body
<?php
$apiKey = "your_api_key";
$url = "https://api.tor.app/developer/annotations/profiles/create_from_transcription";
$config = json_encode([
"start_time" => 0,
"end_time" => 13000,
"order_id" => "your_order_id",
"old_speaker_name" => "SPK_1",
"new_speaker_name" => "new_speaker_name"
]);
$headers = [
"Authorization: Bearer $apiKey",
"Content-Type: application/json",
"Accept: application/json"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $config);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import okhttp3.*
import org.json.JSONObject
fun main() {
val apiKey = "your_api_key"
val url = "https://api.tor.app/developer/annotations/profiles/create_from_transcription"
val config = JSONObject().apply {
put("start_time", 0)
put("end_time", 13000)
put("order_id", "your_order_id")
put("old_speaker_name", "SPK_1")
put("new_speaker_name", "new_speaker_name")
}
val client = OkHttpClient()
val body = RequestBody.create(MediaType.parse("application/json"), config.toString())
val request = Request.Builder()
.url(url)
.post(body)
.addHeader("Authorization", "Bearer $apiKey")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build()
client.newCall(request).execute().use { response ->
println(response.body()?.string())
}
}
import Foundation
let apiKey = "your_api_key"
let url = URL(string: "https://api.tor.app/developer/annotations/profiles/create_from_transcription")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
let config: [String: Any] = [
"start_time": 0,
"end_time": 13000,
"order_id": "your_order_id",
"old_speaker_name": "SPK_1",
"new_speaker_name": "new_speaker_name"
]
request.httpBody = try! JSONSerialization.data(withJSONObject: config, options: [])
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data, let responseBody = String(data: data, encoding: .utf8) {
print(responseBody)
}
}
task.resume()
import 'dart:convert';
import 'dart:io';
void main() async {
const apiKey = 'your_api_key';
final url = Uri.parse('https://api.tor.app/developer/annotations/profiles/create_from_transcription');
final config = jsonEncode({
"start_time": 0,
"end_time": 13000,
"order_id": "your_order_id",
"old_speaker_name": "SPK_1",
"new_speaker_name": "new_speaker_name",
});
final request = await HttpClient().postUrl(url)
..headers.set('Authorization', 'Bearer $apiKey')
..headers.set('Content-Type', 'application/json')
..headers.set('Accept', 'application/json')
..write(config);
final response = await request.close();
if (response.statusCode == 200) {
final responseBody = await response.transform(utf8.decoder).join();
print(responseBody);
} else {
print("Request failed with status: ${response.statusCode}");
await response.transform(utf8.decoder).forEach(print);
}
}
Response
200 OK
"Audio processed and uploaded successfully!"
400 Bad Request
{
"error": "The request is invalid or malformed."
}
500 Internal Server Error
{
"error": "An error occurred on the server."
}
Get a List of Your Speaker Profiles
You can view the list of speaker profiles you created.
import requests
import json
api_key = "user_api_key"
url = f"https://api.tor.app/developer/annotations/profiles"
# Define the API key as a variable
api_key = "your_api_key" # Replace with your actual API key
# Set up the headers, including the API key
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}", # Use the variable here
"Accept": "application/json",
}
response = requests.get(url, headers=headers, params={})
speaker_labels = json.loads(response.text)
print(f"Speaker profiles: ", speaker_labels)
const axios = require('axios');
const apiKey = 'your_api_key'; // Replace with your actual API key
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`,
'Accept': 'application/json'
};
const url = "https://api.tor.app/developer/annotations/profiles";
axios.get(url, { headers })
.then(response => {
console.log("Speaker profiles:", response.data);
})
.catch(error => {
console.error("Error:", error.response ? error.response.data : error.message);
});
import okhttp3.*;
public class RetrieveSpeakerProfiles {
private static final String API_KEY = "your_api_key";
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient();
String url = "https://api.tor.app/developer/annotations/profiles";
Request request = new Request.Builder()
.url(url)
.get()
.addHeader("Authorization", "Bearer " + API_KEY)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println("Speaker profiles: " + response.body().string());
}
}
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
public class Program
{
private static readonly string apiKey = "your_api_key";
public static async Task Main()
{
var client = new HttpClient();
var url = "https://api.tor.app/developer/annotations/profiles";
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
client.DefaultRequestHeaders.Add("Accept", "application/json");
var response = await client.GetAsync(url);
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine("Speaker profiles: " + responseBody);
}
}
package main
import (
"encoding/json"
"fmt"
"net/http"
)
const apiKey = "your_api_key"
func main() {
url := "https://api.tor.app/developer/annotations/profiles"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
var speakerLabels map[string]interface{}
json.NewDecoder(resp.Body).Decode(&speakerLabels)
fmt.Println("Speaker profiles:", speakerLabels)
}
require 'net/http'
require 'json'
require 'uri'
api_key = "your_api_key"
url = URI("https://api.tor.app/developer/annotations/profiles")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
response = http.request(request)
speaker_labels = JSON.parse(response.body)
puts "Speaker profiles: #{speaker_labels}"
<?php
$apiKey = "your_api_key";
$url = "https://api.tor.app/developer/annotations/profiles";
$headers = [
"Authorization: Bearer $apiKey",
"Content-Type: application/json",
"Accept: application/json"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$speakerLabels = json_decode($response, true);
echo "Speaker profiles: ";
print_r($speakerLabels);
?>
import okhttp3.*
fun main() {
val apiKey = "your_api_key"
val url = "https://api.tor.app/developer/annotations/profiles"
val client = OkHttpClient()
val request = Request.Builder()
.url(url)
.get()
.addHeader("Authorization", "Bearer $apiKey")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build()
client.newCall(request).execute().use { response ->
println("Speaker profiles: ${response.body()?.string()}")
}
}
import Foundation
let apiKey = "your_api_key"
let url = URL(string: "https://api.tor.app/developer/annotations/profiles")!
var request = URLRequest(url: url)
request.httpMethod = "GET"
request.addValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data, let responseBody = String(data: data, encoding: .utf8) {
print("Speaker profiles: \(responseBody)")
}
}
task.resume()
import 'dart:convert';
import 'dart:io';
void main() async {
const apiKey = 'your_api_key';
final url = Uri.parse('https://api.tor.app/developer/annotations/profiles');
final request = await HttpClient().getUrl(url)
..headers.set('Authorization', 'Bearer $apiKey')
..headers.set('Content-Type', 'application/json')
..headers.set('Accept', 'application/json');
final response = await request.close();
if (response.statusCode == 200) {
final responseBody = await response.transform(utf8.decoder).join();
print("Speaker profiles: $responseBody");
} else {
print("Request failed with status: ${response.statusCode}");
await response.transform(utf8.decoder).forEach(print);
}
}
Response
200 OK
{
"statusCode": 200,
"body": [
{
"speaker_name": "speaker1",
"download_url": "https://download_url_1"
},
{
"speaker_name": "speaker2",
"download_url": "https://download_url_2"
}
]
}
500 Error Fetching User Settings
{
"statusCode": 500,
"body": {
"error": "Failed to fetch user settings"
}
}
500 Internal Server Error
{
"statusCode": 500,
"body": {
"error": "Detailed error message"
}
}
Learn Your Speaker Profiles Count and See If You Have Reached Limit For Creating Speaker Profile
For efficiency of transcribing process speaker profile count is limited to 20, if you think you need to increase that limit please contact us.
import requests
import json
url = f"https://api.tor.app/developer/annotations/profiles/count"
# Define the API key as a variable
api_key = "your_api_key" # Replace with your actual API key
payload = {}
# Set up the headers, including the API key
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}", # Use the variable here
"Accept": "application/json",
}
response = requests.get(url, headers=headers, data=payload)
speaker_label_count = json.loads(response.text)
print(f"Speaker profile count: ", speaker_label_count)
const axios = require('axios');
const apiKey = 'your_api_key'; // Replace with your actual API key
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`,
'Accept': 'application/json'
};
const url = "https://api.tor.app/developer/annotations/profiles/count";
axios.get(url, { headers })
.then(response => {
console.log("Speaker profile count:", response.data);
})
.catch(error => {
console.error("Error:", error.response ? error.response.data : error.message);
});
import okhttp3.*;
public class RetrieveSpeakerProfileCount {
private static final String API_KEY = "your_api_key";
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient();
String url = "https://api.tor.app/developer/annotations/profiles/count";
Request request = new Request.Builder()
.url(url)
.get()
.addHeader("Authorization", "Bearer " + API_KEY)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println("Speaker profile count: " + response.body().string());
}
}
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
public class Program
{
private static readonly string apiKey = "your_api_key";
public static async Task Main()
{
var client = new HttpClient();
var url = "https://api.tor.app/developer/annotations/profiles/count";
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
client.DefaultRequestHeaders.Add("Accept", "application/json");
var response = await client.GetAsync(url);
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine("Speaker profile count: " + responseBody);
}
}
package main
import (
"encoding/json"
"fmt"
"net/http"
)
const apiKey = "your_api_key"
func main() {
url := "https://api.tor.app/developer/annotations/profiles/count"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
var speakerLabelCount map[string]interface{}
json.NewDecoder(resp.Body).Decode(&speakerLabelCount)
fmt.Println("Speaker profile count:", speakerLabelCount)
}
require 'net/http'
require 'json'
require 'uri'
api_key = "your_api_key"
url = URI("https://api.tor.app/developer/annotations/profiles/count")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
response = http.request(request)
speaker_label_count = JSON.parse(response.body)
puts "Speaker profile count: #{speaker_label_count}"
<?php
$apiKey = "your_api_key";
$url = "https://api.tor.app/developer/annotations/profiles/count";
$headers = [
"Authorization: Bearer $apiKey",
"Content-Type: application/json",
"Accept: application/json"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$speakerLabelCount = json_decode($response, true);
echo "Speaker profile count: ";
print_r($speakerLabelCount);
?>
import okhttp3.*
fun main() {
val apiKey = "your_api_key"
val url = "https://api.tor.app/developer/annotations/profiles/count"
val client = OkHttpClient()
val request = Request.Builder()
.url(url)
.get()
.addHeader("Authorization", "Bearer $apiKey")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build()
client.newCall(request).execute().use { response ->
println("Speaker profile count: ${response.body()?.string()}")
}
}
import Foundation
let apiKey = "your_api_key"
let url = URL(string: "https://api.tor.app/developer/annotations/profiles/count")!
var request = URLRequest(url: url)
request.httpMethod = "GET"
request.addValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data, let responseBody = String(data: data, encoding: .utf8) {
print("Speaker profile count: \(responseBody)")
}
}
task.resume()
import 'dart:convert';
import 'dart:io';
void main() async {
const apiKey = 'your_api_key';
final url = Uri.parse('https://api.tor.app/developer/annotations/profiles/count');
final request = await HttpClient().getUrl(url)
..headers.set('Authorization', 'Bearer $apiKey')
..headers.set('Content-Type', 'application/json')
..headers.set('Accept', 'application/json');
final response = await request.close();
if (response.statusCode == 200) {
final responseBody = await response.transform(utf8.decoder).join();
print("Speaker profile count: $responseBody");
} else {
print("Request failed with status: ${response.statusCode}");
await response.transform(utf8.decoder).forEach(print);
}
}
Response
200 OK
{
"statusCode": 200,
"body": {
"speaker_label_count": 7,
"limit_reached": false
}
}
200 OK (Limit Reached)
{
"statusCode": 200,
"body": {
"speaker_label_count": 10,
"limit_reached": true
}
}
500 Internal Server Error
{
"statusCode": 500,
"body": {
"error": "Failed to fetch user settings"
}
}
Delete a Speaker Profile
You can delete a speaker profile that you created.
import requests
import json
url = f"https://api.tor.app/developer/annotations/profiles"
api_key = "your_api_key" # Replace with your actual API key
speaker_label_name = "your_speaker_name"
payload = {"speaker_name": speaker_label_name}
# Set up the headers, including the API key
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}", # Use the variable here
"Accept": "application/json",
}
response = requests.delete(url, headers=headers, json=payload)
print(response.text)
const axios = require('axios');
const apiKey = 'your_api_key'; // Replace with your actual API key
const speakerLabelName = 'your_speaker_name';
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`,
'Accept': 'application/json'
};
const payload = {
speaker_name: speakerLabelName
};
const url = "https://api.tor.app/developer/annotations/profiles";
axios.delete(url, { headers, data: payload })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error("Error:", error.response ? error.response.data : error.message);
});
import okhttp3.*;
public class DeleteSpeakerProfile {
private static final String API_KEY = "your_api_key";
private static final String SPEAKER_LABEL_NAME = "your_speaker_name";
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient();
String url = "https://api.tor.app/developer/annotations/profiles";
String jsonPayload = "{\"speaker_name\":\"" + SPEAKER_LABEL_NAME + "\"}";
RequestBody body = RequestBody.create(jsonPayload, MediaType.parse("application/json"));
Request request = new Request.Builder()
.url(url)
.delete(body)
.addHeader("Authorization", "Bearer " + API_KEY)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
public class Program
{
private static readonly string apiKey = "your_api_key";
private static readonly string speakerLabelName = "your_speaker_name";
public static async Task Main()
{
var client = new HttpClient();
var url = "https://api.tor.app/developer/annotations/profiles";
var payload = new { speaker_name = speakerLabelName };
var jsonPayload = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
client.DefaultRequestHeaders.Add("Accept", "application/json");
var request = new HttpRequestMessage(HttpMethod.Delete, url) { Content = jsonPayload };
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
const apiKey = "your_api_key"
const speakerLabelName = "your_speaker_name"
func main() {
url := "https://api.tor.app/developer/annotations/profiles"
payload := map[string]string{"speaker_name": speakerLabelName}
payloadBytes, _ := json.Marshal(payload)
req, _ := http.NewRequest("DELETE", url, bytes.NewBuffer(payloadBytes))
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
var response map[string]interface{}
json.NewDecoder(resp.Body).Decode(&response)
fmt.Println(response)
}
require 'net/http'
require 'json'
require 'uri'
api_key = "your_api_key"
speaker_label_name = "your_speaker_name"
url = URI("https://api.tor.app/developer/annotations/profiles")
body = { "speaker_name" => speaker_label_name }
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request.body = body.to_json
response = http.request(request)
puts response.body
<?php
$apiKey = "your_api_key";
$speakerLabelName = "your_speaker_name";
$url = "https://api.tor.app/developer/annotations/profiles";
$payload = json_encode(["speaker_name" => $speakerLabelName]);
$headers = [
"Authorization: Bearer $apiKey",
"Content-Type: application/json",
"Accept: application/json"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import okhttp3.*
import org.json.JSONObject
fun main() {
val apiKey = "your_api_key"
val speakerLabelName = "your_speaker_name"
val url = "https://api.tor.app/developer/annotations/profiles"
val payload = JSONObject().put("speaker_name", speakerLabelName)
val client = OkHttpClient()
val body = RequestBody.create(MediaType.parse("application/json"), payload.toString())
val request = Request.Builder()
.url(url)
.delete(body)
.addHeader("Authorization", "Bearer $apiKey")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build()
client.newCall(request).execute().use { response ->
println(response.body()?.string())
}
}
import Foundation
let apiKey = "your_api_key"
let speakerLabelName = "your_speaker_name"
let url = URL(string: "https://api.tor.app/developer/annotations/profiles")!
var request = URLRequest(url: url)
request.httpMethod = "DELETE"
request.addValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
let payload: [String: Any] = [
"speaker_name": speakerLabelName
]
request.httpBody = try! JSONSerialization.data(withJSONObject: payload, options: [])
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data, let responseBody = String(data: data, encoding: .utf8) {
print(responseBody)
}
}
task.resume()
import 'dart:convert';
import 'dart:io';
void main() async {
const apiKey = 'your_api_key';
const speakerLabelName = 'your_speaker_name';
final url = Uri.parse('https://api.tor.app/developer/annotations/profiles');
final payload = jsonEncode({
"speaker_name": speakerLabelName,
});
final request = await HttpClient().deleteUrl(url)
..headers.set('Authorization', 'Bearer $apiKey')
..headers.set('Content-Type', 'application/json')
..headers.set('Accept', 'application/json')
..write(payload);
final response = await request.close();
if (response.statusCode == 200) {
final responseBody = await response.transform(utf8.decoder).join();
print(responseBody);
} else {
print("Request failed with status: ${response.statusCode}");
await response.transform(utf8.decoder).forEach(print);
}
}
Response
200 OK
{
"statusCode": 200,
"body": "Speaker deleted successfully"
}
404 Not Found
{
"statusCode": 404,
"body": "Speaker not found"
}
500 Internal Server Error
{
"statusCode": 500,
"body": "Failed to fetch user settings"
}
500 Internal Server Error
{
"statusCode": 500,
"body": "Failed to update user settings"
}
Updated about 1 month ago