Transcription Client

The Transcription Client allows you to interact with the HTTPTranscriptServer. Here are examples of how to use different clients to communicate with the server:

1. Send Transcription Job


# Basic transcription
curl -X POST -H "Content-Type: application/json" -d "{\"url\":\"C:\\path\\to\\audio\\file.mp3\"}" http://localhost:8088/transcribe

# Advanced transcription with options
curl -X POST -H "Content-Type: application/json" -d "{
    \"url\":\"C:\\path\\to\\audio\\file.mp3\",
    \"language\":\"fr\",
    \"target_language\":\"English\",
    \"start_time\":30,
    \"end_time\":90,
    \"prompt\":\"This is a French lecture about renewable energy\"
}" http://localhost:8088/transcribe

# Note: Use either 'prompt' or 'hotwords' based on your ASR Mode setting
# For ASR Mode 2, replace 'prompt' with:
# \"hotwords\":\"énergie renouvelable, éolienne, solaire\"

# Basic transcription
otcli.exe --action send --source "C:\path\to\audio\file.mp3"

# Advanced transcription with options
otcli.exe --action send --source "C:\path\to\audio\file.mp3" --language "fr" --target-language "English" --start-time 30 --end-time 90 --prompt "This is a French lecture about renewable energy"

# Note: Use either --prompt or --hotwords based on your ASR Mode setting
# For ASR Mode 2, replace --prompt with:
# --hotwords "énergie renouvelable, éolienne, solaire"

import requests

# Basic transcription
response = requests.post('http://localhost:8088/transcribe', 
                         json={'url': 'C:\\path\\to\\audio\\file.mp3'})

# Advanced transcription with options
response = requests.post('http://localhost:8088/transcribe', 
                         json={
                             'url': 'C:\\path\\to\\audio\\file.mp3',
                             'language': 'fr',
                             'target_language': 'English',
                             'start_time': 30,
                             'end_time': 90,
                             'prompt': 'This is a French lecture about renewable energy'
                         })

# Note: Use either 'prompt' or 'hotwords' based on your ASR Mode setting
# For ASR Mode 2, replace 'prompt' with:
# 'hotwords': 'énergie renouvelable, éolienne, solaire'

job_id = response.json()['job_id']
print(f"Job ID: {job_id}")

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    // Basic transcription
    jobReq := []byte(`{"url": "C:\\path\\to\\audio\\file.mp3"}`)

    // Advanced transcription with options
    // jobReq := []byte(`{
    //     "url": "C:\\path\\to\\audio\\file.mp3",
    //     "language": "fr",
    //     "target_language": "English",
    //     "start_time": 30,
    //     "end_time": 90,
    //     "prompt": "This is a French lecture about renewable energy"
    // }`)

    // Note: Use either 'prompt' or 'hotwords' based on your ASR Mode setting
    // For ASR Mode 2, replace 'prompt' with:
    // "hotwords": "énergie renouvelable, éolienne, solaire"

    resp, _ := http.Post("http://localhost:8088/transcribe", "application/json", bytes.NewBuffer(jobReq))
    var result map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&result)
    jobID := result["job_id"].(string)
    fmt.Printf("Job ID: %s\n", jobID)
}

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class TranscriptionClient {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        
        // Basic transcription
        String jobReq = "{\"url\": \"C:\\\\path\\\\to\\\\audio\\\\file.mp3\"}";

        // Advanced transcription with options
        // String jobReq = "{" +
        //     "\"url\": \"C:\\\\path\\\\to\\\\audio\\\\file.mp3\"," +
        //     "\"language\": \"fr\"," +
        //     "\"target_language\": \"English\"," +
        //     "\"start_time\": 30," +
        //     "\"end_time\": 90," +
        //     "\"prompt\": \"This is a French lecture about renewable energy\"" +
        // "}";

        // Note: Use either 'prompt' or 'hotwords' based on your ASR Mode setting
        // For ASR Mode 2, replace 'prompt' with:
        // "\"hotwords\": \"énergie renouvelable, éolienne, solaire\"" +

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("http://localhost:8088/transcribe"))
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(jobReq))
                .build();
        HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
        String jobId = response.body().split("\"job_id\":\"")[1].split("\"")[0];
        System.out.println("Job ID: " + jobId);
    }
}

2. Query Job Status

curl http://localhost:8088/status/{job_id}
# On Windows:
otcli.exe --action query --jobid {job_id}

# On macOS/Linux:
otcli --action query --jobid {job_id}
import requests

job_id = "your_job_id_here"
response = requests.get(f'http://localhost:8088/status/{job_id}')
status = response.json()['status']
print(f"Job status: {status}")
package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    jobID := "your_job_id_here"
    resp, _ := http.Get(fmt.Sprintf("http://localhost:8088/status/%s", jobID))
    var result map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&result)
    status := result["status"].(string)
    fmt.Printf("Job status: %s\n", status)
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class TranscriptionClient {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        String jobId = "your_job_id_here";
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("http://localhost:8088/status/" + jobId))
                .GET()
                .build();
        HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
        String status = response.body().split("\"status\":\"")[1].split("\"")[0];
        System.out.println("Job status: " + status);
    }
}

