Introduction
HearJabber API provides TTS (Text-to-Speech) services to convert text data to audio files and STT (Speech-to-Text) services to convert audio files to text data. While the TTS API allows users to convert the text they specify into an audio file, the STT API allows users to convert audio files into text data.
Login Request
This endpoint allows users to log in to the system. A login request is sent with the user's email address and password, and a token is received upon successful login.
Endpoint
Method: POST
Base URL: https://www.hearjabber.com
Query URL: /api/v1/login
Body Parameters
- email ( string, required ): User Email Address
- password (string, required): User Password
Sample Codes
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())
Sample Response (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:
It represents the letters that the user has loaded and can use as balance. This balance is deducted when the user uses the text-to-speech (TTS) service.
available_minutes:
It represents the valid minutes that the user has loaded as a balance. This is deducted from the balance when the user uses the voice-to-text (STT) service.
Voiceover Languages
It lists the languages and some fields in json format that you can send as parameters when using our text-to-speech (TTS) service.
Endpoint
Method: GET
Base URL: https://www.hearjabber.com
Query URL: /api/v1/voiceover-languages
Sample Response (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"
},
.
.
.
Sample Codes
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));
Transcript Languages
It lists the languages and some fields in json format that you can send as parameters when using our voice-to-text (STT) service.
Endpoint
Method: GET
Base URL: https://www.hearjabber.com
Query URL: /api/v1/transcript-languages
Sample Response (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"
},
.
.
.
Sample Codes
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 Parameters
- audio ( required ): Audio file with wav, mp3, ogg extension
- language (string, required): Language Code
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: Example to import audio file
<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)
Sample Response (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 Parameters
- text ( required ): Text to be spoken
- language (string, required): Language Code
- extension (string,required): Sound file extension
Sample Request
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)
Sample Response (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"
}
Sample Codes General Use
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();