Speech
(llm.speech)
Overview
Available Operations
- transcribe - Speech to text transcription
- textToSpeech - Text to speech (Urdu)
transcribe
Convert audio to text using advanced speech recognition.
Upload Methods:
Complete File Upload (Standard)
- Use
Content-Type: multipart/form-data - Upload the complete audio file in one request
- Maximum file size: 25MB
- Example (curl):
bashcurl -X POST "http://localhost:3000/api/v1/llm/speech/transcriptions?language=en" \ -F "file=@audio.flac"- Use
Chunked Upload (Streaming)
- Use
Transfer-Encoding: chunkedheader - Stream audio data in chunks as it's being recorded
- No need to know total file size upfront
- Server buffers chunks until complete before processing
- Maximum total size: 25MB
- Example (curl):
bashcurl -X POST "http://localhost:3000/api/v1/llm/speech/transcriptions?language=en" \ -H "Transfer-Encoding: chunked" \ -H "Content-Type: multipart/form-data" \ --data-binary @audio.flac- Use
Supported Formats: FLAC, MP3, MP4, MPEG, MPGA, M4A, OGG, WAV, WebM
Query Parameters:
language(optional): ISO-639-1 language code (e.g., "en", "es", "fr"). Auto-detects if not specified.prompt(optional): Text to guide transcription styletemperature(optional): Sampling temperature 0-1 (higher = more random)
Response: Returns transcribed text in JSON format.
Example Usage
import { SDK } from "@meetkai/mka1";
import { openAsBlob } from "node:fs";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.speech.transcribe({
requestBody: {
file: await openAsBlob("example.file"),
},
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmSpeechTranscribe } from "@meetkai/mka1/funcs/llmSpeechTranscribe.js";
import { openAsBlob } from "node:fs";
// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await llmSpeechTranscribe(sdk, {
requestBody: {
file: await openAsBlob("example.file"),
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmSpeechTranscribe failed:", res.error);
}
}
run();React hooks and utilities
This method can be used in React components through the following hooks and associated utilities.
Check out this guide for information about each of the utilities below and how to get started using React hooks.
import {
// Mutation hook for triggering the API call.
useLlmSpeechTranscribeMutation
} from "@meetkai/mka1/react-query/llmSpeechTranscribe.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.TranscribeRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries | RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.TranscribeResponseBody>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
textToSpeech
Convert Urdu text to speech using the MK TTS service.
Request Body:
text: Input text in Urdu (Arabic script) - requiredspeaking_rate: Speech speed multiplier (default: 1.0, higher = faster, lower = slower)noise_scale: Prosody/expressiveness variation (default: 0.667, 0.0 = monotone, higher = more varied)noise_scale_duration: Timing/rhythm variation (default: 0.8)
Response: Returns audio file in WAV format
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.speech.textToSpeech({
text: "<value>",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmSpeechTextToSpeech } from "@meetkai/mka1/funcs/llmSpeechTextToSpeech.js";
// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await llmSpeechTextToSpeech(sdk, {
text: "<value>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmSpeechTextToSpeech failed:", res.error);
}
}
run();React hooks and utilities
This method can be used in React components through the following hooks and associated utilities.
Check out this guide for information about each of the utilities below and how to get started using React hooks.
import {
// Mutation hook for triggering the API call.
useLlmSpeechTextToSpeechMutation
} from "@meetkai/mka1/react-query/llmSpeechTextToSpeech.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.TextToSpeechRequestBody | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries | RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<ReadableStream<Uint8Array>>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |