### Get Model Status - C# Source: https://docs.voicebox.sh/api-reference/models/get_model_status_models_status_get Retrieves the status of all available models using C#'s HttpClient. This example shows how to perform a GET request and display the response content. ```C# using System; using System.Net.Http; using System.Threading.Tasks; public class ModelStatusFetcher { static readonly HttpClient client = new HttpClient(); public static async Task Main(string[] args) { try { HttpResponseMessage response = await client.GetAsync("http://localhost:8000/models/status"); response.EnsureSuccessStatusCode(); // Throw if HTTP status code is not 2xx string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } catch (HttpRequestException e) { Console.WriteLine($"\nException Caught!\n -- {e.Message} -- "); } } } ``` -------------------------------- ### Transcribe Audio using C# Source: https://docs.voicebox.sh/api-reference/generation/transcribe_audio_transcribe_post Provides a C# code example for transcribing audio files. This involves using HttpClient to send a POST request with the audio file as multipart/form-data. ```csharp // C# code for transcription would go here. // Example using HttpClient: /* using System; using System.IO; using System.Net.Http; using System.Threading.Tasks; public class TranscribeAudio { public static async Task Main(string[] args) { using (var httpClient = new HttpClient()) { using (var form = new MultipartFormDataContent()) { var audioFile = new FileStream("audio.wav", FileMode.Open); var fileContent = new StreamContent(audioFile); form.Add(fileContent, "file", Path.GetFileName("audio.wav")); var response = await httpClient.PostAsync("http://localhost:8000/transcribe", form); response.EnsureSuccessStatusCode(); // Throw if not 2xx var responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } } } } */ ``` -------------------------------- ### Transcribe Audio using Go Source: https://docs.voicebox.sh/api-reference/generation/transcribe_audio_transcribe_post Provides a Go code example for transcribing audio files. This involves setting up an HTTP client to send a POST request to the /transcribe endpoint with the audio file. ```go // Go code for transcription would go here. // Example using net/http: /* package main import ( "bytes" "fmt" "io" "mime/multipart" "net/http" "os" ) func main() { url := "http://localhost:8000/transcribe" file, err := os.Open("audio.wav") // Replace with your audio file path if err != nil { panic(err) } defer file.Close() body := &bytes.Buffer{} writer := multipart.NewWriter(body) part, err := writer.CreateFormFile("file", "audio.wav") if err != nil { panic(err) } _, err = io.Copy(part, file) if err != nil { panic(err) } writer.Close() // Don't forget to close the multipart writer req, err := http.NewRequest("POST", url, body) if err != nil { panic(err) } req.Header.Set("Content-Type", writer.FormDataContentType()) client := &http.Client{} res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() responseBody, err := io.ReadAll(res.Body) if err != nil { panic(err) } fmt.Println(string(responseBody)) } */ ``` -------------------------------- ### Get Model Status - Python Source: https://docs.voicebox.sh/api-reference/models/get_model_status_models_status_get Retrieves the status of all available models using Python's requests library. This example shows a simple GET request and how to access the JSON response. ```Python import requests response = requests.get('http://localhost:8000/models/status') print(response.json()) ``` -------------------------------- ### Get Model Status - JavaScript Source: https://docs.voicebox.sh/api-reference/models/get_model_status_models_status_get Retrieves the status of all available models using JavaScript's fetch API. This example demonstrates how to make a GET request to the /models/status endpoint and handle the JSON response. ```JavaScript fetch('http://localhost:8000/models/status') .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### GET /profiles Source: https://docs.voicebox.sh/api-reference/profiles/list_profiles_profiles_get Retrieves a list of all available voice profiles from the system. ```APIDOC ## GET /profiles ### Description Retrieves a list of all voice profiles currently stored in the system. ### Method GET ### Endpoint http://localhost:8000/profiles ### Parameters None ### Request Example curl -X GET "http://localhost:8000/profiles" ### Response #### Success Response (200) - **id** (string) - Unique identifier for the profile - **name** (string) - Name of the voice profile - **description** (string) - Brief description of the profile - **language** (string) - Language code for the profile - **created_at** (string) - ISO 8601 timestamp of creation - **updated_at** (string) - ISO 8601 timestamp of last update #### Response Example [ { "id": "string", "name": "string", "description": "string", "language": "string", "created_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z" } ] ``` -------------------------------- ### GET /models/status Source: https://docs.voicebox.sh/api-reference/models/get_model_status_models_status_get Retrieves the status of all available models, including whether they are downloaded and loaded. ```APIDOC ## GET /models/status ### Description Get status of all available models. ### Method GET ### Endpoint /models/status ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **models** (array) - A list of model objects, each containing: - **model_name** (string) - The internal name of the model. - **display_name** (string) - The user-friendly name of the model. - **downloaded** (boolean) - Indicates if the model is downloaded. - **size_mb** (integer) - The size of the model in megabytes. - **loaded** (boolean) - Indicates if the model is currently loaded in memory. #### Response Example ```json { "models": [ { "model_name": "string", "display_name": "string", "downloaded": true, "size_mb": 0, "loaded": false } ] } ``` ``` -------------------------------- ### Get Model Status - Java Source: https://docs.voicebox.sh/api-reference/models/get_model_status_models_status_get Retrieves the status of all available models using Java's HttpClient. This snippet demonstrates making a GET request and handling the response. ```Java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class ModelStatus { public static void main(String[] args) throws Exception { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("http://localhost:8000/models/status")) .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } ``` -------------------------------- ### Get Audio Source: https://docs.voicebox.sh/api-reference/generation/get_audio_audio__generation_id__get Serve generated audio file using its unique generation ID. ```APIDOC ## GET /audio/{generation_id} ### Description Serve generated audio file. ### Method GET ### Endpoint /audio/{generation_id} ### Parameters #### Path Parameters - **generation_id** (string) - Required - The ID of the audio generation. ### Response #### Success Response (200) - **Response Body**: application/json (null) #### Error Response (422) - **Response Body**: application/json ```json { "detail": [ { "loc": [ "string" ], "msg": "string", "type": "string" } ] } ``` ### Request Example ```bash curl -X GET "http://localhost:8000/audio/string" ``` ``` -------------------------------- ### Get Profile Samples - Go Source: https://docs.voicebox.sh/api-reference/profiles/get_profile_samples_profiles__profile_id__samples_get Retrieves all audio samples associated with a specific profile ID using Go. This endpoint requires a valid profile ID as a path parameter. The response includes a list of sample objects, each containing an ID, profile ID, audio path, and reference text. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { profileID := "string" url := fmt.Sprintf("http://localhost:8000/profiles/%s/samples", profileID) res, err := http.Get(url) if err != nil { fmt.Printf("Error making request: %s\n", err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Printf("Error reading response body: %s\n", err) return } fmt.Println(string(body)) } ``` -------------------------------- ### Transcribe Audio using cURL Source: https://docs.voicebox.sh/api-reference/generation/transcribe_audio_transcribe_post Example of how to transcribe an audio file to text using a cURL command. This involves sending a POST request to the /transcribe endpoint with the audio file in the request body. ```bash curl -X POST "http://localhost:8000/transcribe" \ -F file="string" ``` -------------------------------- ### Get Model Status - Go Source: https://docs.voicebox.sh/api-reference/models/get_model_status_models_status_get Retrieves the status of all available models using Go's net/http package. This code snippet shows how to perform a GET request and parse the JSON response. ```Go package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" ) func main() { resp, err := http.Get("http://localhost:8000/models/status") if err != nil { fmt.Printf("Error making request: %s\n", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Printf("Error reading response body: %s\n", err) return } var result map[string]interface{} err = json.Unmarshal(body, &result) if err != nil { fmt.Printf("Error unmarshalling JSON: %s\n", err) return } fmt.Println(result) } ``` -------------------------------- ### GET / Source: https://docs.voicebox.sh/api-reference/general/root__get The root endpoint serves as the entry point for the Voicebox API, providing basic connectivity verification. ```APIDOC ## GET / ### Description Root endpoint used to verify that the Voicebox API service is reachable. ### Method GET ### Endpoint http://localhost:8000/ ### Parameters None ### Request Example ``` curl -X GET "http://localhost:8000" ``` ### Response #### Success Response (200) - **body** (null) - Returns an empty response body. #### Response Example ``` null ``` ``` -------------------------------- ### Get Profile Samples - Java Source: https://docs.voicebox.sh/api-reference/profiles/get_profile_samples_profiles__profile_id__samples_get Retrieves all audio samples associated with a specific profile ID using Java. This endpoint requires a valid profile ID as a path parameter. The response includes a list of sample objects, each containing an ID, profile ID, audio path, and reference text. ```java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.io.IOException; public class GetProfileSamples { public static void main(String[] args) { String profileId = "string"; String url = "http://localhost:8000/profiles/" + profileId + "/samples"; HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) .GET() .build(); try { HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } catch (IOException | InterruptedException e) { e.printStackTrace(); } } } ``` -------------------------------- ### GET /profiles/{profile_id}/samples Source: https://docs.voicebox.sh/api-reference/profiles/get_profile_samples_profiles__profile_id__samples_get Retrieves a list of all audio samples associated with a specific voice profile. ```APIDOC ## GET /profiles/{profile_id}/samples ### Description Retrieves all audio samples linked to a specific voice profile ID. ### Method GET ### Endpoint http://localhost:8000/profiles/{profile_id}/samples ### Parameters #### Path Parameters - **profile_id** (string) - Required - The unique identifier of the profile. ### Request Example curl -X GET "http://localhost:8000/profiles/string/samples" ### Response #### Success Response (200) - **id** (string) - Sample ID - **profile_id** (string) - Associated profile ID - **audio_path** (string) - Path to the audio file - **reference_text** (string) - Transcribed text of the sample #### Response Example [ { "id": "string", "profile_id": "string", "audio_path": "string", "reference_text": "string" } ] ``` -------------------------------- ### Get Profile Samples - C# Source: https://docs.voicebox.sh/api-reference/profiles/get_profile_samples_profiles__profile_id__samples_get Retrieves all audio samples associated with a specific profile ID using C#. This endpoint requires a valid profile ID as a path parameter. The response includes a list of sample objects, each containing an ID, profile ID, audio path, and reference text. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class GetProfileSamples { public static async Task Main(string profileId) { using (HttpClient client = new HttpClient()) { string url = $"http://localhost:8000/profiles/{profileId}/samples"; HttpResponseMessage response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); // Throw if not 2xx string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } } } ``` -------------------------------- ### Get Profile Samples - JavaScript Source: https://docs.voicebox.sh/api-reference/profiles/get_profile_samples_profiles__profile_id__samples_get Retrieves all audio samples associated with a specific profile ID using JavaScript. This endpoint requires a valid profile ID as a path parameter. The response includes a list of sample objects, each containing an ID, profile ID, audio path, and reference text. ```javascript fetch('http://localhost:8000/profiles/{profile_id}/samples') .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Get Profile Samples - Python Source: https://docs.voicebox.sh/api-reference/profiles/get_profile_samples_profiles__profile_id__samples_get Retrieves all audio samples associated with a specific profile ID using Python. This endpoint requires a valid profile ID as a path parameter. The response includes a list of sample objects, each containing an ID, profile ID, audio path, and reference text. ```python import requests profile_id = "string" url = f"http://localhost:8000/profiles/{profile_id}/samples" response = requests.get(url) if response.status_code == 200: print(response.json()) elif response.status_code == 422: print("Validation Error:", response.json()) else: print(f"Error: {response.status_code}") ``` -------------------------------- ### Get Stats Source: https://docs.voicebox.sh/api-reference/history/get_stats_history_stats_get Retrieves generation statistics from the Voicebox API. ```APIDOC ## GET /history/stats ### Description Get generation statistics. ### Method GET ### Endpoint /history/stats ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET "http://localhost:8000/history/stats" ``` ### Response #### Success Response (200) - **null** (null) - Placeholder for statistics data. #### Response Example ```json null ``` ``` -------------------------------- ### Get Profile Samples - cURL Source: https://docs.voicebox.sh/api-reference/profiles/get_profile_samples_profiles__profile_id__samples_get Retrieves all audio samples associated with a specific profile ID. This endpoint requires a valid profile ID as a path parameter. The response includes a list of sample objects, each containing an ID, profile ID, audio path, and reference text. ```curl curl -X GET "http://localhost:8000/profiles/string/samples" ``` -------------------------------- ### Get Model Status Source: https://docs.voicebox.sh/api-reference/history/get_stats_history_stats_get Retrieves the status of all available models in Voicebox. ```APIDOC ## GET /models/status ### Description Get status of all available models. ### Method GET ### Endpoint /models/status ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET "http://localhost:8000/models/status" ``` ### Response #### Success Response (200) - **models** (object) - An object containing the status of each model. - **model_name** (string) - The status of the model (e.g., 'available', 'unavailable'). #### Response Example ```json { "gpt-3.5-turbo": "available", "claude-3-opus": "available" } ``` ``` -------------------------------- ### Delete Generation by ID (Go) Source: https://docs.voicebox.sh/api-reference/history/delete_generation_history__generation_id__delete Provides a Go example for deleting a generation by its ID. This function constructs the URL with the generation ID and sends a DELETE request. Error handling is included for unsuccessful requests. ```go package main import ( "fmt" "net/http" "bytes" "io/ioutil" ) func deleteGeneration(generationID string) error { url := fmt.Sprintf("http://localhost:8000/history/%s", generationID) req, err := http.NewRequest("DELETE", url, bytes.NewBuffer(nil)) if err != nil { return fmt.Errorf("failed to create request: %w", err) } client := &http.Client{} res, err := client.Do(req) if err != nil { return fmt.Errorf("failed to send request: %w", err) } defer res.Body.Close() if res.StatusCode != http.StatusOK { bodyBytes, _ := ioutil.ReadAll(res.Body) return fmt.Errorf("failed to delete generation, status: %d, body: %s", res.StatusCode, string(bodyBytes)) } return nil } ``` -------------------------------- ### GET /profiles/{profile_id} Source: https://docs.voicebox.sh/api-reference/profiles/get_profile_profiles__profile_id__get Retrieves a specific voice profile using its unique identifier. ```APIDOC ## GET /profiles/{profile_id} ### Description Get a voice profile by ID. ### Method GET ### Endpoint `/profiles/{profile_id}` ### Parameters #### Path Parameters - **profile_id** (string) - Required - The unique identifier of the profile to retrieve. ### Request Example ```json { "example": "Not applicable for GET request body" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the profile. - **name** (string) - The name of the voice profile. - **description** (string) - A description of the voice profile. - **language** (string) - The language associated with the profile. - **created_at** (string) - The timestamp when the profile was created. - **updated_at** (string) - The timestamp when the profile was last updated. #### Response Example ```json { "id": "string", "name": "string", "description": "string", "language": "string", "created_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z" } ``` #### Error Response (422) - **detail** (array) - An array of error details. - **loc** (array) - The location of the error. - **msg** (string) - The error message. - **type** (string) - The type of error. #### Response Example ```json { "detail": [ { "loc": [ "string" ], "msg": "string", "type": "string" } ] } ``` ``` -------------------------------- ### Get Generation by ID Source: https://docs.voicebox.sh/api-reference/history/get_generation_history__generation_id__get Retrieves a specific generation record using its unique identifier. ```APIDOC ## GET /history/{generation_id} ### Description Get a generation by ID. ### Method GET ### Endpoint `/history/{generation_id}` ### Parameters #### Path Parameters - **generation_id** (string) - Required - The unique identifier for the generation. ### Request Example ```json { "example": "Not applicable for GET request" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the generation. - **profile_id** (string) - The identifier for the associated profile. - **profile_name** (string) - The name of the associated profile. - **text** (string) - The generated text. - **language** (string) - The language of the generated text. - **audio_path** (string) - The path to the generated audio file. - **duration** (number) - The duration of the audio in seconds. - **seed** (number) - The seed used for generation. - **created_at** (string) - The timestamp when the generation was created (ISO 8601 format). #### Error Response (422) - **detail** (array) - An array of error details. - **loc** (array) - The location of the error (e.g., field name). - **msg** (string) - The error message. - **type** (string) - The type of error. #### Response Example (200) ```json { "id": "string", "profile_id": "string", "profile_name": "string", "text": "string", "language": "string", "audio_path": "string", "duration": 0, "seed": 0, "created_at": "2019-08-24T14:15:22Z" } ``` #### Response Example (422) ```json { "detail": [ { "loc": [ "string" ], "msg": "string", "type": "string" } ] } ``` ``` -------------------------------- ### Get Model Status - cURL Source: https://docs.voicebox.sh/api-reference/models/get_model_status_models_status_get Retrieves the status of all available models. This endpoint returns a JSON object containing an array of model details, including name, download status, size, and loaded status. ```cURL curl -X GET "http://localhost:8000/models/status" ``` -------------------------------- ### Get Audio by Generation ID Source: https://docs.voicebox.sh/api-reference/generation/get_audio_audio__generation_id__get Retrieves a generated audio file using its unique generation identifier. This endpoint returns the audio data upon a successful 200 status or validation errors with a 422 status. ```bash curl -X GET "http://localhost:8000/audio/string" ``` -------------------------------- ### GET /health Source: https://docs.voicebox.sh/api-reference/general/health_health_get Checks the operational status of the Voicebox service, including model availability and hardware resource usage. ```APIDOC ## GET /health ### Description Returns the current health status of the API, including whether the model is loaded, downloaded, and the current GPU/VRAM usage. ### Method GET ### Endpoint /health ### Response #### Success Response (200) - **status** (string) - The current status of the service. - **model_loaded** (boolean) - Indicates if the model is loaded into memory. - **model_downloaded** (boolean) - Indicates if the model files are present. - **model_size** (string) - The size of the loaded model. - **gpu_available** (boolean) - Indicates if a GPU is detected. - **vram_used_mb** (integer) - The amount of VRAM currently in use in megabytes. #### Response Example { "status": "ok", "model_loaded": true, "model_downloaded": true, "model_size": "1.2GB", "gpu_available": true, "vram_used_mb": 512 } ``` -------------------------------- ### Delete Generation by ID (C#) Source: https://docs.voicebox.sh/api-reference/history/delete_generation_history__generation_id__delete A C# example for deleting a generation by its ID using `HttpClient`. This method sends a DELETE request to the API endpoint and processes the response, including error handling for non-successful status codes. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class VoiceboxClient { public static async Task DeleteGenerationAsync(string generationId) { using (HttpClient client = new HttpClient()) { string url = $"http://localhost:8000/history/{generationId}"; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Delete, url); HttpResponseMessage response = await client.SendAsync(request); if (response.IsSuccessStatusCode) { return await response.Content.ReadAsStringAsync(); } else { Console.WriteLine($"Error deleting generation: {response.StatusCode}"); string errorBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(errorBody); return null; } } } } ``` -------------------------------- ### Retrieve Root Endpoint via HTTP GET Source: https://docs.voicebox.sh/api-reference/general/root__get The root endpoint serves as the entry point for the Voicebox API. It returns a 200 OK status code with a null response body, confirming the service is reachable. ```cURL curl -X GET "http://localhost:8000" ``` ```JavaScript fetch('http://localhost:8000', { method: 'GET' }).then(response => response.json()); ``` ```Go package main import "net/http" func main() { resp, _ := http.Get("http://localhost:8000") defer resp.Body.Close() } ``` ```Python import requests response = requests.get("http://localhost:8000") print(response.status_code) ``` ```Java import java.net.http.*; HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://localhost:8000")).build(); ``` ```C# using System.Net.Http; var client = new HttpClient(); var response = await client.GetAsync("http://localhost:8000"); ``` -------------------------------- ### Get Generation Statistics via Voicebox API Source: https://docs.voicebox.sh/api-reference/history/get_stats_history_stats_get Retrieves aggregate statistics for generation history. This endpoint requires no parameters and returns a JSON object containing usage data. ```bash curl -X GET "http://localhost:8000/history/stats" ``` -------------------------------- ### Health Check Endpoint (cURL) Source: https://docs.voicebox.sh/api-reference/general/health_health_get This cURL command demonstrates how to perform a health check on the Voicebox API. It sends a GET request to the /health endpoint. ```shell curl -X GET "http://localhost:8000/health" ``` -------------------------------- ### Get Voice Profile by ID Source: https://docs.voicebox.sh/api-reference/profiles/get_profile_profiles__profile_id__get Retrieves the details of a specific voice profile using its unique identifier. The endpoint returns a JSON object containing profile metadata, or a 422 error if the request parameters are invalid. ```bash curl -X GET "http://localhost:8000/profiles/string" ``` -------------------------------- ### Get Generation by ID using Voicebox API Source: https://docs.voicebox.sh/api-reference/history/get_generation_history__generation_id__get Retrieves the details of a specific audio generation using its unique identifier. This endpoint returns a 200 status code with the generation metadata or a 422 error for validation failures. ```cURL curl -X GET "http://localhost:8000/history/string" ``` -------------------------------- ### Transcribe Audio using Python Source: https://docs.voicebox.sh/api-reference/generation/transcribe_audio_transcribe_post Illustrates how to transcribe audio to text using Python. This typically involves using the 'requests' library to send a POST request with the audio file. ```python # Python code for transcription would go here. # Example using requests library: /* import requests url = "http://localhost:8000/transcribe" files = { 'file': open('audio.wav', 'rb') # Replace with your audio file path } response = requests.post(url, files=files) if response.status_code == 200: print(response.json()) elif response.status_code == 422: print("Validation Error:", response.json()) else: print(f"Error: {response.status_code}") */ ``` -------------------------------- ### Transcribe Audio using JavaScript Source: https://docs.voicebox.sh/api-reference/generation/transcribe_audio_transcribe_post Demonstrates how to transcribe an audio file to text using JavaScript. This typically involves using the Fetch API to send a POST request with the audio file as multipart/form-data. ```javascript // JavaScript code for transcription would go here. // Example using Fetch API: /* fetch('http://localhost:8000/transcribe', { method: 'POST', body: formData }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); */ ``` -------------------------------- ### Transcribe Audio using Java Source: https://docs.voicebox.sh/api-reference/generation/transcribe_audio_transcribe_post Shows a Java code snippet for transcribing audio files. This involves using an HTTP client library to perform a POST request with the audio file. ```java // Java code for transcription would go here. // Example using Apache HttpClient: /* import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.content.FileBody; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import java.io.File; public class TranscribeAudio { public static void main(String[] args) throws Exception { CloseableHttpClient httpclient = HttpClients.createDefault(); try { HttpPost httppost = new HttpPost("http://localhost:8000/transcribe"); File audioFile = new File("audio.wav"); // Replace with your audio file path FileBody fileBody = new FileBody(audioFile); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addPart("file", fileBody); HttpEntity multipart = builder.build(); httppost.setEntity(multipart); System.out.println("Executing request " + httppost.getRequestLine()); CloseableHttpResponse response = httpclient.execute(httppost); try { System.out.println("----------------------------------------"); System.out.println(response.getStatusLine()); HttpEntity entity = response.getEntity(); if (entity != null) { String responseString = EntityUtils.toString(entity, "UTF-8"); System.out.println(responseString); } EntityUtils.consume(entity); } finally { response.close(); } } finally { httpclient.close(); } } } */ ``` -------------------------------- ### POST /profiles/{profile_id}/samples Source: https://docs.voicebox.sh/api-reference/profiles/add_profile_sample_profiles__profile_id__samples_post Add a sample to a voice profile. This endpoint allows you to upload an audio file and its corresponding reference text to a specified profile. ```APIDOC ## POST /profiles/{profile_id}/samples ### Description Add a sample to a voice profile. This endpoint allows you to upload an audio file and its corresponding reference text to a specified profile. ### Method POST ### Endpoint `/profiles/{profile_id}/samples` ### Parameters #### Path Parameters - **profile_id** (string) - Required - The ID of the profile to which the sample will be added. #### Request Body - **file** (file) - Required - The audio file to upload (multipart/form-data). - **reference_text** (string) - Required - The reference text for the audio sample. ### Request Example ```json { "file": "binary", "reference_text": "string" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the added sample. - **profile_id** (string) - The ID of the profile the sample belongs to. - **audio_path** (string) - The path to the stored audio file. - **reference_text** (string) - The reference text associated with the sample. #### Response Example ```json { "id": "string", "profile_id": "string", "audio_path": "string", "reference_text": "string" } ``` #### Error Response (422) - **detail** (array) - An array of error details. - **loc** (array) - The location of the error. - **msg** (string) - The error message. - **type** (string) - The error type. #### Response Example ```json { "detail": [ { "loc": [ "string" ], "msg": "string", "type": "string" } ] } ``` ``` -------------------------------- ### POST /transcribe Source: https://docs.voicebox.sh/api-reference/generation/transcribe_audio_transcribe_post Transcribes an uploaded audio file into text format. ```APIDOC ## POST /transcribe ### Description Transcribe an audio file to text. This endpoint accepts multipart/form-data containing the audio file. ### Method POST ### Endpoint http://localhost:8000/transcribe ### Parameters #### Request Body - **file** (binary) - Required - The audio file to be transcribed. - **language** (string) - Optional - The language code of the audio content. ### Request Example curl -X POST "http://localhost:8000/transcribe" \ -F file="@path/to/audio.wav" ### Response #### Success Response (200) - **text** (string) - The transcribed text. - **duration** (integer) - The duration of the audio in seconds. #### Response Example { "text": "string", "duration": 0 } #### Error Response (422) - **detail** (array) - List of validation errors. #### Error Example { "detail": [ { "loc": ["string"], "msg": "string", "type": "string" } ] } ``` -------------------------------- ### POST /profiles Source: https://docs.voicebox.sh/api-reference/profiles/create_profile_profiles_post Create a new voice profile by providing a name and optional metadata. ```APIDOC ## POST /profiles ### Description Create a new voice profile in the system. ### Method POST ### Endpoint http://localhost:8000/profiles ### Parameters #### Request Body - **name** (string) - Required - The name of the profile (1 <= length <= 100) - **description** (string) - Optional - A brief description of the profile - **language** (string) - Optional - The language code (default: "en", allowed: "en", "zh") ### Request Example { "name": "My Voice Profile", "description": "A professional voice model", "language": "en" } ### Response #### Success Response (200) - **id** (string) - Unique identifier for the profile - **name** (string) - Name of the profile - **description** (string) - Description of the profile - **language** (string) - Language code - **created_at** (string) - ISO timestamp of creation - **updated_at** (string) - ISO timestamp of last update #### Response Example { "id": "uuid-12345", "name": "My Voice Profile", "description": "A professional voice model", "language": "en", "created_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z" } ``` -------------------------------- ### Add Profile Sample via Voicebox API Source: https://docs.voicebox.sh/api-reference/profiles/add_profile_sample_profiles__profile_id__samples_post Adds a new audio sample to a specific voice profile using a multipart/form-data request. The endpoint requires a binary file and associated reference text, returning the created sample object upon success. ```cURL curl -X POST "http://localhost:8000/profiles/string/samples" \ -F file="string" \ -F reference_text="string" ``` -------------------------------- ### POST /generate Source: https://docs.voicebox.sh/api-reference/generation/generate_speech_generate_post Generates speech from text using a specified voice profile. Supports various parameters for customization. ```APIDOC ## POST /generate ### Description Generate speech from text using a voice profile. ### Method POST ### Endpoint http://localhost:8000/generate ### Parameters #### Request Body - **profile_id** (string) - Required - The ID of the voice profile to use. - **text** (string) - Required - The text to convert to speech. Length must be between 1 and 5000 characters. - **language** (string) - Optional - The language of the text. Defaults to "en". Must match the pattern `^(en|zh)$`. - **seed** (integer|null) - Optional - A seed for reproducibility. - **model_size** (string|null) - Optional - The size of the model to use. Defaults to "1.7B". ### Request Example ```json { "profile_id": "string", "text": "string" } ``` ### Response #### Success Response (200) - **id** (string) - The ID of the generated speech. - **profile_id** (string) - The ID of the voice profile used. - **text** (string) - The input text. - **language** (string) - The language of the speech. - **audio_path** (string) - The path to the generated audio file. - **duration** (number) - The duration of the audio in seconds. - **seed** (number) - The seed used for generation. - **created_at** (string) - The timestamp when the speech was generated. #### Response Example (200) ```json { "id": "string", "profile_id": "string", "text": "string", "language": "string", "audio_path": "string", "duration": 0, "seed": 0, "created_at": "2019-08-24T14:15:22Z" } ``` #### Error Response (422) - **detail** (array) - An array of error details. - **loc** (array) - The location of the error. - **msg** (string) - The error message. - **type** (string) - The error type. #### Response Example (422) ```json { "detail": [ { "loc": [ "string" ], "msg": "string", "type": "string" } ] } ``` ``` -------------------------------- ### Add Profile Sample - cURL Source: https://docs.voicebox.sh/api-reference/profiles/get_profile_samples_profiles__profile_id__samples_get Adds a new audio sample to an existing voice profile. This operation requires the profile ID and the audio data to be provided. ```curl curl -X POST "http://localhost:8000/profiles/{profile_id}/samples" -H "Content-Type: multipart/form-data" -F "audio=@/path/to/your/audio.wav" -F "reference_text=Your reference text" ``` -------------------------------- ### Generate Speech from Text Source: https://docs.voicebox.sh/api-reference/generation/generate_speech_generate_post Sends a text payload to the /generate endpoint to create audio using a specified voice profile. Requires a profile_id and text string, with optional parameters for language, seed, and model size. ```bash curl -X POST "http://localhost:8000/generate" \ -H "Content-Type: application/json" \ -d '{ "profile_id": "string", "text": "string" }' ``` -------------------------------- ### PUT /profiles/{profile_id} Source: https://docs.voicebox.sh/api-reference/profiles/update_profile_profiles__profile_id__put Updates an existing voice profile's details including name, description, and language settings. ```APIDOC ## PUT /profiles/{profile_id} ### Description Updates the attributes of a specific voice profile identified by its unique ID. ### Method PUT ### Endpoint http://localhost:8000/profiles/{profile_id} ### Parameters #### Path Parameters - **profile_id** (string) - Required - The unique identifier of the profile to update. #### Request Body - **name** (string) - Required - The name of the profile (1-100 characters). - **description** (string) - Optional - A brief description of the profile. - **language** (string) - Optional - The language code (default: "en", allowed: "en", "zh"). ### Request Example { "name": "New Profile Name", "description": "Updated description", "language": "en" } ### Response #### Success Response (200) - **id** (string) - Profile ID - **name** (string) - Profile name - **description** (string) - Profile description - **language** (string) - Language code - **created_at** (string) - Creation timestamp - **updated_at** (string) - Last update timestamp #### Response Example { "id": "123", "name": "New Profile Name", "description": "Updated description", "language": "en", "created_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z" } ``` -------------------------------- ### Create Voice Profile Source: https://docs.voicebox.sh/api-reference/profiles/create_profile_profiles_post Creates a new voice profile by sending a JSON payload to the /profiles endpoint. The request requires a name field, with optional description and language parameters. ```bash curl -X POST "http://localhost:8000/profiles" \ -H "Content-Type: application/json" \ -d '{ "name": "string" }' ``` -------------------------------- ### List History Source: https://docs.voicebox.sh/api-reference/history/list_history_history_get Lists generation history with optional filters for profile ID, search terms, and pagination. ```APIDOC ## GET /history ### Description List generation history with optional filters. ### Method GET ### Endpoint /history ### Query Parameters - **profile_id** (string|null) - Optional - Filter history by profile ID. - **search** (string|null) - Optional - Filter history by search term. - **limit** (integer) - Optional - The maximum number of items to return. Defaults to 50. - **offset** (integer) - Optional - The number of items to skip. Defaults to 0. ### Response #### Success Response (200) - **items** (array) - A list of generation history items. - **id** (string) - The unique identifier of the generation. - **profile_id** (string) - The ID of the profile associated with the generation. - **profile_name** (string) - The name of the profile. - **text** (string) - The generated text. - **language** (string) - The language of the generated text. - **audio_path** (string) - The path to the generated audio file. - **duration** (number) - The duration of the audio in seconds. - **seed** (integer) - The seed used for generation. - **created_at** (string) - The timestamp when the generation was created (ISO 8601 format). - **total** (integer) - The total number of generation history items available. #### Error Response (422) - **detail** (array) - A list of validation errors. - **loc** (array) - The location of the error in the request. - **msg** (string) - The error message. - **type** (string) - The type of error. ### Request Example ```json { "items": [ { "id": "string", "profile_id": "string", "profile_name": "string", "text": "string", "language": "string", "audio_path": "string", "duration": 0, "seed": 0, "created_at": "2019-08-24T14:15:22Z" } ], "total": 0 } ``` ### Response Example ```json { "detail": [ { "loc": [ "string" ], "msg": "string", "type": "string" } ] } ``` ``` -------------------------------- ### Update Profile Response Schemas Source: https://docs.voicebox.sh/api-reference/profiles/update_profile_profiles__profile_id__put Defines the JSON structure for successful profile updates (200 OK) and validation error responses (422 Unprocessable Entity). ```json { "id": "string", "name": "string", "description": "string", "language": "string", "created_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z" } ``` ```json { "detail": [ { "loc": [ "string" ], "msg": "string", "type": "string" } ] } ``` -------------------------------- ### Delete Generation by ID (Java) Source: https://docs.voicebox.sh/api-reference/history/delete_generation_history__generation_id__delete Illustrates deleting a generation by its ID in Java using the `HttpClient`. This code snippet sends a DELETE request and handles potential errors, returning the response body or null if an error occurs. ```java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.io.IOException; public class VoiceboxClient { public static String deleteGeneration(String generationId) { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("http://localhost:8000/history/" + generationId)) .DELETE() .build(); try { HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() == 200) { return response.body(); } else { System.err.println("Error deleting generation: " + response.statusCode()); System.err.println(response.body()); return null; } } catch (IOException | InterruptedException e) { e.printStackTrace(); return null; } } } ``` -------------------------------- ### Update Voice Profile via API Source: https://docs.voicebox.sh/api-reference/profiles/update_profile_profiles__profile_id__put Updates an existing voice profile by its unique identifier. The request requires a JSON body containing the profile name, with optional fields for description and language. ```bash curl -X PUT "http://localhost:8000/profiles/string" \ -H "Content-Type: application/json" \ -d '{ "name": "string" }' ``` -------------------------------- ### List Voice Profiles via Voicebox API Source: https://docs.voicebox.sh/api-reference/profiles/list_profiles_profiles_get Retrieves a list of all available voice profiles from the server. The endpoint returns a 200 OK status with a JSON array containing profile details such as ID, name, and timestamps. ```bash curl -X GET "http://localhost:8000/profiles" ``` -------------------------------- ### Delete Generation by ID (JavaScript) Source: https://docs.voicebox.sh/api-reference/history/delete_generation_history__generation_id__delete Demonstrates how to delete a generation by its ID using JavaScript. This involves making a DELETE request to the /history/{generation_id} endpoint. Ensure the generation_id is correctly formatted. ```javascript async function deleteGeneration(generationId) { const response = await fetch(`http://localhost:8000/history/${generationId}`, { method: 'DELETE' }); if (!response.ok) { const errorData = await response.json(); console.error('Error deleting generation:', errorData); return null; } return await response.json(); } ``` -------------------------------- ### List Generation History via Voicebox API Source: https://docs.voicebox.sh/api-reference/history/list_history_history_get Retrieves a paginated list of generation history records. Supports filtering by profile ID and search terms, returning a JSON object containing a list of items and the total count. ```bash curl -X GET "http://localhost:8000/history" ``` -------------------------------- ### DELETE /profiles/samples/{sample_id} Source: https://docs.voicebox.sh/api-reference/profiles/delete_profile_sample_profiles_samples__sample_id__delete Deletes a specific voice profile sample by its unique identifier. ```APIDOC ## DELETE /profiles/samples/{sample_id} ### Description Delete a specific sample associated with a voice profile. ### Method DELETE ### Endpoint http://localhost:8000/profiles/samples/{sample_id} ### Parameters #### Path Parameters - **sample_id** (string) - Required - The unique identifier of the sample to delete. ### Response #### Success Response (200) - **null** (null) - Successful deletion. #### Error Response (422) - **detail** (array) - Validation error details. ### Response Example ```json { "detail": [ { "loc": ["string"], "msg": "string", "type": "string" } ] } ``` ```