3. Get Transcription Result

Text format without timestamps:

curl "http://localhost:8088/result/{job_id}?format=txt×tamp=false"

JSON format with timestamps:

curl "http://localhost:8088/result/{job_id}?format=json×tamp=true"

SRT format:

curl "http://localhost:8088/result/{job_id}?format=srt"

Text format without timestamps:

otcli.exe --action get --get-type transcript --jobid {job_id} --format txt

JSON format with timestamps:

otcli.exe --action get --get-type transcript --jobid {job_id} --format json --timestamp

SRT format:

otcli.exe --action get --get-type transcript --jobid {job_id} --format srt

import requests

job_id = "your_job_id_here"

# Text format without timestamps
response = requests.get(f'http://localhost:8088/result/{job_id}', 
                        params={'format': 'txt', 'timestamp': 'false'})
print(response.text)

# JSON format with timestamps
response = requests.get(f'http://localhost:8088/result/{job_id}', 
                        params={'format': 'json', 'timestamp': 'true'})
result = response.json()
print(result)

# SRT format
response = requests.get(f'http://localhost:8088/result/{job_id}', 
                        params={'format': 'srt'})
print(response.text)
        

package main

import (
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    jobID := "your_job_id_here"

    // Text format without timestamps
    resp, _ := http.Get(fmt.Sprintf("http://localhost:8088/result/%s?format=txt×tamp=false", jobID))
    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))

    // JSON format with timestamps
    resp, _ = http.Get(fmt.Sprintf("http://localhost:8088/result/%s?format=json×tamp=true", jobID))
    body, _ = ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))

    // SRT format
    resp, _ = http.Get(fmt.Sprintf("http://localhost:8088/result/%s?format=srt", jobID))
    body, _ = ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}
        

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class TranscriptionClient {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        String jobId = "your_job_id_here";

        // Text format without timestamps
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("http://localhost:8088/result/" + jobId + "?format=txt×tamp=false"))
                .GET()
                .build();
        HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());

        // JSON format with timestamps
        request = HttpRequest.newBuilder()
                .uri(URI.create("http://localhost:8088/result/" + jobId + "?format=json×tamp=true"))
                .GET()
                .build();
        response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());

        // SRT format
        request = HttpRequest.newBuilder()
                .uri(URI.create("http://localhost:8088/result/" + jobId + "?format=srt"))
                .GET()
                .build();
        response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
        

4. Get Supported Languages

curl http://localhost:8088/languages
otcli.exe --action get --get-type languages

import requests

response = requests.get('http://localhost:8088/languages')
languages = response.json()
print(f"Supported languages: {languages}")

package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    resp, _ := http.Get("http://localhost:8088/languages")
    var languages []string
    json.NewDecoder(resp.Body).Decode(&languages)
    fmt.Printf("Supported languages: %v\n", languages)
}

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class TranscriptionClient {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("http://localhost:8088/languages"))
                .GET()
                .build();
        HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println("Supported languages: " + response.body());
    }
}

Important Parameter Notes

  • start-time and end-time: Must be positive numbers or 0. These parameters set the start and end of the portion of the audio/video file to be transcribed.
  • language: Specifies the source language of the video or audio.
  • target-language: Must be the same as the original language or 'English'. If 'English', the server will transcribe and translate to English.
  • prompt or hotwords: Use only one of these parameters depending on your ASR Mode setting in Settings -> Advanced page.
    • If ASR Mode 1 is selected, use prompt.
    • If ASR Mode 2 is selected, use hotwords.

Note: If the prompt length is more than 244 characters or the hotwords length is more than 500 characters, a warning will be given, but the request will still be valid.

Format and Timestamp Parameters

When retrieving transcription results, you can use the following parameters:

  • format: Specifies the output format of the transcription.
    • txt: Plain text format (default)
    • json: JSON format
    • srt: Subtitle format
  • timestamp: Determines whether to include timestamps in the transcription.
    • false: No timestamps (default)
    • true: Include timestamps

These parameters allow you to customize the transcription output according to your needs.

360Converter Offline Transcriber CLI

otcli (or otcli.exe on Windows) is the command-line interface for 360Converter Offline Transcriber. It is located in the 360Converter Offline Transcriber installation directory. This tool allows you to interact with the transcription service from the command line, providing functionalities to send transcription jobs, query job statuses, and retrieve transcription results. To learn more about the client, refer to Transcription automation client cli.

Transcription Server

For information on how to setup Offline Transcriber Server, please refer to the Transcription Server documentation.