Update Transcription Content
💾 Update Transcription Content
After editing your transcription content you can update an existing transcription.
import requests
order_id = "example_order_id" # Replace with your order id
api_key = 'your_api_key_here' # Replace with your actual API key
# Set up the headers, including the API key
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {api_key}',
'Accept': 'application/json'
}
url = f"https://api.tor.app/developer/files/{order_id}/content"
# Define the new content of the transcription
new_content = [{'text': 'New content for a transcription', 'StartTime': 9960, 'EndTime': 10710, 'VoiceStart': 9960, 'VoiceEnd': 10710, 'Speaker': 'SPK_1'}]
response = requests.put(url, headers=headers, json={'content': new_content})
response_json = response.json()
print(response_json)
const axios = require('axios');
const orderId = "your_order_id"; // Replace with your order ID
const apiKey = "your_api_key"; // Replace with your actual API key
const url = `https://api.tor.app/developer/files/${orderId}/content/speaker_labels`;
const headers = {
"Content-Type": "application/json",
"Authorization": `Bearer ${apiKey}`,
"Accept": "application/json"
};
const payload = {
old_speaker_label: "SPK_1",
new_speaker_label: "new_speaker_label"
};
axios.put(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;
import java.io.IOException;
public class UpdateSpeakerLabels {
public static void main(String[] args) throws IOException {
String orderId = "your_order_id"; // Replace with your order ID
String apiKey = "your_api_key"; // Replace with your actual API key
String url = "https://api.tor.app/developer/files/" + orderId + "/content/speaker_labels";
OkHttpClient client = new OkHttpClient();
JSONObject payload = new JSONObject();
payload.put("old_speaker_label", "SPK_1");
payload.put("new_speaker_label", "new_speaker_label");
RequestBody body = RequestBody.create(
payload.toString(),
MediaType.parse("application/json")
);
Request request = new Request.Builder()
.url(url)
.put(body)
.addHeader("Authorization", "Bearer " + apiKey)
.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.Threading.Tasks;
using Newtonsoft.Json;
class Program
{
static async Task Main()
{
string orderId = "your_order_id"; // Replace with your order ID
string apiKey = "your_api_key"; // Replace with your actual API key
string url = $"https://api.tor.app/developer/files/{orderId}/content/speaker_labels";
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
client.DefaultRequestHeaders.Add("Accept", "application/json");
var payload = new
{
old_speaker_label = "SPK_1",
new_speaker_label = "new_speaker_label"
};
StringContent content = new StringContent(JsonConvert.SerializeObject(payload), Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PutAsync(url, content);
string responseData = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseData);
}
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
orderID := "your_order_id" // Replace with your order ID
apiKey := "your_api_key" // Replace with your actual API key
url := fmt.Sprintf("https://api.tor.app/developer/files/%s/content/speaker_labels", orderID)
payload := map[string]string{
"old_speaker_label": "SPK_1",
"new_speaker_label": "new_speaker_label",
}
payloadBytes, _ := json.Marshal(payload)
req, _ := http.NewRequest("PUT", url, bytes.NewBuffer(payloadBytes))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+apiKey)
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 result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
require 'net/http'
require 'json'
require 'uri'
order_id = "your_order_id" # Replace with your order ID
api_key = "your_api_key" # Replace with your actual API key
url = URI("https://api.tor.app/developer/files/#{order_id}/content/speaker_labels")
headers = {
"Authorization" => "Bearer #{api_key}",
"Content-Type" => "application/json",
"Accept" => "application/json"
}
payload = {
old_speaker_label: "SPK_1",
new_speaker_label: "new_speaker_label"
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url, headers)
request.body = payload.to_json
response = http.request(request)
puts response.body
<?php
$order_id = "your_order_id"; // Replace with your order ID
$api_key = "your_api_key"; // Replace with your actual API key
$url = "https://api.tor.app/developer/files/$order_id/content/speaker_labels";
$headers = [
"Authorization: Bearer $api_key",
"Content-Type: application/json",
"Accept: application/json"
];
$payload = json_encode([
"old_speaker_label" => "SPK_1",
"new_speaker_label" => "new_speaker_label"
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import okhttp3.*
import org.json.JSONObject
fun main() {
val orderId = "your_order_id" // Replace with your order ID
val apiKey = "your_api_key" // Replace with your actual API key
val url = "https://api.tor.app/developer/files/$orderId/content/speaker_labels"
val client = OkHttpClient()
val payload = JSONObject()
payload.put("old_speaker_label", "SPK_1")
payload.put("new_speaker_label", "new_speaker_label")
val body = RequestBody.create(MediaType.parse("application/json"), payload.toString())
val request = Request.Builder()
.url(url)
.put(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 orderId = "your_order_id" // Replace with your order ID
let apiKey = "your_api_key" // Replace with your actual API key
let url = URL(string: "https://api.tor.app/developer/files/\(orderId)/content/speaker_labels")!
var request = URLRequest(url: url)
request.httpMethod = "PUT"
request.addValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
let payload: [String: Any] = [
"old_speaker_label": "SPK_1",
"new_speaker_label": "new_speaker_label"
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload, options: [])
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data, error == nil else { return }
if let responseJson = try? JSONSerialization.jsonObject(with: data, options: []) {
print(responseJson)
}
}
task.resume()
import 'dart:convert';
import 'dart:io';
void main() async {
final orderId = "your_order_id"; // Replace with your order ID
final apiKey = "your_api_key"; // Replace with your actual API key
final url = Uri.parse("https://api.tor.app/developer/files/$orderId/content/speaker_labels");
final payload = jsonEncode({
"old_speaker_label": "SPK_1",
"new_speaker_label": "new_speaker_label"
});
final request = await HttpClient().putUrl(url)
..headers.set('Authorization', 'Bearer $apiKey')
..headers.contentType = ContentType.json
..headers.set('Accept', 'application/json')
..write(payload);
final response = await request.close();
final responseData = await response.transform(utf8.decoder).join();
print(responseData);
}
🔄 Update Speaker Labels
If you only need to modify a speaker label within an existing transcription, this API allows you to update the speaker's name without editing the full content.
Simply specify the order ID, the current old_speaker_label, and the desired new_speaker_label.
import requests
import json
order_id = "your_order_id" # Replace with your order ID
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}",
"Accept": "application/json",
}
# Define the API endpoint
url = f"https://api.tor.app/developer/files/{order_id}/content/speaker_labels"
# Define the old and new speaker labels
payload = {"old_speaker_label": "SPK_1", "new_speaker_label": "new_speaker_label"}
# Send the PUT request to update speaker labels
response = requests.put(url, headers=headers, json=payload)
# Parse the response as JSON
response_json = response.json()
# Print the response
print(response_json)
const axios = require('axios');
const orderId = 'example_order_id'; // Replace with your order ID
const apiKey = 'your_api_key_here'; // 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/files/${orderId}/content`;
const newContent = [
{
text: 'New content for a transcription',
StartTime: 9960,
EndTime: 10710,
VoiceStart: 9960,
VoiceEnd: 10710,
Speaker: 'SPK_1'
}
];
axios.put(url, { content: newContent }, { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error("Error:", error.response ? error.response.data : error.message);
});
import okhttp3.*;
import org.json.JSONArray;
import org.json.JSONObject;
public class UpdateTranscriptionContent {
private static final String API_KEY = "your_api_key_here";
private static final String ORDER_ID = "example_order_id";
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient();
String url = "https://api.tor.app/developer/files/" + ORDER_ID + "/content";
JSONObject newContentObject = new JSONObject();
JSONArray contentArray = new JSONArray();
JSONObject content = new JSONObject();
content.put("text", "New content for a transcription");
content.put("StartTime", 9960);
content.put("EndTime", 10710);
content.put("VoiceStart", 9960);
content.put("VoiceEnd", 10710);
content.put("Speaker", "SPK_1");
contentArray.put(content);
newContentObject.put("content", contentArray);
RequestBody body = RequestBody.create(newContentObject.toString(), MediaType.parse("application/json"));
Request request = new Request.Builder()
.url(url)
.put(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()) {
System.out.println("Response: " + response.body().string());
} 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_here";
private static readonly string orderId = "example_order_id";
public static async Task Main()
{
var client = new HttpClient();
var url = $"https://api.tor.app/developer/files/{orderId}/content";
var newContent = new[]
{
new { text = "New content for a transcription", StartTime = 9960, EndTime = 10710, VoiceStart = 9960, VoiceEnd = 10710, Speaker = "SPK_1" }
};
var payload = new { content = newContent };
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.PutAsync(url, jsonPayload);
if (response.IsSuccessStatusCode)
{
var responseData = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseData);
}
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_here"
orderId = "example_order_id"
)
func main() {
url := fmt.Sprintf("https://api.tor.app/developer/files/%s/content", orderId)
newContent := []map[string]interface{}{
{
"text": "New content for a transcription",
"StartTime": 9960,
"EndTime": 10710,
"VoiceStart": 9960,
"VoiceEnd": 10710,
"Speaker": "SPK_1",
},
}
payload := map[string]interface{}{
"content": newContent,
}
payloadBytes, _ := json.Marshal(payload)
req, _ := http.NewRequest("PUT", 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{}
if err := json.NewDecoder(resp.Body).Decode(&response); err != nil {
fmt.Println("Error decoding response:", err)
return
}
fmt.Println(response)
}
require 'net/http'
require 'json'
require 'uri'
api_key = "your_api_key_here"
order_id = "example_order_id"
url = URI("https://api.tor.app/developer/files/#{order_id}/content")
new_content = [
{
"text" => "New content for a transcription",
"StartTime" => 9960,
"EndTime" => 10710,
"VoiceStart" => 9960,
"VoiceEnd" => 10710,
"Speaker" => "SPK_1"
}
]
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request.body = { "content" => new_content }.to_json
response = http.request(request)
puts JSON.parse(response.body)
<?php
$apiKey = "your_api_key_here";
$orderId = "example_order_id";
$url = "https://api.tor.app/developer/files/$orderId/content";
$newContent = [
[
"text" => "New content for a transcription",
"StartTime" => 9960,
"EndTime" => 10710,
"VoiceStart" => 9960,
"VoiceEnd" => 10710,
"Speaker" => "SPK_1"
]
];
$headers = [
"Authorization: Bearer $apiKey",
"Content-Type: application/json",
"Accept: application/json"
];
$payload = json_encode(["content" => $newContent]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
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.JSONArray
import org.json.JSONObject
fun main() {
val apiKey = "your_api_key_here"
val orderId = "example_order_id"
val url = "https://api.tor.app/developer/files/$orderId/content"
val contentArray = JSONArray().apply {
put(JSONObject().apply {
put("text", "New content for a transcription")
put("StartTime", 9960)
put("EndTime", 10710)
put("VoiceStart", 9960)
put("VoiceEnd", 10710)
put("Speaker", "SPK_1")
})
}
val payload = JSONObject().put("content", contentArray)
val client = OkHttpClient()
val body = RequestBody.create(MediaType.parse("application/json"), payload.toString())
val request = Request.Builder()
.url(url)
.put(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_here"
let orderId = "example_order_id"
let url = URL(string: "https://api.tor.app/developer/files/\(orderId)/content")!
var request = URLRequest(url: url)
request.httpMethod = "PUT"
request.addValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
let newContent = [
[
"text": "New content for a transcription",
"StartTime": 9960,
"EndTime": 10710,
"VoiceStart": 9960,
"VoiceEnd": 10710,
"Speaker": "SPK_1"
]
]
request.httpBody = try! JSONSerialization.data(withJSONObject: ["content": newContent], options: [])
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
let jsonResponse = try? JSONSerialization.jsonObject(with: data, options: [])
print(jsonResponse ?? "Failed to parse response")
}
}
task.resume()
import 'dart:convert';
import 'dart:io';
void main() async {
const apiKey = 'your_api_key_here';
const orderId = 'example_order_id';
final url = Uri.parse('https://api.tor.app/developer/files/$orderId/content');
final newContent = [
{
"text": "New content for a transcription",
"StartTime": 9960,
"EndTime": 10710,
"VoiceStart": 9960,
"VoiceEnd": 10710,
"Speaker": "SPK_1"
}
];
final payload = jsonEncode({"content": newContent});
final request = await HttpClient().putUrl(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}");
final responseBody = await response.transform(utf8.decoder).join();
print("Response Body: $responseBody");
}
}
Updated 30 days ago