Orator is our specialized TTS API that delivers natural-sounding voice synthesis for Pakistani languages. It handles native pronunciation, mixed language text, and cultural nuances that generic TTS services miss.
Once you have your API key, you can make your first text-to-speech request. Here’s a simple example using JavaScript:
Copy
async function convertTextToSpeech() { try { const response = await fetch('https://api.upliftai.org/v1/synthesis/text-to-speech', { method: 'POST', headers: { 'Authorization': 'Bearer sk_api_your_key_here', 'Content-Type': 'application/json' }, body: JSON.stringify({ "voiceId": "v_8eelc901", // See available voice Ids in the documentation below "text": "سلام، آپ اِس وقت اوریٹر کی آواز سن رہے ہیں۔", // => "Salaam, Aap ise waqt Orator ki awaaz suun rahay hain." "outputFormat": "MP3_22050_128" }) }); // Get audio duration from headers const audioDuration = response.headers.get('x-uplift-ai-audio-duration'); console.log(`Audio duration: ${audioDuration}ms`); // The response body is an audio blob, you can save this or send it to your frontend to be played const audioBlob = await response.blob(); } catch (error) { console.error('Error:', error); }}// Call the functionconvertTextToSpeech();
Brand names: Convert English spellings to Urdu phonetics
Technical terms: Ensure consistent pronunciation
LLM outputs: Fix common misspellings from AI models
Regional variations: Adapt to local dialects
For example:
Copy
[ {"phrase":"سیونگز اکاؤنٹ","replacement":"savings account"}, // In Urdu Isabion is pronunced Izabiyan, but LLMs don't understand this {"phrase":"Isabion","replacement":"ایزابیان"}, // Sometimes the English spellings of brand names don't capture Urdu pronunciation {"phrase": "Meezan bank", "replacement": "میزان بینک"}]
Here is how you can create a replacement configuration:
Copy
// Create a phrase replacement configurationasync function createPhraseReplacements() { try { const response = await fetch('https://api.upliftai.org/v1/synthesis/phrase-replacement-config', { method: 'POST', headers: { 'Authorization': 'Bearer sk_api_your_key_here', 'Content-Type': 'application/json' }, body: JSON.stringify({ "phraseReplacements": [ { "phrase": "سیونگز اکاؤنٹ", "replacement": "Savings account", }, { "phrase": "Meezan bank", "replacement": "میزان بینک" } ] }) }); const data = await response.json(); console.log('Configuration created with ID:', data.configId); return data.configId; // save this configId for later reuse } catch (error) { console.error('Error creating phrase replacements:', error); }}// Use the configuration ID in your text-to-speech requestasync function ttsWithPhraseReplacement(configId) { // Similar to the first example, but add phraseReplacementConfigId const requestBody = { "voiceId": "v_8eelc901", "text": "Meezan Bank اعتماد کا ضامن", "outputFormat": "MP3_22050_128", "phraseReplacementConfigId": configId }; // Make API request as shown in the first example}
Each voice is optimized for specific use cases and audiences:Info/Education: voiceId: "v_8eelc901"Listen to articles, information, and videos. Fast and easy to understand.Nostalgic News: voiceId: "v_30s70t3a"A classic Pakistani news voice that we heard growing up. We bring those memories back. Stay calm, stay tuned.Dada Jee: voiceId: "v_yypgzenx"Listen to stories with a suspensful and deep voice.Gen Z (under development): voiceId: "v_kwmp7zxt"If you want your info clean and fast, this voice is for you.For more voices and langauges check this voices page