Giriş
HearJabber API, metin verilerini ses dosyalarına dönüştürmek için TTS (Text-to-Speech) ve ses dosyalarını metin verilerine dönüştürmek için STT (Speech-to-Text) hizmetleri sunar. TTS API, kullanıcıların belirledikleri metni ses dosyasına dönüştürmelerine olanak tanırken, STT API, kullanıcıların ses dosyalarını metin verisine çevirmelerini sağlar.
Giriş Yap İsteği
Bu endpoint, kullanıcıların sistemde oturum açmalarını sağlar. Kullanıcı e-posta adresi ve şifresi ile oturum açma isteği gönderilir ve başarılı bir oturum açma işlemi sonucunda bir token alınır.
Endpoint
Method: POST
Base URL: https://www.hearjabber.com
Query URL: /api/v1/login
Body Parametreleri
- email ( string, required ): Kullanıcı e-posta adresi
- password (string, required): Kullanıcı şifresi
Örnek Kodlar
POST /api/v1/login HTTP/1.1
Host: www.hearjabber.com
Content-Type: application/x-www-form-urlencoded
[email protected]&password=123456
Python
import requests
base_url="https://www.hearjabber.com"
url = base_url + "/api/v1/login"
payload = {'email': '[email protected]', 'password': '123456789'}
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
response = requests.post(url, headers=headers, data=payload)
print(response.json())
Örnek Cevap (JSON)
{
"token":"Token",
"expries_at":"TOKEN EXPRIES DATE"
"user": {
"id": USER ID,
"name": "USER NAME",
"job_role": "USER ROLE",
"email": "USER MAIL",
"company": "USER COMPANY NAME"
"website": "USER WEBSİTE "
"phone_number": "USER PHONE NUMBER",
"address": "USER ADDRESS",
"city": "USER CİTY",
"postal_code": "USER POSTAL CODE",
"country": "USER COUNTRY,
"available_chars": "USER AVAİLABLE CHARS",
"language": "USER DEFAULT LANGUAGE",
"project": "USER DEFAULT PROJECT NAME",
"available_minutes": "148.698",
"profile_photo_path": null,
}
available_chars:
Kullanıcının bakiye olarak yüklediği ve kullanabileceği harfleri temsil eder. Kullanıcı metinden sese (TTS) hizmetini kullanırken bu bakiyeden azalır.
available_minutes:
Kullanıcının bakiye olarak yüklediği geçerli dakikaları temsil eder. Kullanıcı sesten metine (STT) hizmetini kullanırken bu bakiyeden düşürülür.
Seslendirme Dilleri
Metinden sese(TTS) servimizi kullanırken parametre olarak gönderebileceğiniz dilleri ve bazı alanları json formatında listeler.
Endpoint
Method: GET
Base URL: https://www.hearjabber.com
Query URL: /api/v1/voiceover-languages
Örnek Cevap (JSON)
{
"language": "Language Name",
"api_language_code": "Language Code",
"language_flag": "Language Flag Source"
},
{
"language": "English",
"api_language_code": "en",
"language_flag": "https://www.hearjabber.com/img/flags/en.svg"
},
.
.
.
Örnek Kodlar
Python
import requests
base_url="https://www.hearjabber.com"
url =base_url + "/api/v1/voiceover-languages"
response = requests.get(url)
print(response.json())
Javascript
const baseUrl = "https://www.hearjabber.com";
const url = baseUrl + "/api/v1/voiceover-languages";
fetch(url)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
PHP
$url = 'https://www.hearjabber.com/api/v1/voiceover-languages';
$options = [
'http' => [
'method' => 'GET',
'header' => 'Content-Type: application/json'
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
var_dump(json_decode($response));
Transkript Dilleri
Sesten metine (STT) servimizi kullanırken parametre olarak gönderebileceğiniz dilleri ve bazı alanları json formatında listeler.
Endpoint
Method: GET
Base URL: https://www.hearjabber.com
Query URL: /api/v1/transcript-languages
Örnek Cevap (JSON)
{
"language": "Language Name",
"api_language_code": "Language Code",
"language_flag": "Language Flag Source"
},
{
"language": "English",
"api_language_code": "en",
"language_flag": "https://www.hearjabber.com/img/flags/en.svg"
},
.
.
.
Örnek Kodlar
Python
import requests
base_url="https://www.hearjabber.com"
url =base_url + "/api/v1/transcript-languages"
response = requests.get(url)
print(response.json())
Javascript
const baseUrl = "https://www.hearjabber.com";
const url = baseUrl + "/api/v1/transcript-languages";
fetch(url)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
PHP
$url = 'https://www.hearjabber.com/api/v1/transcript-languages';
$options = [
'http' => [
'method' => 'GET',
'header' => 'Content-Type: application/json'
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
var_dump(json_decode($response));
STT API
Endpoint
Method: POST
Base URL: https://www.hearjabber.com
Query URL: /api/v1/stt
Authorization - Bearer Token: Token <token>
Body Parametreleri
- audio ( required ): wav,mp3,ogg uzantılı ses dosyası
- language (string, required): Dil kodu
Method: POST
Base URL: https://www.hearjabber.com
Query URL: /api/v1/stt
Javascript
const baseUrl = "https://www.hearjabber.com";
const url = baseUrl + "/api/v1/stt";
const token = "YOUR_BEARER_TOKEN"; // Token write here
function handleFileChange(event) {
const audioFile = event.target.files[0];
const language = 'tr';
const formData = new FormData();
formData.append('audio', audioFile);
formData.append('language', language);
fetch(url, {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`
},
body: formData
})
.then(response => response.json())
.then(data => {
console.log("Transcription:", data);
})
.catch(error => console.error(error));
}
HTML: Ses dosyasını almak için örnek
<input type="file" id="audioInput" accept="audio/*" onchange="handleFileChange(event)">
PHP
$baseUrl = "https://www.hearjabber.com";
$url = $baseUrl . "/api/v1/stt";
$token = "YOUR_BEARER_TOKEN"; // Token write here
function transcribeAudio($audioFile) {
global $url, $token;
$language = 'tr';
$formData = new FormData();
$formData->append('audio', $audioFile);
$formData->append('language', $language);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $formData);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
echo "Transcription: " . $data;
}
$audioFile = $_FILES['audio'];
transcribeAudio($audioFile);
Python
import requests
baseUrl = "https://www.hearjabber.com"
url = baseUrl + "/api/v1/stt"
token = "YOUR_BEARER_TOKEN" # Token write here
def transcribe_audio(audioFile):
language = 'en'
formData = {
'audio': audioFile,
'language': language
}
headers = {
'Authorization': f'Bearer {token}'
}
response = requests.post(url, files=formData, headers=headers)
data = response.json()
print("Transcription:", data)
audioFile = {'audio': open('audio_file.mp3', 'rb')}
transcribe_audio(audioFile)
Örnek Cevap (JSON)
{
"text": "RESULT TEXT",
"remaining_minutes": "USER REMAINING MINUTES"
}
TTS API
Endpoint
Method: POST
Base URL: https://www.hearjabber.com
Query URL: /api/v1/tts
Authorization - Bearer Token: Token <token>
Body Parametreleri
- text ( required ): Seslendirilecek metin
- language (string, required): Dil kodu
- extension (string,required): Ses dosyası uzantısı
Örnek İstek
Javascript
const baseUrl = "https://www.hearjabber.com";
const url = baseUrl + "/api/v1/tts";
const token = "YOUR_BEARER_TOKEN"; // Token write here
function textToSpeech(text, language, extension) {
fetch(url, {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: text,
language: language,
extension: extension
})
})
.then(response => response.json())
.then(data => {
console.log("File URL:", data.file);
console.log("Remaining Characters:", data.remaining_chars);
console.log("Available at:", data.available_at);
})
.catch(error => console.error(error));
}
const text = "Test text";
const language = "tr";
const extension = "wav";
textToSpeech(text, language, extension);
Python
import requests
baseUrl = "https://www.hearjabber.com"
url = baseUrl + "/api/v1/tts"
token = "YOUR_BEARER_TOKEN" # Token write here
def text_to_speech(text, language, extension):
formData = {
'text': text,
'language': language,
'extension': extension
}
headers = {
'Authorization': f'Bearer {token}'
}
response = requests.post(url, data=formData, headers=headers)
data = response.json()
print("File URL:", data['file'])
print("Remaining Characters:", data['remaining_chars'])
print("Available at:", data['available_at'])
text = "Test text"
language = "tr"
extension = "wav"
text_to_speech(text, language, extension)
Örnek Cevap (JSON)
{
"file":"FILE URL",
"remaining_chars": "REMAİNİNG CHARS",
"avaliable_at": "The Period of Validity",
}
{
"file": "https://www.hearjabber.com/audios/api/tts/example.wav",
"remaining_chars": "175011",
"avaliable_at": "2024-05-29T08:39:13.891275Z"
}
Örnek Kodlar Genel Kullanım
Javascript
const baseUrl = "https://www.hearjabber.com";
const languagesUrl = baseUrl + "/api/v1/voiceover-languages";
const loginUrl = baseUrl + "/api/v1/login";
const sttUrl = baseUrl + "/api/v1/stt";
const email = "[email protected]";
const password = "your_password";
let selectedLanguage = "tr";
function getLanguagesAndHandleFileUpload() {
fetch(languagesUrl, {
method: 'GET'
})
.then(response => response.json())
.then(data => {
console.log("Languages:", data);
showLanguageOptions(data);
})
.catch(error => console.error(error));
}
function showLanguageOptions(languages) {
const languageSelect = document.getElementById('languageSelect');
languages.forEach(language => {
const option = document.createElement('option');
option.value = language.code;
option.textContent = language.name;
languageSelect.appendChild(option);
});
}
function handleLanguageSelect() {
selectedLanguage = document.getElementById('languageSelect').value;
}
fetch(loginUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: `email=${email}&password=${password}`
})
.then(response => response.json())
.then(data => {
getLanguagesAndHandleFileUpload();
})
.catch(error => console.error(error));
function handleFileUpload() {
const audioFile = document.getElementById('audioInput').files[0];
const formData = new FormData();
formData.append('audio', audioFile);
formData.append('language', selectedLanguage);
fetch(sttUrl, {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`
},
body: formData
})
.then(response => response.json())
.then(data => {
console.log("Transcription:", data);
})
.catch(error => console.error(error));
}
Python
import requests
baseUrl = "https://www.hearjabber.com"
languagesUrl = baseUrl + "/api/v1/voiceover-languages"
loginUrl = baseUrl + "/api/v1/login"
sttUrl = baseUrl + "/api/v1/stt"
email = "[email protected]"
password = "your_password"
selectedLanguage = "tr"
token = ""
def get_languages_and_handle_file_upload():
response = requests.get(languagesUrl)
languages = response.json()
print("Languages:", languages)
show_language_options(languages)
def show_language_options(languages):
languageSelect = input("Select a language:\n")
for language in languages:
print(language["name"] + " - " + language["code"])
def handle_language_select():
selectedLanguage = input("Enter the language code:\n")
login_data = {
'email': email,
'password': password
}
response = requests.post(loginUrl, data=login_data)
token = response.json()["token"]
get_languages_and_handle_file_upload()
def handle_file_upload():
audioFile = {'audio': open('audio_file.mp3', 'rb')}
formData = {
'audio': audioFile,
'language': selectedLanguage
}
headers = {
'Authorization': f'Bearer {token}'
}
response = requests.post(sttUrl, files=formData, headers=headers)
data = response.json()
print("Transcription:", data)
handle_file_upload()
PHP
$baseUrl = "https://www.hearjabber.com";
$languagesUrl = $baseUrl . "/api/v1/voiceover-languages";
$loginUrl = $baseUrl . "/api/v1/login";
$sttUrl = $baseUrl . "/api/v1/stt";
$email = "[email protected]";
$password = "your_password";
$selectedLanguage = "tr";
$token = "";
function getLanguagesAndHandleFileUpload() {
global $languagesUrl, $selectedLanguage;
$response = file_get_contents($languagesUrl);
$languages = json_decode($response, true);
echo "Languages:\n";
foreach ($languages as $language) {
echo $language['name'] . " - " . $language['code'] . "\n";
}
}
function handleFileUpload() {
global $sttUrl, $selectedLanguage, $token;
$audioFile = $_FILES['audio'];
$formData = array(
'audio' => $audioFile,
'language' => $selectedLanguage
);
$headers = array(
'Authorization: Bearer ' . $token
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $sttUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $formData);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
echo "Transcription:\n";
print_r($data);
}
// Login
$loginData = array(
'email' => $email,
'password' => $password
);
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($loginData)
)
);
$context = stream_context_create($options);
$response = file_get_contents($loginUrl, false, $context);
$token = json_decode($response, true)['token'];
handleFileUpload();