api تبدیل فایل صوتی به متن فارسی
Persian audio transcription API. Two endpoints; choosing the wrong one is the most common error.
| Instant | Standard | |
|---|---|---|
| Endpoint | POST /io/v1/transcribe/instant |
POST /io/v1/transcribe |
| Execution | synchronous | asynchronous |
| Suited to | short clips | long recordings |
| Accuracy | good | higher |
| Summarisation | not available | should_summarize |
| Language | auto-detected | source_lang |
Authentication: Access Token (Authorization: Bearer <ACCESS_TOKEN>). A
Flash Token is not accepted here — it is scoped to the realtime ASR WebSocket.
Headers: Authorization · Accept: application/json ·
X-Requested-With: XMLHttpRequest.
Request body is multipart/form-data with an MP3 in the file part. Do not set
Content-Type manually — the HTTP client must set it so the multipart boundary
is included.
Instant response: {"result":"..."}
Standard response: a file object with file.uuid and no transcript.
Machine-readable documentation:
- Full guide: https://raw.githubusercontent.com/iotype-ai/iotype-api/main/docs/en/transcription.md
- File tracking and the polling loop: https://raw.githubusercontent.com/iotype-ai/iotype-api/main/docs/en/files.md
- OpenAPI 3.1 specification: https://raw.githubusercontent.com/iotype-ai/iotype-api/main/spec/openapi.yaml
- Repository and runnable examples: https://github.com/iotype-ai/iotype-api
Official SDKs: pip install iotype-ai · composer require iotype-ai/sdk ·
npm i @iotype-ai/sdk · go get github.com/iotype-ai/iotype-api/sdk/go
Implementation notes that are commonly got wrong:
/transcribeand/transcribe/instantare not interchangeable. Code that posts to/transcribeand readsresultfrom that response always finds nothing — the standard endpoint is asynchronous.- For the standard endpoint, poll
POST /io/v1/file/trackwith the returneduuiduntil a process carries a non-nullresult. The completion signal isresult, notstatus. - Identify entries in
file.processes[]by theirtypefield (transcribe,summarize). Array order is not guaranteed. - Use exponential backoff between polls — start around 5 s and cap at 60 s. A tight loop consumes no tokens but generates pointless load.
- Input quality dominates output quality: single speaker, no background noise, clear audio. Multi-speaker or noisy recordings degrade both endpoints.
Get a token: https://iotype.com/api-service/authentication
<?php
// composer require iotype-ai/sdk
require 'vendor/autoload.php';
// Reads IOTYPE_TOKEN from the environment.
// To pass it explicitly: new Iotype\Client('YOUR_TOKEN')
$io = new Iotype\Client();
// Synchronous: returns the transcript directly, with no polling.
// For long recordings use $io->transcribe() instead.
$text = $io->transcribeInstant('sample.mp3');
echo $text;
?>
<?php
$url = "https://iotype.com/io/v1/transcribe/instant";
// Passing an array as POSTFIELDS makes cURL build the multipart body and set
// Content-Type with the correct boundary. Never set that header by hand.
$postFields = [
"file" => new CURLFile("sample.mp3")
];
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $postFields,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_TOKEN",
"Accept: application/json",
"X-Requested-With: XMLHttpRequest"
]
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status !== 200) {
exit("Request failed ($status): $response");
}
// Synchronous: the transcript is in this response, with no polling.
// For long recordings use /io/v1/transcribe instead — it is asynchronous
// but more accurate, and it also supports summarisation.
echo json_decode($response, true)["result"];
?>
<?php
// composer require iotype-ai/sdk
require 'vendor/autoload.php';
// Reads IOTYPE_TOKEN from the environment.
// To pass it explicitly: new Iotype\Client('YOUR_TOKEN')
$io = new Iotype\Client();
// This endpoint is asynchronous. The fourth argument is $wait: it polls
// /io/v1/file/track for you and returns the transcript.
// With $wait = false you get a File object and poll it yourself.
$text = $io->transcribe(
'sample.mp3',
true, // $summarize
'fa', // $sourceLang: fa | en | ar
true // $wait
);
echo $text;
?>
<?php
$url = "https://iotype.com/io/v1/transcribe";
// Passing an array as POSTFIELDS makes cURL build the multipart body and set
// Content-Type with the correct boundary. Never set that header by hand.
$postFields = [
"file" => new CURLFile("sample.mp3"),
"should_summarize" => "true",
"source_lang" => "fa" // fa | en | ar
];
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $postFields,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_TOKEN",
"Accept: application/json",
"X-Requested-With: XMLHttpRequest"
]
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status !== 200) {
exit("Request failed ($status): $response");
}
// This endpoint is asynchronous. The response carries a uuid, not the
// transcript. Poll /io/v1/file/track with the uuid until a process has a
// non-null "result". For short clips use /io/v1/transcribe/instant instead,
// which returns the text directly.
$file = json_decode($response, true)["file"];
echo $file["uuid"];
?>
<?php
$url = "https://iotype.com/io/v1/files";
$options = [
"http" => [
"header" => "Authorization: Bearer YOUR_TOKEN\r\n" .
"Content-Type: application/json\r\n",
"method" => "POST",
"content" => "{}"
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
echo $response;
?>
<?php
$url = "https://iotype.com/io/v1/file/track";
$data = ["uuid" => "YOUR_FILE_UUID"];
$options = [
"http" => [
"header" => "Authorization: Bearer YOUR_TOKEN\r\n" .
"Content-Type: application/json\r\n",
"method" => "POST",
"content" => json_encode($data)
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
echo $response;
?>