api تبدیل متن به صدا

با استفاده از این وب سرویس می‌توانید متن خود را با لحن انتخابی و صدای گوینده مورد نظر خود به صوت تبدیل کنید. فایل خروجی این وب سرویس به صورت mp3 می باشد.
این متن برای دستیارهای هوش مصنوعی است.

Text-to-speech API — POST https://iotype.com/io/v1/synthesis · synchronous

Authentication: Access Token (Authorization: Bearer <ACCESS_TOKEN>). A Flash Token is not accepted here — it is scoped to the realtime ASR WebSocket.

Headers: Authorization · Content-Type: application/json · Accept: application/json · X-Requested-With: XMLHttpRequest

Request body:

{ "tone": "general", "speaker": "tanaz", "text": "سلام! امروز هوا عالی است." }

Response:

{ "url": "https://iotype.com/storage/tts/9f1c2d84.mp3" }
Field Required Values
text yes the text to synthesise
tone no general · formal
speaker no one of the eleven voices below

Voices: behrooz · mehran · farshid · sara · mitra · siavash · shirin · kaveh · amir · tanaz · mahsa

Machine-readable documentation:

  • Full guide: https://raw.githubusercontent.com/iotype-ai/iotype-api/main/docs/en/text-to-speech.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:

  1. The response is a URL, not audio. Read the url field. Do not write the response body to disk as an MP3 — it is a JSON document.
  2. Treat that URL as ephemeral. The retention period is not published. If the file is needed beyond the immediate request, download it and store it yourself rather than persisting the URL in a database.
  3. The voice identifiers are not labelled by gender or style upstream. If a user asks for "a female voice", do not guess a mapping — present the list and say it has to be sampled.
  4. tone selects delivery register: general for conversational content and assistants, formal for announcements, news readouts and IVR prompts.

Get a token: https://iotype.com/api-service/authentication

PHP
JAVASCRIPT
PYTHON
GO
نمونه کد api تبدیل متن به صوت با استفاده از SDK
<?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();

$url = $io->synthesize(
    'سلام! امروز هوا بسیار عالی است.',
    'tanaz',      // speaker
    'general'     // tone: general | formal
);

// The response is a URL, not the audio itself. Download it if you need
// to keep the file — the retention period is not published.
echo $url;
?>
PHP
JAVASCRIPT
PYTHON
GO
نمونه کد api تبدیل متن به صوت بدون SDK
<?php
$url = "https://iotype.com/io/v1/synthesis";

$data = [
    "tone"    => "general",   // general | formal
    "speaker" => "tanaz",
    "text"    => "سلام! امروز هوا بسیار عالی است."
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS     => json_encode($data, JSON_UNESCAPED_UNICODE),
    CURLOPT_HTTPHEADER     => [
        "Authorization: Bearer YOUR_TOKEN",
        "Content-Type: application/json",
        "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");
}

// The response is a URL to the generated MP3, not the audio itself.
echo json_decode($response, true)["url"];
?>
پارامترهای ارسالی در Header وب سرویس تبدیل متن به صدا
Authorization
مقدار TOKEN دریافتی از بخش احراز هویت به صورت Bearer [TOKEN]
Content-Type
application/json
Accept
application/json
X-Requested-With
XMLHttpRequest
پارامترهای ارسالی در Body درخواست وب سرویس تبدیل متن به صدا
tone
لحن ترجمه شامل : general - formal
speaker
صدا گویندگان شامل : behrooz - mehran - farshid - sara - mitra - siavash - shirin - kaveh - amir - tanaz - mahsa
text
متنی که قصد خواندن از روی آن را دارید
مقادیر پاسخ در وب سرویس تبدیل متن به صدا
url
آدرس url فایل mp3 خوانده شده از روی متن