# API Credits, Limits and Analytics Source: https://docs.reverieinc.com/analytics Reverie offers a free tier to help developers explore Speech and Text APIs with flexible access, and provides detailed usage analytics to monitor and optimize API consumption. ### Free Tier (1 Year Expiry) Upon signing up, every developer account receives: * **5 hours of free Speech-to-Text (Streaming)** usage * **5 hours of free Speech-to-Text (File)** usage * **10,000 characters of free Text-to-Speech (TTS)** generation * **10,000 characters of free Translation** usage * **10,000 characters of free Transliteration** usage These free credits help you prototype and evaluate Reverie’s core speech capabilities before moving to a paid plan. ### Need More Credits? Once your free quota is used, you can easily upgrade: 1. Visit the [**Pricing Page**](https://revup.reverieinc.com/pricing?utm_source=documentation\&utm_medium=website\&utm_campaign=revup_signup) on RevUp 2. Choose a suitable usage tier 3. Submit the form with your details 4. Our team will get in touch, activate your preferred plan, and provide additional credits Enterprise users can also request volume-based pricing or custom SLAs through this form. ### Rate Limits * **Concurrency limit (free tier)**: Up to 5 concurrent API connections/sessions. * Contact us for enterprise-scale limits or guaranteed throughput ### Monitor Your API Usage The **RevUp Dashboard** offers real-time analytics to help you stay in control of your API consumption. Here’s what you can track: * **Credits Usage**: View how much of your free or purchased credits have been consumed. * **Remaining Quota**: Monitor your remaining Speech and Text APIs usage at a glance. * **Detailed Usage Logs**: * View API-wise breakdown * Analyze daily, weekly, or monthly usage trends # Translation API Source: https://docs.reverieinc.com/api-reference/localization Translation is the REST API developed for localizing the contents from English to Indic languages. Using the Translation API, you can either localize a single sentence or multiple sentences in a fraction of time. # How Does API Work? The Translation API will use the App Id and API key to authenticate requests. Your credentials carry many privileges, so be sure to keep them secure. * **Post the request by:** * Enter the valid `REV-APPNAME`, `REV-APP-ID`, and `REV-API-KEY`. * Specify the Source language & Target language(s) code. * Enter the content you want to localize and mention the domain. * **On posting the request:** * The API will validate user credentials. * Validate the key-value pairs in the API request. * If all the information is valid, then initially, the API will refer to the Database (Lookup DB & Template DB) to localize the content. * If the content is not available in the Database, then the NMT (Neural Machine Translation) technology is adapted. * **On successfully translating the content:** * The API returns the content in the requested target language(s). ## cURL for Integration ### Translate content to one target language #### Request ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ], "nmtMask": true, "nmtMaskTerms": { "Reverie Language Technologies":"Reverie Language Technologies" }, "enableNmt": true, "enableLookup": true }' ``` #### Response ```json theme={null} { "responseList": [ { "inString": "Reverie Language Technologies was established in 2009.", "outString": "Reverie Language Technologies की स्थापना 2009 में की गई थी।", "apiStatus": 3 }, { "inString": "The company head office is located in Bengaluru.", "outString": "कंपनी का मुख्यालय बेंगलुरु में स्थित है।", "apiStatus": 3 } ], "tokenConsumed": 102 } ``` ### Translate content to multiple target languages #### Request ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi,ta' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ], "nmtMask": true, "nmtMaskTerms": { "Reverie Language Technologies":"Reverie Language Technologies" }, "enableNmt": true, "enableLookup": true }' ``` #### Response ```json theme={null} { "responseList": [ { "inString": "Reverie Language Technologies was established in 2009.", "apiStatus": 3, "outStrings": { "hi": "रेवरी लैंग्वेज टेक्नोलॉजीस की स्थापना 2009 में की गई थी।", "ta": "ரெவரி லாங்வேஜ் டெக்னாலஜிஸ் 2009 இல் நிறுவப்பட்டது ." }, "api_statuses": { "hi": 3, "ta": 3 } }, { "inString": "The company head office is located in Bengaluru.", "apiStatus": 3, "outStrings": { "hi": "कंपनी का प्रधान कार्यालय बंगलुरू में स्थित है।", "ta": "நிறுவனத்தின் தலைமை அலுவலகம் பெங்கலூரில் அமைந்துள்ளது ." }, "api_statuses": { "hi": 3, "ta": 3 } } ], "tokenConsumed": 204 } ``` #### Error Response ```json theme={null} { "message": "unauthorized to use this src/tgt language", "status": 403 } ``` ## API References ### HTTP Request URL | URL Elements | Sample URL | | ------------------- | ---------------------------------------------------------------- | | https\://(hostname) | [https://revapi.reverieinc.com/](https://revapi.reverieinc.com/) | ### Headers {" "} The format of the data to be posted: `application/json` {" "} A unique key/token provided by Reverie to identify the user using the Translation API. {" "} The unique account ID to identify the user and the default account settings. {" "} The parameter to identify the API : `localization` {" "} * The version refers to the specific iteration of the API that is being called. * Note: The default version is **2.0**. {" "} * The language of the input text * Example : `or`, `hi`, `bn` * Refer to section [Language Codes](/usage-guides/localization/supported-languages) for valid language code. {" "} * Language to which you want to localize the input text * Note: To enter multiple target languages, separate the value using the comma separator(,). For example: `tgt_lang` : `hi, ta` * Example : `or`, `hi`, `bn` * Refer to section [Language Codes](/usage-guides/localization/supported-languages) for valid language code. {" "} * The Domain refers to the universe in which you use the Translation API. Example- Health Care, Insurance, Legal, etc. * Refer to section [Domain Codes](/usage-guides/localization/supported-domains) for valid language code. ### Request {" "} * List of input text for Translation. {" "} * Specify whether the content Translation process should use NMT technology or not. * For Example, When the enableNmt value is true, the system will initially refer to the Lookup database to localize content. If the content is not available in the database, then the NMT is used for translation. * **Note** - By default, the `enableNmt`= `true` {" "} * Specify whether the content Translation process should use transliteration technology or not. * For Example, When the enableTransliteration value is true, the system will initially refer to the Lookup database to localize content. If the content is not available in the database, then nmt is used for translation. If nmt fails, transliteration is called. * **Note** - By default, the `enableTransliteration`= `true` {" "} * The parameter will specify whether the application should refer to the Lookup DB or not. * For Example, when the enableLookup is true, the system will initially refer to the Database to fetch contents. * **Note** - By default, the `enableLookup`= `true` {" "} * The feature to screen the non-dictionary words used in a sentence. In other words, the mask will indicate the words that should not be translated into the target language. * **Note** - By default, the `enableLookup`= `true` * **Note** - To set the `nmtMask` = `true`, it is mandatory the `src_lang` = `en` (English). * Determines the words that are to be masked. * **Note** - On defining values in the `nmtMaskTerms`, then automatically the `nmtMask` is set to true. * **Example** - Masking a term:\ `nmtMaskTerms: ["Reverie Language Technologies"]`\ Here, the API will mask the term `Reverie Language Technologies`, if found in the source content, and will transliterate the word. {" "} * Specify whether you want to filter out profane content from the input. * **Note** - By default, the `filterProfane`= `true` ### Response {" "} * The API will return the string(s) in the target language(s). {" "} * The input text in the source language. {" "} * The localized content in the requested target language(s). {" "} * Status of API Moderated / Partial /Unmoderated (Aggregate of all segments). Refer to [API Messages](/api-reference/localization#api-messages) to know about the available apiStatus and its description. {" "} * A dictionary/object with language codes as keys and integer status codes as values. Represents the status of the API output for each language, indicating the moderation level of the response content. Each key is a language code (e.g.,”hi” for Hindi,”ta” for Tamil), and each value is an integer status code representing the moderation level. * **Note**: This `api_statuses` field will be displayed only if multiple languages are requested in the same API payload. * Refer to section [Language Codes](/usage-guides/localization#supported-languages) for valid language code. * Refer to [API Messages](/api-reference/localization#api-messages) to know about the available apiStatus and its description. {" "} * Error status code for the invalid request. * **Note**: The status is shown only for the invalid request. {" "} * A Human-readable error message. * Refer to [API Messages](/api-reference/localization#api-messages) to know about the available apiStatus and its description. {" "} * The payload length served by NMT. * **Note** - if LookUp DB serves the payload and if the content is moderated, then the token`Consumed = `0\` (Zero). {" "} * It is a 128-bit Universally Unique Identifier. It is likely being used for tracking a request in the Translation API. ### Handling Errors The Translation API raises exceptions for many reasons, such as failed conversions, invalid parameters, authentication errors, and network unavailability. It will provide more specific machine-readable messages with an error response so that users can react to errors more effectively. Refer to: [API Messages](/api-reference/localization#api-messages) section to know the error code and corresponding messages. ```json theme={null} { "documentation": "http://beta.revup.reverieinc.com/dashboard/documentation", "message": "Oops! something wrong happened", "error_cause": "Target language is mandatory", "status": "BAD_REQUEST" } ``` ### API Messages | Status Code | Status Type | Status | Description | | ----------- | ----------- | ----------------------------------------- | ------------------------------------------------------------------------ | | 2 | Success | LOOKUP\_MODERATED | API fetched Translation content from the database. | | 3 | Success | MT\_SUCCESS | Source content translated using Neural Machine Translation (NMT). | | 4 | Success | LOOKUP\_UNMODERATED | Localized content in database, but verification status is "unmoderated." | | 5 | Success | LOOKUP\_INPROGRESS | Localized content in database; content moderation in progress. | | 6 | Success | LOOKUP\_PARTIAL | API partially localized a segment from LookUp DB. | | 10 | Success | T13N\_SUCCESS | API fetched content from transliteration. | | -2 | Error | UNLOCALIZED | Requested content is transliterated, not translated. | | -3 | Error | ROSETTA\_ERROR | Error occurred while preprocessing the sentence. | | -4 | Error | MT\_ERROR | Error occurred during NMT translation. | | -5 | Error | MT\_TIME\_OUT | Timeout error while fetching response from NMT Engine. | | -6 | Error | LOCMAN\_ERROR | Error occurred while processing content in LocMan. | | -7 | Error | SEGMENTATION\_API\_ERROR | Error while segmenting the sentence. | | 403 | Error | unauthorized to use this src/tgt language | Invalid or unauthorized language code provided. | | 403 | Error | Invalid REV-API-KEY or REV-APP-ID | Invalid credentials provided. | | 403 | Error | usage exhausted | Provided credit limit is exhausted. | | 403 | Error | API key expired | API key provided has expired. | | 403 | Error | unauthorized to use this API | User is not authorized to use the Translation API. | | 403 | Error | Please provide data string | Data is missing. | | 403 | Error | Target language is mandatory | Target language (tgt\_lang) is missing. | | 403 | Error | Source language is mandatory | Source language (src\_lang) is missing. | # Speech-to-Text (Batch) API Source: https://docs.reverieinc.com/api-reference/speech-to-text-batch The Speech-to-Text API powered by Reverie's AI technology accurately converts speech into text. The solution can transcribe audio files of various Indian languages and audio formats. # How Does API Work? The process to transcribe an audio file: * Post the request by: * Enter the valid `REV-APPNAME`, `REV-APP-ID`, and `REV-API-KEY`. * Define the Language Code and domain. * Upload the audio file to transcribe. * Define the audio format, if required. * The API will return the text in the requested Indian language. ## cURL for Integration ### Step 1 : Upload the Audio File #### Request : Transcribing Audio ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: generic' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_batch' \ --header 'REV-APP-ID: ' \ --header 'subtitles: true' \ --form 'file=@""' ``` #### Request: Transcribing Audio other than Default Format ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: generic' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_batch' \ --header 'REV-APP-ID: ' \ --header 'subtitles: true' \ --form 'file=@""' \ --header 'format=mp3' ``` #### Response: Success ```json theme={null} { "job_id": "e21f356d-cbf9-4d62-a960-1e9da1805d19", "code": "000", "message": "Success. Request accepted" } ``` #### Response: Error Message ```json theme={null} { "job_id": "9b46fa98-d5a6-49d3-96c2-c12c22cf1984", "code": "005", "message": "file is required" } ``` ### Step 2 : Get the Status #### Request: Get status of the transcription ```bash theme={null} curl --location --request GET 'https://revapi.reverieinc.com/status?job_id=' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_batch' \ --header 'REV-APP-ID: ' ``` #### Response: Success ```json theme={null} { "job_id": "e21f356d-cbf9-4d62-a960-1e9da1805d19", "code": "000", "message": "Transcript ready.", "status": "completed" } ``` ### Step 3 : Get the Transcript #### Request: Get transcript of the transcription ```bash theme={null} curl --location --request GET 'https://revapi.reverieinc.com/transcript?job_id=' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_batch' \ --header 'REV-APP-ID: ' ``` #### Response: Success ```json theme={null} { "job_id": "e21f356d-cbf9-4d62-a960-1e9da1805d19", "code": "000", "message": "Transcript ready.", "result": { "transcript": "Hello. Welcome to Reverie.", "original_transcript": "HELLO. WELCOME TO REVERIE.", "channel_number": 1, "words": [ [ { "conf": 0.991683, "end": 0.21, "start": 0.09, "word": "HELLO" }, { "conf": 1.0, "end": 0.6, "start": 0.21, "word": "WELCOME" }, { "conf": 0.99723, "end": 0.72, "start": 0.6, "word": "TO" }, { "conf": 1.0, "end": 1.320315, "start": 0.72, "word": "REVERIE" } ] ], "subtitles": "1\n00:00:00,090 --> 00:00:06,900\nHELLO. WELCOME TO REVERIE.\n\n" } } ``` ## API References ### HTTP Request URL | URL Elements | Sample URL | | ------------------- | ---------------------------------------------------------------------------- | | https\://(hostname) | [https://revapi.reverieinc.com/upload](https://revapi.reverieinc.com/upload) | #### Headers {" "} API key shared by the Reverie team {" "} APP ID shared by the Reverie team {" "} Value if this string should always be `stt_batch` {" "} * Specify the language code.
* Example: `hi`
* Refer to section [Language Codes](/usage-guides/speech-to-text/supported-languages) for valid language code.
{" "} * This field identifies your use case type and set of the terminology defined for transcription.
* e.g. for general audio is ‘generic’
* It is only required for the first API i.e Upload File API.
{" "} * Mention the audio sample rate and file format of the uploaded file.
* Refer to section [Supported Audio Formats](/usage-guides/speech-to-text/supported-audio-formats) for valid audio format code.
* It is only required for the first API i.e Upload File API * Note: * By default, the format = `16k_int16`. (WAV, Signed 16 bit, 16,000 or 16K Hz). * It is an optional parameter.
{" "} * Enables subtitling from the audio file. #### Query Parameter {" "} * An audio file for which the transcript is desired. #### Response {" "} * A unique Identity number auto-assigned by the API for each request, to be used to fetch job status and transcripts. {" "} * Provides a message code which can be used to look up the nature of the response returned by the API. {" "} * Provides a brief description about the response returned by the API. #### Handling Errors Our API raises errors when there is something wrong with certain aspects of the submitted file or any network issues. Some areas where errors might come up would be errors due to network related issues, file formats, incorrect domain names or language codes. Each response code provides a descriptive message about what has gone wrong. #### API Response Message Codes | Code | Message | | ---- | -------------------------------------------------------------------------------------------------------------- | | 000 | Success. Request accepted | | 001 | Language code is required | | 002 | File type not supported. Upload only wav, flac or mp3 formats. Preferred format for transcription is wav files | | 003 | Language and/or Domain not available | | 004 | File type not supported. Upload only wav, flac or mp3 formats. Preferred format for transcription is wav files | | 999 | Unknown error, please contact developer | ### HTTP Status URL | URL Elements | Sample URL | | ------------------- | ------------------------------------------------------ | | https\://(hostname) | `https://revapi.reverieinc.com/status?job_id=` | #### Query Parameter {" "} * `job_id` received after uploading the file. #### Status Query Response {" "} * A unique Identity number auto-assigned by the API for each request {" "} * Provides a message code which can be used to look up the nature of the response returned by the API {" "} * Provides a brief description about the response returned by the API. {" "} * status values: `queued`, `processing`, `failed` and `completed` #### Status Types | Status | Description | | ---------- | ------------------------------------------------------------------------------------------------ | | queued | When the file is successfully validated, the request is queued for processing. | | processing | The transcript generation process is in progress. | | failed | Due to network issues, availability constraints, etc., the request might fail during processing. | | completed | Transcription was successfully completed. | #### API Response Message Codes | Code | Message | | ---- | ---------------------------------------------------------- | | 000 | Transcript ready | | 001 | Invalid JOB ID | | 002 | Invalid JOB ID | | 003 | Your request is in the queue and will be processed shortly | | 004 | Your request is being processed | | 005 | Job failed. Please contact the developers | | 999 | Unknown error | ### HTTP Transcript URL | URL Elements | Sample URL | | ------------------- | ----------------------------------------------------------- | | https\://(hostname) | `https://revapi.reverieinc.com/transcript?job_id= ` | #### Query Parameter {" "} * `job_id` received after uploading the file. #### Transcript Query Response {" "} * A unique Identity number auto-assigned by the API for each request. {" "} * Provides a message code which can be used to look up the nature of the response returned by the API. {" "} * Provides a brief description about the response returned by the API. {" "} * An array of transcript objects including, channel\_number, transcript, list of words with start time, end time and confidence.Please check the sample response. #### API Response Message Codes | Code | Message | | ---- | ---------------------------------------------------------- | | 000 | Transcript ready | | 001 | Invalid JOB ID | | 002 | Invalid JOB ID | | 003 | Your request is in the queue and will be processed shortly | | 004 | Your request is being processed | | 005 | Job failed. Please contact the developers | | 999 | Unknown error | # Speech-to-Text (File) API Source: https://docs.reverieinc.com/api-reference/speech-to-text-file The Speech-to-Text API powered by Reverie's AI technology accurately converts speech into text. The solution can transcribe audio files of various Indian languages and audio formats. # How Does API Work? The process to transcribe an audio file: * Post the request by: * Enter the valid `REV-APPNAME`, `REV-APP-ID`, and `REV-API-KEY`. * Define the Language Code and domain. * Upload the audio file to transcribe. * Define the audio format, if required. * The API will return the text in the requested Indian language. ## cURL for Integration ### Step 1 : Upload the Audio File #### Request : Transcribing Audio ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'src_lang: hi' \ --header 'domain: generic' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_file' \ --header 'REV-APP-ID: ' \ --form 'audio_file=@"" ``` #### Request: Transcribing Audio other than Default Format ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'src_lang: hi' \ --header 'domain: generic' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_file' \ --header 'REV-APP-ID: ' \ --header 'format: mp3' --form 'audio_file=@""' ``` #### Response: Success ```json theme={null} { "id": "ddf4ebda44af4fdf95118af9a6f14d46fce12ed85347471d", "success": true, "final": true, "text": "नाइनटी एट पॉइंट थ्री एफएम पर प्ले करिए", "cause": "EOF received", "confidence": 0.891, "display_text": "98.3 एफएम पर प्ले करिए" } ``` #### Response: Error Message ```json theme={null} { "id": "03e4f260551345e6832bf62ba273e0096fd303e72f94453f", "success": false, "text": "", "final": true, "confidence": 1.0, "cause": "no file given", "display_text": "" } ``` ## API References ### HTTP Request URL | URL Elements | Sample URL | | ------------------- | ---------------------------------------------------------------- | | https\://(hostname) | [https://revapi.reverieinc.com/](https://revapi.reverieinc.com/) | #### Headers {" "} API key shared by the Reverie team {" "} APP ID shared by the Reverie team {" "} Value if this string should always be `stt_file` {" "} * Specify the language code.
* Example: `hi`
* Refer to section [Language Codes](/usage-guides/speech-to-text/supported-languages) for valid language code.
{" "} * This field identifies your use case type and set of the terminology defined for transcription.
* e.g. for general audio is ‘generic’
* It is only required for the first API i.e Upload File API.
{" "} * Mention the audio sample rate and file format of the uploaded file.
* Refer to section [Supported Audio Formats](/usage-guides/speech-to-text/supported-audio-formats) for valid audio format code.
* It is only required for the first API i.e Upload File API * Note: * By default, the format = `16k_int16`. (WAV, Signed 16 bit, 16,000 or 16K Hz). * It is an optional parameter.
#### Query Parameter {" "} * An audio file for which the transcript is desired. #### Response {" "} * A unique Identity number auto-assigned by the API for each request, to be used to fetch job status and transcripts. {" "} * Provides true or false based on the nature of the response returned by the API. {" "} * Provides whether the response is the final response returned by the API. {" "} * Provides the trascripted response returned by the API for the audio file. {" "} * Reason for obtaining the final output, generally due to End Of File (EOF) received. {" "} * Provides the confidence on the scale of 0 - 1 for the output. {" "} * Provides the display text for the final output based on some post processing. # Speech-to-Text (Streaming) API Source: https://docs.reverieinc.com/api-reference/speech-to-text-streaming The Speech-to-Text accurately converts speech into text using an API powered by Reverie's AI technology. The solution will transcribe the speech in real-time of various Indian languages and audio formats. # How Does API Work? * The process to transcribe the continuous audio input: * Open the connection with the STT service by defining `apikey`, `appid`, `appname`, `domain`, `src_lang`. * In the API response, if the `cause = Ready`, then the connection is successfully established. * Write the speech data into the upstream and continuously receive the transcribed data. * **Note**: In the response, if the `final = false`, then the audio is partially transcribed, and the service is still processing the input data. * Write `--EOF--` into the upstream to stop the recognition process. * **Note**: If you fail to write `--EOF--` into the upstream, then the STT service will automatically terminate the recognition process. * Below are the scenarios when the service will auto-terminate the recognition process: * On connection timeout. * After starting recording, if the user maintains silence for more than the defined duration. * In the API response, if the `final = true`, then the text received is considered the final transcript. ## Code Snippets for Integration ### Initiating Speech Service **URL Elements** ```html theme={null} wss://revapi.reverieinc.com/stream?apikey=&appid=&appname=stt_stream&src_lang=hi&domain=generic ``` **CDN**
Add the following script to the head section of your `index.html` ```html theme={null} ``` ### Implementation ```javascript Javascript theme={null} const ReverieClient = require("@reverieit/reverie-client"); const reverieClient = new ReverieClient({ apiKey: "YOUR-API-KEY", appId: "YOUR-APP-ID", }); await reverieClient.init_stt({ src_lang: "hi", callback: (event) => { console.log("STT event:", event); }, element: document.getElementById("transcript"), domain: "generic" }); // Start/Stop streaming await reverieClient.start_stt(); await reverieClient.stop_stt(); ``` ```python Python theme={null} import pyaudio, asyncio from reverie_sdk import ReverieClient from reverie_sdk.services.asr import AudioStream client = ReverieClient( api_key="REVERIE_API_KEY", app_id="REVERIE_APP_ID", ) stream = AudioStream() pa = pyaudio.PyAudio() def mic_callback(in_data, frame_count, time_info, status): try: asyncio.run(stream.add_chunk_async(in_data)) except: return (None, pyaudio.paAbort) return (None, pyaudio.paContinue) async def main(): pa_stream = pa.open( rate=RATE, channels=CHANNELS, format=FORMAT, frames_per_buffer=CHUNK_SIZE, input=True, stream_callback=mic_callback, ) pa_stream.start_stream() print("listening... press ctrl+C to stop", flush=True) try: await client.asr.stt_stream_async( src_lang="en", bytes_or_stream=stream, callback=print, continuous="0", domain="generic", format="16k_int16", logging="true", punctuate="true", silence=15, timeout=15, ) except Exception as err: print(err) finally: pa_stream.stop_stream() pa_stream.close() asyncio.run(main()) pa.terminate() ``` ### Response #### Successful Response - Establishing the connection ```json theme={null} { "id": "bb261bd789af4ba487a2667f8d942d4d7e0195fd1c8e4073", "success": true, "text": "", "display_text": "", "final": false, "confidence": 1, "cause": "ready" } ``` #### Partial Utterance - In-between an utterance ```json theme={null} { "id": "bb261bd789af4ba487a2667f8d942d4d7e0195fd1c8e4073", "success": true, "text": "आत्म निर्भर योजना इस योजना अथवा अभियान का उद्देश्य एक सौ तीस करोड़ भारतवासियो", "display_text": "आत्म निर्भर योजना इस योजना अथवा अभियान का उद्देश्य 130 करोड़ भारतवासियों", "final": false, "confidence": 0.797274, "cause": "partial" } ``` #### The Final Successful Response ```json theme={null} { "id": "bb261bd789af4ba487a2667f8d942d4d7e0195fd1c8e4073", "success": true, "text": "आत्म निर्भर योजना इस योजना अथवा अभियान का उद्देश्य एक सौ तीस करोड़ भारतवासियों को आत्मनिर्भर बनाना है ताकि देश का हर नागरिक संकट की इस घड़ी में कदम से कदम मिलाकर चल सके", "display_text": "आत्म निर्भर योजना इस योजना अथवा अभियान का उद्देश्य 130 करोड़ भारतवासियों को आत्मनिर्भर बनाना है ताकि देश का हर नागरिक संकट की इस घड़ी में कदम से कदम मिलाकर चल सके", "final": true, "confidence": 0.743304, "cause": "EOF received" } ``` #### Error Response ```json theme={null} { "id": "2ab3a0b76c854953a022df742f6b3857a76494acd72e4489", "success": false, "text": "", "final": true, "confidence": 1, "cause": "no `domain` given" } ``` ### API References #### Query Parameters {" "} A unique key/token is provided by Reverie to identify the user using the STT API. {" "} A unique account ID to identify the user and the default account settings {" "} The parameter to identify the API.
**Note:** The value allowed is stt\_stream
{" "} * Indicates the language in which the audio is spoken.
* Specify the ISO language code.
* Example: `hi`
* Refer to section [Language Codes](/usage-guides/speech-to-text/supported-languages) for valid language code.
{" "} * The universe in which the Streaming STT API is used for transcribing the speech.
* Specify the domain ID.
* Example: `generic`
* Refer to section [Domains](/usage-guides/speech-to-text/supported-domains) for valid domain code.
{" "} * The duration to keep a connection open between the application and the STT server.
* **Note**: The default timeout = `15` seconds, and the maximum time allowed = `180` seconds
{" "} * The time to determine when to end the connection automatically after detecting the silence after receiving the speech data.
* Example: * Consider `silence = 15` seconds i.e., On passing the speech for 60 seconds, and if you remain silent, the connection will be open for the next 15 seconds and then will automatically get disconnected.
* Note: The default silence= `1` second, and the maximum silence = `30` seconds.
{" "} * The audio sampling rate and the data format of the speech.
* Refer to section [Supported Audio Formats](/usage-guides/speech-to-text/supported-audio-formats) for valid audio format code.
* Note: By default, the format = `16k_int16`. (WAV, Signed 16 bit, 16,000 or 16K Hz).
{" "} * Possible values are : 1. `true` - stores audio and keep transcripts in logs. 2. `no_audio` - does not store audios but keep transcripts in logs. 3. `no_transcript` - does not keep transcripts in logs but stores audios. 4. `false` - does not keep neither audios nor transcripts in log. * Default value is `true` {" "} * It will enable punctuation and capitalisation in the transcript. The values it can take are true and false. * Supported languages: `en`, `hi` * Default value is `true` {" "} * It will enable continuous decoding even after silence is detected. * Can take value `true`/`1` or `false`/`0`. * Default value is `false`/`0` #### Request {" "} * The audio streamed from the input device. * Note: The default timeout = 15 seconds, and the maximum time allowed = 180 seconds. #### Response {" "} * API will auto-assign assign a unique identification number for each request. {" "} * Will indicate the functional status of the API: * If the `success` = `true`, then the API is functioning and ready to generate output. * If the `success` = `false`, then the API is not functional and has some errors {" "} * Will report whether the received output is partial or final: * If the `final` = `true`, then the received text is the final output. * If the `final` = `false`, then the text received is partial and is still processing the file {" "} * Reason for obtaining the final output. * The cause will appear for both successful and failed requests; * Refer to section [API Codes](/api-reference/speech-to-text-streaming#api-messages) to view the list of messages/ cause and its description. {" "} * The streaming audio input is converted into text format in the requested language. * Note: The field will remain empty in case of any error or on connect. {" "} * The level of confidence that Streaming STT API has in the accuracy of the transcription. * The Confidence score ranges from `0` to `1`. Higher scores indicate greater relevance to the transcription {" "} * The beautified text of the final transcript. * If the final transcript consists of digits, URL, app names, it is quickly converted to a readable format for the user. * Note: The field will remain empty in case of any error or on connect #### Handling Error The Streaming STT API raises exceptions for many reasons, such as a failed connection, invalid parameters, authentication errors, and network unavailability. We provide more specific human-readable messages with an error response so that users can react to errors more. In the API response, if the `success` = `false`, then the cause will display the reason for the error. Refer to [API Codes](/api-reference/speech-to-text-streaming#api-messages) to view the list of error messages and its description. ```json theme={null} { "id": "2ab3a0b76c854953a022df742f6b3857a76494acd72e4489", "success": false, "text": "", "final": true, "confidence": 1, "cause": "no `domain` given" } ``` #### API Messages | Message Code | Message | Description | | ------------ | ------------------------- | --------------------------------------------------------------------------------------------------------- | | 403 | Forbidden | Entered Invalid credentials | | 403 | Forbidden | The provided credit limit is exhausted. | | 403 | Forbidden | The API key provided to a user is expired. | | 403 | Forbidden | The user is not authorized to use the STT API. | | 403 | Forbidden | The invalid language code is passed, or the user has entered the code, which he is not authorized to use. | | 400 | no decoder for given args | For the language and domain given in the request, STT service is not available | | 200 | unsupported audio format | The API does not support the audio format. | | 200 | ready | STT is ready to receive audio data | | 200 | partial | This is a partial response. Keep waiting for the final response. | | 200 | EOF received | This is the final response. The connection will be closed as EOF received in the request. | | 200 | silence detected | This is the final response. The connection will be closed as silence is received in the request. | | 200 | timeout | This is the final response. The connection will be closed as no data is received. | | 200 | audio too short | Audio too short to detect transcription | # Text-to-Speech API Source: https://docs.reverieinc.com/api-reference/text-to-speech Reverie's TTS (Text-to-Speech) is a solution that turns text into lifelike speech, allowing you to create applications that talk in multiple Indic languages and build comprehensive speech-enabled products. # How Does API Work? The process to generate an audio file for the text input is: * Post the request by: * Enter the valid `REV-APPNAME`, `REV-APP-ID`, and `REV-API-KEY`. * Enter the text for which you want to obtain the speech. * Select the output voice type (either male voice or the female voice) of the audio file. * Define the SSML Code, if required. * By default, the API will return the WAV audio file with a sampling rate of 22.05KHz. ## cURL for Integration ### Request : Synthesizing Audio for Single Sentence ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'REV-APPNAME: tts' \ --header 'speaker: hi_female' \ --header 'Content-Type: application/json' \ --data-raw '{ "text": "किसान होंगे आत्मनिर्भर, समृद्ध भारत" }' ``` ### Request : Synthesizing Audio for Multiple Sentences ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'REV-APPNAME: tts' \ --header 'speaker: hi_female' \ --header 'Content-Type: application/json' \ --data-raw '{ "text": ["भारत मेरा देश है।" , "मेरी कंपनी का नाम रेवेरी लैंग्वेज टेक्नोलॉजीज है।" ], "speed": 1, "pitch": 0, "format": "WAV" }' ``` ### Request : Synthesizing Audio for Multiple Sentences ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'REV-APPNAME: tts' \ --header 'speaker: hi_female' \ --header 'Content-Type: application/json' \ --data-raw '{ "ssml": " Hello. ", "speed": 1, "pitch": 0, "format": "WAV" }' ``` ### Error Response ```json theme={null} { "success": false, "cause": "no `spkr` given" } ``` ## API References ### HTTP Request URL | URL Elements | Sample URL | | ------------------- | ---------------------------------------------------------------- | | https\://(hostname) | [https://revapi.reverieinc.com/](https://revapi.reverieinc.com/) | #### Headers {" "} `application/JSON` {" "} A unique key/token provided by Reverie to identify the user using the TTS API. {" "} The unique account ID to identify the user and the default account settings. {" "} The parameter to identify the API. The value is `tts` {" "} * The desired language and voice code for synthesizing the audio file
* Example: `hi_male`
* Specify the speaker’s code with respect to the language. Refer to [Supporting Speaker](/usage-guides/text-to-speech/supported-speakers) Code section for valid speaker code.
#### Request {" "} * The plain text or SSML input to synthesize an audio output. * If you want to follow W3 standards, the ssml field must be used and not the text field. * For SSML input Refer to the [SSML Tags](/usage-guides/text-to-speech/ssml-tags#core-ssml-tags) {" "} * The speech rate of the audio file. Allows values: from 0.5 (slowest speed rate) up to 1.5 (fastest speed rate). * Note: By default, speed = 1 (normal speed). {" "} * Speaking pitch, in the range Allows values: from -3 up tp 3. 3 indicates an increase of 3 semitones from the original pitch. -3 indicates a decrease of 3 semitones from the original pitch. * Note: By default, the pitch = 0 (zero) {" "} * The sampling rate (in hertz) to synthesize the audio output. Refer to [Supporting Sampling Rate](usage-guides/text-to-speech#supported-sampling-rate) section, to know the supporting audio sample rates. * Note: By default, the sample\_rate = 22050 Hz (22.05kHz) {" "} * The speech audio format to generate the audio file. Refer to [Supporting Audio Format](/usage-guides/text-to-speech/supported-audio-formats) section, to know the supporting audio formats.
* Note: By default, the format = WAV
#### Handling Error The TTS API raises exceptions for many reasons, such as failed conversions, invalid parameters, authentication errors, and network unavailability. It will provide more specific machine-readable messages with an error response so that users can react to errors more effectively. Refer to [API Codes](/api-reference/text-to-speech#api-messages) to view the list of error messages and its description. ```json theme={null} { "success": false, "cause": "no `text` given" } ``` #### API Messages | Status Code | Error Message | Description | | ----------- | ----------------------------------------- | ------------------------------------------------------------------------------------ | | 403 | Invalid REV-API-KEY or REV-APP-ID | Entered Invalid credentials | | 403 | usage exhausted | The provided credits or the character limit is exhausted. | | 403 | API key expired | The API key provided to a user is expired. | | 403 | unauthorized to use this API | The REV-APPNAME entered is invalid, or the user is not authorized to use it. | | 403 | unauthorized to use this src/tgt language | The invalid speaker code is passed, or the user cannot use the defined speaker code. | | 400 | no spkr given | The speaker code is missing | | 400 | invalid speed value | The speed requested in the input is invalid or not supported by the API. | | 400 | invalid pitch value | The audio pitch defined in the input is invalid or not supported by the API. | | 400 | invalid format value | The requested audio format is invalid or not supported by the API. | | 400 | invalid sample\_rate value | The requested audio sample rate is invalid or not supported by the API. | | 400 | no text given | The input text is missing | # Transliteration API Source: https://docs.reverieinc.com/api-reference/transliteration The Transliteration API is a REST API used to transliterate the content from English to Indic languages and vice-versa. The solution is an automated solution that converts the content in real-time. It is easy to integrate into your applications and display content in the 11 most popular Indian languages # How Does API Work? The Transliteration API will use the REV-APP-ID and REV-API-KEY to authenticate requests. Your credentials carry many privileges, so be sure to keep them secure. * **Pass valid login credentials**: * `REV-APP-ID` * `REV-API-KEY` * Select Source language & Target language * Post Source Content * Validate user credentials & load default account settings * Return content in Target language ## cURL for Integration ### Translate content to one target language #### Request ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'cnt_lang: en' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["Reverie Language Technologies ltd website address is www.reverieinc.com"], "isBulk" :false, "ignoreTaggedEntities" : false }' ``` #### Response ```json theme={null} { "responseList": [ { "inString": "Reverie Language Technologies ltd website address is www.reverieinc.com ", "outString": [ "रेवरी लैंग्वेज टेक्नोलॉजीस लिमिटेड वेबसाइट एड्रेस इज़ www.reverieinc.com" ], "status": 2 } ] } ``` ### Transliterating Multiple sentences #### Request ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'REV-APPNAME: transliteration' \ --header 'domain: 1' \ --header 'cnt_lang: en' \ --data-raw '{"data": [ "Reverie Language Technologies is located in Bengaluru ", "The address is Jio Avana, Bellandur, Bengaluru -560102", "The website address is www.reverieinc.com." ], "isBulk": false, "ignoreTaggedEntities": false }' ``` #### Response ```json theme={null} { "responseList": [ { "inString": "Reverie Language Technologies is located in Bengaluru ", "outString": [ "रेवरी लैंग्वेज टेक्नोलॉजीस इज़ लोकेटेड इन बेंगलुरु " ], "status": 2 }, { "inString": "The address is Jio Avana, Bellandur, Bengaluru -560102", "outString": [ "द एड्रेस इज़ जियो अवाना, बेल्लन्दूर, बेंगलूरु -560102" ], "status": 2 }, { "inString": "The website address is www.reverieinc.com", "outString": [ "द वेबसाइट ऍड्रेस इज़ www.reverieinc.com" ], "status": 2 } ] } ``` ## API References ### HTTP Request URL | URL Elements | Sample URL | | ------------------- | ---------------------------------------------------------------- | | https\://(hostname) | [https://revapi.reverieinc.com/](https://revapi.reverieinc.com/) | ### Headers {" "} The format of the data to be posted: `application/json` {" "} A unique key/token provided by Reverie to identify the user using the Localization API. {" "} The unique account ID to identify the user and the default account settings. {" "} The parameter to identify the API : `transliteration` {" "} * The version refers to the specific iteration of the API that is being called. * Note: The default version is **2.0**. {" "} * The script used in the input text. * Example : `or`, `hi`, `bn` * Refer to section [Language Codes](/usage-guides/transliteration/supported-languages) for valid language code. {" "} * The script to which you want to convert the input text. * Example : `or`, `hi`, `bn` * Refer to section [Language Codes](/usage-guides/transliteration/supported-languages) for valid language code. {" "} * The Domain refers to the universe in which you use the Transliteration . Example- Health Care, Insurance, Legal, etc. * Refer to section [Domain Codes](/usage-guides/transliteration/supported-domains) for valid language code. * The language of the words in the input text. * Refer to section [Supported Language](/usage-guides/transliteration/supported-languages) for valid language code. * **Example**:\ `data: "Singh Sahab aap Kahan the."`\ In the example above, the Hindi language words are written in the English language script (Roman Script). So `cnt_lang = "hi"`. * **Note**: This is an optional parameter. If no value is provided, by default the value is the same as `src_lang`. ### Request {" "} * List of input text for transliteration. {" "} * Specify whether the API should initially search in the Exception DB to transliterate the input text. * **Note** - By default, the `isBulk`= `true` and will not search in the Exception DB. * Mention the number of transliteration suggestions the API should return for the input text. * **Note** - By default, the `noOfSuggestions` = 1, means the API will return only one transliteration suggestion for the input string. * **Example**: Consider `noOfSuggestions = 2` | **Source Content** | **Target Content** | | ------------------ | ------------------ | | Rama | 1. रामा | | | 2. रमा | {" "} * The abbreviate will Validate whether any Abbreviations/ Acronyms are passed in the input text and will transliterate it accurately. * **Note** - By default, the `abbreviate` = `true` * **Note** - If the value is false, the API will consider the abbreviation as a word and transliterate it to the nearest available word. * **Note** - In the input text, pass the abbreviations in upper case. * The feature to screen the non-dictionary words used in a sentence. In other words, the mask will indicate the words that should not be translated into the target language. * **Note** - By default, the `enableLookup` = `true`. * **Note** - To set the `nmtMask` = `true`, it is mandatory the `src_lang` = `en` (English). * **Description**: Specify whether to convert the numbers in the input text to the target language script based on the value type. * **Three types of values for this parameter:** * **local**: This value can convert the input number to the target language script.\ **Example**: | **Source String** | **Target String** | | ----------------- | ----------------- | | 2020.04 | २०२०.०४ | * **words**: This value can convert numbers into words with respect to the target language.\ **Example**: | **Source String** | **Target String** | | ----------------- | ----------------- | | 505 | पांच सौ पांच | * **roman**: This value can convert Roman numbers to English numbers.\ **Example**: * If the user types `sector V` in English, the transliteration would be `सेक्टर 5` in Hindi. * `Block II` will be transliterated as `ब्लॉक 2`. * Specify whether you want to retain the entities like email ID and URL in the input script. * **Note**: By default, the `ignoreTaggedEntities` = `true` and will transliterate the email ID and URL into the target language script. * **Example**: Consider `ignoreTaggedEntities = false` | **Source String** | **Target String** | | ------------------------------------------------------------------------ | ----------------------------------------------------------------------- | | Check product details in [www.reverieinc.com](http://www.reverieinc.com) | चेक प्रोडक्ट डिटेल्स इन [www.reverieinc.com](http://www.reverieinc.com) | * This is used for transliterating ordinal values to English numbers. * **Note** - Default value = `False`. * **Example**: If the user types `15th Main` in English, the transliteration would be `15 मेन` in Hindi. * This is used to produce the abbreviation output without a dot. * **Note** - Default value = `False`. * **Example**: If a user wants an abbreviation output without a dot and is given `SMS` as an input, then the result would be `एसएमएस`. ### Response * The API will return the string(s) in the target language script. * The input text in the source language script. * A string which is the result of converting the input text to the output script * Status of API – successful/fail. * By default, the `api_status` = 2 for all the successful transactions. ### Handling Errors The Transliteration API raises exceptions for many reasons, such as failed conversions, invalid parameters, authentication errors, and network unavailability. It will provide more specific machine-readable messages with an error response so that users can react to errors more effectively. Refer to: [API Messages](/api-reference/transliteration#api-messages) section to know the error code and corresponding messages. ```json theme={null} { "documentation": "https://revup.reverieinc.com/dashboard/documentation", "message": "Oops! Something wrong happened", "error_cause": "Required String parameter 'target_lang' is not present", "status": "BAD_REQUEST" } ``` ### API Messages | Status Code | Status Type | Message | Description | | ----------- | --------------------- | ------------------------------------------ | ---------------------------------------------------------------------------- | | 200 | Success/OK | - | Successfully executed the request. | | 400 | Bad Request | Message depending on the missing parameter | Incorrect request format or data posted incorrectly. | | 403 | Forbidden | Invalid REV-API-KEY or REV-APP-ID | Entered invalid credentials. | | 403 | Forbidden | usage exhausted | The provided credits or character limit is exhausted. | | 403 | Forbidden | API key expired | The API key provided to a user is expired. | | 403 | Forbidden | unauthorized to use this src/tgt language | Invalid language code passed or user cannot use the defined language code. | | 403 | Forbidden | unauthorized to use this API | The REV-APPNAME entered is invalid, or the user is not authorized to use it. | | 500 | Internal Server Error | Internal Server Error | An error occurred with the API. | # Get your API credentials Source: https://docs.reverieinc.com/authentication To start integrating Reverie’s APIs into your application, you'll need two credentials: * **REV-API-KEY**: Your unique API key for authentication * **REV-APP-ID**: Identifies your registered application These are required in the header of every request made to our APIs. ### Steps to Generate Your API Key 1. **Sign Up** : Visit [RevUp Developer Portal](https://revup.reverieinc.com?utm_source=documentation\&utm_medium=website\&utm_campaign=revup_signup) and create a free developer account. 2. **Automatic API Key Generation** : As soon as you register, your **first API Key** and **App ID** are automatically created — no extra steps required. 3. **Access Credentials** : Your APP ID and API Key will be visible in the dashboard for use in your integrations. Reverie Dashboard ### How to Use the Credentials To authenticate your requests, include the REV-APP-ID & REV-API-KEY in the headers of your HTTP requests. ```yml theme={null} REV-API-KEY: REV-APP-ID: ``` ### Test your first API call Here are the cURL requests of all the APIs. ```bash Speech-to-Text (File) theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: generic' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_file' \ --header 'REV-APP-ID: ' \ --header 'subtitles: true' \ --form 'file=@""' ``` ```bash Text-to-Speech theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'REV-APPNAME: tts' \ --header 'speaker: hi_female' \ --header 'Content-Type: application/json' \ --data-raw '{ "text": "किसान होंगे आत्मनिर्भर, समृद्ध भारत" }' ``` ```bash Translation theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ], "nmtMask": true, "nmtMaskTerms": { "Reverie Language Technologies":"Reverie Language Technologies" }, "enableNmt": true, "enableLookup": true }' ``` ```bash Transliteration theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'cnt_lang: en' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["Reverie Language Technologies ltd website address is www.reverieinc.com"], "isBulk" :false, "ignoreTaggedEntities" : false }' ``` ```bash OCR theme={null} curl -X POST https://revapi.reverieinc.com/process_doc \ --header 'REV-API-KEY: YOUR-API-KEY' \ --header 'REV-APP-ID: YOUR-APPID' \ --header 'REV-APPNAME: ocr' \ -F "file=@document.pdf" \ -F "file_type=pdf" \ -F "languages=en,hi" \ -F "ocr_type=layout_ocr" ``` ```bash Document Localization theme={null} curl --location 'https://revapi.reverieinc.com/translate_doc_import' \ --header 'REV-APP-ID: YOUR_APP_ID' \ --header 'REV-APPNAME: nmt' \ --header 'REV-API-KEY: YOUR_API_KEY' \ --form sourceLanguage="english" \ --form targetLanguage="hindi" \ --form projectFiles=@"/path/to/your/file/Movie.txt" ``` ```bash Text Analysis theme={null} curl --location 'http://revapi.reverieinc.com/api/v2/text-analyse?translate=false&summary=false&sentiment=true&detect_entities=true&content_safety=true&pii_redaction=true' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'REV-APPNAME: text-analysis' \ --data-raw '{ "text": "Today is a special day. I sent you an email earlier and shared my website link. Please use #ForBetterReach and feel free to contact me around 10 AM.", "language": "en", "translation": { "target_language": "en", "translation_domain": "generic" }, "pii_redaction": { "redact_pii_sub": "entity_name", "redact_pii_types": [] }, "summary": { "summary_model": "gemma2:2b", "summary_type": "headline" }, "entity_recognition": { "entity_types": [] }, "sentiment": { "level": "whole" }, "content_moderation": { "moderation_types": [ "hate_speech", "profanity" ] } }' ``` ### Best Practices for API Key Management 1. **Secure Storage**: Store API keys in secure environments like encrypted storage or secrets management tools (e.g., AWS Secrets Manager or Azure Key Vault) to avoid exposure in source code or version control systems. 2. **Limit Key Permissions**: Use the principle of least privilege by restricting the permissions associated with the API key. Only allow access to the specific API endpoints and actions required, reducing potential security risks 3. **Monitor Usage and Set Limits**: Continuously monitor API key usage for abnormal activity and implement rate limits to prevent abuse or overuse, ensuring better security and performance. # Contact Us Source: https://docs.reverieinc.com/contact-us Need help, have questions, or want to see our solutions in action? We’re here to help. Choose any of the following ways to reach out to our team: ### Request a Demo Explore our solutions with a personalized walkthrough. [**Request a Demo**](https://reverieinc.com/request-demo)\ Fill out the form, and our team will connect with you shortly. *** ### Email Our Support Team For technical queries, API issues, or onboarding assistance. [**api.support@reverieinc.com**](mailto:api.support@reverieinc.com)\ We typically respond within 24 hours on business days. *** ### Join Our Discord Community Connect directly with our engineers and fellow developers. [**Join us on Discord**](https://discord.com/invite/ba8TT9UYfu)\ Get support, share ideas, and stay updated. *** # Translation API Source: https://docs.reverieinc.com/endpoints/localization POST https://revapi.reverieinc.com/ Translation is a REST API that quickly translates English content into Indic languages, supporting single or multiple sentences. ```bash cURL theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ], "nmtMask": true, "nmtMaskTerms": { "Reverie Language Technologies":"Reverie Language Technologies" }, "enableNmt": true, "enableLookup": true }' ``` ```python Python theme={null} from reverie_sdk import ReverieClient client = ReverieClient( api_key="MY_API_KEY", app_id="MY_APP_ID", ) resp = client.nmt.localization( data=[ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bangalore.", ], domain=1, src_lang="en", tgt_lang=["hi"], nmtMask=True, nmtMaskTerms=["Reverie Language Technologies"], nmtParam=True, dbLookupParam=True, segmentationParam=False, ) print(resp) ``` ```javascript JavaScript theme={null} const ReverieClient = require("@reverieit/reverie-client"); const reverieClient = new ReverieClient({ apiKey: "YOUR-API-KEY", appId: "YOUR-APP-ID", }); async function translateText() { const translation = await reverieClient.translate({ text: "Hey there, how are you doing?", src_lang: "en", tgt_lang: "or", }); console.log(translation); } translateText(); ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "log" "net/http" ) const ( apiURL = "https://revapi.reverieinc.com/" apiKey = "" appID = "" ) type RequestBody struct { Data []string `json:"data"` IsBulk bool `json:"isBulk"` IgnoreTaggedEntities bool `json:"ignoreTaggedEntities"` } type APIResponse struct { ResponseList []struct { APIStatus int `json:"apiStatus"` InString string `json:"inString"` OutString string `json:"outString"` // Change []string to string } `json:"responseList"` TokenConsumed int `json:"tokenConsumed"` } func main() { text := "Reverie Language Technologies ltd is a great place to work." // Constructing JSON Request Body requestBody := map[string]interface{}{ "data": []string{text}, "isBulk": false, "ignoreTaggedEntities": false, } jsonData, err := json.Marshal(requestBody) if err != nil { log.Fatalf("Error marshaling JSON: %v", err) } // Creating HTTP Request req, err := http.NewRequest("POST", apiURL, bytes.NewBuffer(jsonData)) if err != nil { log.Fatalf("Error creating request: %v", err) } // Setting Request Headers req.Header.Set("Content-Type", "application/json") req.Header.Set("REV-API-KEY", apiKey) req.Header.Set("REV-APP-ID", appID) req.Header.Set("src_lang", "en") req.Header.Set("tgt_lang", "hi") req.Header.Set("domain", "1") req.Header.Set("cnt_lang", "en") req.Header.Set("REV-APPNAME", "localization") // Making HTTP Request client := &http.Client{} resp, err := client.Do(req) if err != nil { log.Fatalf("Error making request: %v", err) } defer resp.Body.Close() // Handle non-200 response codes if resp.StatusCode != http.StatusOK { log.Fatalf("Unexpected API response status: %d", resp.StatusCode) } // Read Response Body body, err := io.ReadAll(resp.Body) if err != nil { log.Fatalf("Error reading response body: %v", err) } // Unmarshalling JSON Response var apiResponse APIResponse err = json.Unmarshal(body, &apiResponse) if err != nil { log.Fatalf("Error unmarshaling response: %v", err) } // Check if response contains valid translation if len(apiResponse.ResponseList) > 0 { response := apiResponse.ResponseList[0] if len(response.OutString) > 0 { fmt.Println("Translated Text:", response.OutString) } else { fmt.Println("No translated text received.") } // Handling API Status if response.APIStatus != 3 { // Example: 3 might indicate partial success fmt.Printf("Warning: API returned status %d\n", response.APIStatus) } } else { fmt.Println("No response from API") } } ``` ### Headers {" "} The format of the data to be posted: "application/json" {" "} A unique key/token provided by Reverie to identify the user using the Translation API. {" "} The unique account ID to identify the user and the default account settings. {" "} The parameter to identify the API : "localization" {" "} The version refers to the specific iteration of the API that is being called. : "2.0/3.0" Note: The default version is "2.0". {" "} The language of the input text Codes: hi, en, as, bn, gu, kn, kok, ml, mr, mai, or, pa, ta, te, ne, ur {" "} Language to which you want to localize the input text Codes: hi, en, as, bn, gu, kn, kok, ml, mr, mai, or, pa, ta, te, ne, ur {" "} Domain for APPVERSION 2.0: 0, 1, 2, 3, 4, 5, 6, 7, 8 Domain for APPVERSION 3.0: generic, government, travel, ecommerce, infotainment, bfsi, food, education, medical ### Body {" "} List of input text for Translation. {" "} Specify whether the content Translation process should use NMT technology or not. * For Example, When the enableNmt value is true, the system will initially refer to the Lookup database to localize content. If the content is not available in the database, then the NMT is used for translation. * **Note** - By default, the `enableNmt`= `true` {" "} Specify whether the content Translation process should use transliteration technology or not. * For Example, When the enableTransliteration value is true, the system will initially refer to the Lookup database to localize content. If the content is not available in the database, then nmt is used for translation. If nmt fails, transliteration is called. * **Note** - By default, the `enableTransliteration`= `true` {" "} The parameter will specify whether the application should refer to the Lookup DB or not. * For Example, when the enableLookup is true, the system will initially refer to the Database to fetch contents. * **Note** - By default, the `enableLookup`= `true` {" "} The feature to screen the non-dictionary words used in a sentence. In other words, the mask will indicate the words that should not be translated into the target language. * **Note** - By default, the `enableLookup`= `true` * **Note** - To set the `nmtMask` = `true`, it is mandatory the `src_lang` = `en` (English). Determines the words that are to be masked. * **Note** - On defining values in the `nmtMaskTerms`, then automatically the `nmtMask` is set to true. * **Example** - Masking a term:\ `nmtMaskTerms: ["Reverie Language Technologies"]`\ Here, the API will mask the term `Reverie Language Technologies`, if found in the source content, and will transliterate the word. {" "} Specify whether you want to filter out profane content from the input. * **Note** - By default, the `filterProfane`= `true` ```bash 200 theme={null} { "responseList": [ { "inString": "Reverie Language Technologies was established in 2009.", "outString": "Reverie Language Technologies की स्थापना 2009 में की गई थी।", "apiStatus": 3 }, { "inString": "The company head office is located in Bengaluru.", "outString": "कंपनी का मुख्यालय बेंगलुरु में स्थित है।", "apiStatus": 3 } ], "tokenConsumed": 102 } ``` ```bash 400 theme={null} { "message" : "Message depending on the missing parameter" } ``` ```bash 403 theme={null} { "message" : "Invalid REV-API-KEY or REV-APP-ID" } ``` ```bash 403 theme={null} { "message" : "usage exhausted" } ``` ```bash 403 theme={null} { "message" : "API key expired" } ``` ```bash 403 theme={null} { "message" : "unauthorized to use this src/tgt language" } ``` ```bash 403 theme={null} { "message" : "unauthorized to use this API" } ``` ```bash 500 theme={null} { "message" : "Internal Server Error" } ``` ### Response An array of translation responses The input text in the source language. Example: `Reverie Language Technologies was established in 2009.` The localized content in the requested target language. Example: `Reverie Language Technologies की स्थापना 2009 में की गई थी।` Status of API Moderated / Partial / Unmoderated (Aggregate of all segments). Refer to API Messages for available apiStatus and its description. Example: `3` The payload length served by NMT. Note: If LookUp DB serves the payload and the content is moderated, then tokenConsumed = 0. Example: `102` # Text to Speech API Source: https://docs.reverieinc.com/endpoints/text-to-speech POST / Reverie’s TTS (Text-to-Speech) is a solution that turns text into lifelike speech, allowing you to create applications that talk in multiple Indic languages and build comprehensive speech-enabled products. # Transliteration API Source: https://docs.reverieinc.com/endpoints/transliteration POST https://revapi.reverieinc.com/ The Transliteration API enables you to convert text content from one language script to another. Below are examples demonstrating how to transliterate single and multiple sentences. ```bash cURL theme={null} curl --location --request POST 'https://revapi.reverieinc.com' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{ "data": ["Hello, how are you?"], "isBulk": true, "ignoreTaggedEntities": true }' ``` ```python Python theme={null} from reverie_sdk import ReverieClient client = ReverieClient( api_key="MY_API_KEY", app_id="MY_APP_ID", ) res = client.t13n.transliteration( data=[ "Reverie Language Technologies is located in Bengaluru ", "The address is Jio Avana, Bellandur, Bengaluru -560102", "The website address is www.reverieinc.com.", ], src_lang="en", cnt_lang="en", tgt_lang="hi", noOfSuggestions=2, ) print(res) ``` ```javascript JavaScript theme={null} const ReverieClient = require("@reverieit/reverie-client"); const reverieClient = new ReverieClient({ apiKey: "YOUR-API-KEY", appId: "YOUR-APP-ID", }); async function transliterateText() { const translation = await reverieClient.transliterate({ text: "Namaste", src_lang: "en", tgt_lang: "ta", }); console.log(translation); } transliterateText(); ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "log" "net/http" ) const ( apiURL = "https://revapi.reverieinc.com/" apiKey = "" appID = "" ) type RequestBody struct { Data []string `json:"data"` IsBulk bool `json:"isBulk"` IgnoreTaggedEntities bool `json:"ignoreTaggedEntities"` } type APIResponse struct { ResponseList []struct { APIStatus int `json:"apiStatus"` InString string `json:"inString"` OutString []string `json:"outString"` } `json:"responseList"` } func main() { text := "Reverie Language Technologies ltd website address is www.reverieinc.com" requestBody := map[string]interface{}{ "data": []string{text}, "isBulk": false, "ignoreTaggedEntities": false, } jsonData, err := json.Marshal(requestBody) if err != nil { log.Fatalf("Error marshaling JSON: %v", err) } req, err := http.NewRequest("POST", apiURL, bytes.NewBuffer(jsonData)) if err != nil { log.Fatalf("Error creating request: %v", err) } req.Header.Set("Content-Type", "application/json") req.Header.Set("REV-API-KEY", apiKey) req.Header.Set("REV-APP-ID", appID) req.Header.Set("src_lang", "en") req.Header.Set("tgt_lang", "hi") req.Header.Set("domain", "1") req.Header.Set("cnt_lang", "en") req.Header.Set("REV-APPNAME", "transliteration") client := &http.Client{} resp, err := client.Do(req) if err != nil { log.Fatalf("Error making request: %v", err) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatalf("Error reading response body: %v", err) } var apiResponse APIResponse err = json.Unmarshal(body, &apiResponse) if err != nil { log.Fatalf("Error unmarshaling response: %v", err) } if len(apiResponse.ResponseList) > 0 && len(apiResponse.ResponseList[0].OutString) > 0 { fmt.Println("Transliterated text:", apiResponse.ResponseList[0].OutString[0]) } else { fmt.Println("No response from API") } } ``` ### Headers The format of the data to be posted. Must be set to "application/json". {" "} A unique key/token provided by Reverie to identify the user using the Localization API.{" "} {" "} The unique account ID to identify the user and the default account settings. {" "} Application name i.e., transliteration Source language code : hi, as, bn, gu, kn, ml, mr, or, pa, ta, te, en, ur, sd, doi, kon, brx, ks, mai, mni, sa, sat Target language code : hi, as, bn, gu, kn, ml, mr, or, pa, ta, te, en, ur, sd, doi, kon, brx, ks, mai, mni, sa, sat {" "} Domain category : generic, pii\_names, pii\_addresses, OnlyEnglish, bfsi, ecommerce, food, infotainment Content language code : en ### Body The text you want to translate. This is the input text that will be processed by the translation model. {" "} Indicates whether the request is for bulk processing. Set to `false` for single sentence transliteration.{" "} {" "} Determines whether to ignore tagged entities during transliteration. Set to `false` to include all entities.{" "} ```bash 200 theme={null} { "responseList": [ { "inString": "Reverie Language Technologies ltd website address is www.reverieinc.com ", "outString": [ "रेवरी लैंग्वेज टेक्नोलॉजीस लिमिटेड वेबसाइट एड्रेस इज़ www.reverieinc.com" ], "status": 2 } ] } ``` ```bash 400 theme={null} { "message" : "Message depending on the missing parameter" } ``` ```bash 403 theme={null} { "message" : "Invalid REV-API-KEY or REV-APP-ID" } ``` ```bash 403 theme={null} { "message" : "usage exhausted" } ``` ```bash 403 theme={null} { "message" : "API key expired" } ``` ```bash 403 theme={null} { "message" : "unauthorized to use this src/tgt language" } ``` ```bash 403 theme={null} { "message" : "unauthorized to use this API" } ``` ```bash 500 theme={null} { "message" : "Internal Server Error" } ``` ### Response An array of translation responses The input text in the source language script. Example: `Reverie Language Technologies ltd website address is www.reverieinc.com` The result of converting the input text to the output script. Example: `["रेवरी लैंग्वेज टेक्नोलॉजीस लिमिटेड वेबसाइट एड्रेस इज़ www.reverieinc.com"]` Status of API – successful/fail. By default, 2 for successful transactions. Example: `2` # Introduction Source: https://docs.reverieinc.com/introduction Reverie’s Language AI APIs enable developers to build multilingual, speech-enabled, and intelligent applications tailored for the Indian market. Whether you're building from scratch or embedding into an existing stack, our APIs are designed for scalability, low latency, and easy interoperability across platforms. **India-First Language Intelligence**
Reverie’s models are trained specifically on Indian languages, dialects, and accents — ensuring better accuracy, fluency, and contextual understanding across diverse regions. **Full-Stack Language Coverage**
From real-time speech transcription to document translation, from text-to-speech to named entity recognition — Reverie offers a comprehensive suite for any Indian language use case. **Easy Integration, Powerful Performance**
With developer-friendly APIs, SDKs, and production-grade scalability, you can integrate language AI into your app in minutes — without compromising on performance or reliability. ## Here’s a quick overview of the APIs available Convert live audio into real-time transcriptions using WebSocket. Ideal for IVR systems, virtual assistants, and live meeting captioning. Upload audio files and receive full transcripts asynchronously. Best for analyzing recorded calls, podcasts, or long audio content. Turn written text into natural-sounding speech in Indian languages. Useful in voice bots, accessibility tools, and language learning apps. Translate content between English and Indian languages with domain-tuned accuracy. Useful for apps, customer support, and content platforms. Convert Roman script to native Indian scripts (e.g., `“namaste”` → `“नमस्ते”`). Ideal for input methods, autocomplete, and typing tools. These APIs are production-ready, scalable, and optimized for Indian language nuances, accents, and dialects. ## Getting Started Ready to get started? Dive into our detailed API documentation to integrate these powerful tools into your projects. For any questions or technical support, our team is here to help. Empower your applications with our advanced language processing capabilities today! # GoLang SDK Source: https://docs.reverieinc.com/sdk/go Use Reverie’s Language Solutions in your Go applications with our lightweight Go SDK. This section provides guidance on working with audio processing, retrieving transcription data, and embedding language intelligence into your Go services with clean, idiomatic Go code. Transcribe audio files in batches using the golang SDK. Check the repository for examples. Translate and transliterate content accurately for localization and user support. Visit the repository for implementation guides. Seamlessly convert text between scripts for multilingual platforms and global reach. Visit the repository for implementation guides. Convert written text into natural-sounding speech in multiple languages and voices. Visit the repository for implementation details and API usage. # JavaScript SDK Source: https://docs.reverieinc.com/sdk/javascript Learn how to integrate Reverie’s Language Solutions into your web or Node.js applications using our JavaScript SDK. This section walks you through using our prebuilt libraries to process audio files, extract transcription data, and embed powerful language capabilities directly into your JavaScript projects with minimal setup. Transcribe audio files in batches using the javascript SDK. Check the repository for examples. Enable real-time audio transcription with the javascript SDK. Explore the repository for details. Translate and transliterate content accurately for localization and user support. Visit the repository for implementation guides. Seamlessly convert text between scripts for multilingual platforms and global reach. Visit the repository for implementation guides. Convert written text into natural-sounding speech in multiple languages and voices. Visit the repository for implementation details and API usage. # Python SDK Source: https://docs.reverieinc.com/sdk/python Easily integrate Reverie’s Language Solutions into your Python applications using our robust Python SDK. This guide shows you how to process audio files, extract transcription data, and embed multilingual capabilities using familiar Pythonic patterns—perfect for scripts, back-end services, or data pipelines. Transcribe audio files in batches using the python SDK. Check the repository for examples. Enable real-time audio transcription with the python SDK. Explore the repository for details. Translate and transliterate content accurately for localization and user support. Visit the repository for implementation guides. Seamlessly convert text between scripts for multilingual platforms and global reach. Visit the repository for implementation guides. Convert written text into natural-sounding speech in multiple languages and voices. Visit the repository for implementation details and API usage. # Getting Started Source: https://docs.reverieinc.com/usage-guides/localization/getting-started Translation is the REST API developed for localizing the contents from English to Indic languages. Using the Translation API, you can either localize a single sentence or multiple sentences in a fraction of time. In this guide, you’ll learn how to automatically transcribe live streaming audio in real time using Reverie's SDKs, which are supported for use with the Reverie API. Before you start, you'll need to follow the steps in the [Get your API Credentials](/authentication) to obtain your API KEY & APP ID. ### Make your first Call Make your first API Call using the cURL request. Add your own API Credentials where it says `` & `` and then run the following example in a terminal or your favorite API client. ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ] }' ``` By default, The API will return the strings in the target language. ### SDKs Reverie has several SDKs that can make it easier to use the API. Follow these steps to use the SDK of your choice to make a Reverie Translation request. ### Install Dependencies ```bash JavaScript theme={null} npm i @reverieit/reverie-client ``` ```bash Python theme={null} pip install reverie-sdk ``` ### Translate Text to your preferred language The following code shows how to convert the text to your preferred language. ```javascript JavaScript theme={null} const ReverieClient = require("@reverieit/reverie-client"); const reverieClient = new ReverieClient({ apiKey: "YOUR-API-KEY", appId: "YOUR-APP-ID", }); async function translateText() { const translation = await reverieClient.translate({ text: "Hey there, how are you doing?", src_lang: "en", tgt_lang: "or", }); console.log(translation); } translateText(); ``` ```python Python theme={null} from reverie_sdk import ReverieClient client = ReverieClient( api_key="MY_API_KEY", app_id="MY_APP_ID", ) resp = client.nmt.Translation( data=[ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bangalore.", ], domain=1, src_lang="en", tgt_lang=["hi"], nmtMask=True, nmtMaskTerms=["Reverie Language Technologies"], nmtParam=True, dbLookupParam=True, segmentationParam=False, ) print(resp) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "log" "net/http" ) const ( apiURL = "https://revapi.reverieinc.com/" apiKey = "" appID = "" ) type RequestBody struct { Data []string `json:"data"` IsBulk bool `json:"isBulk"` IgnoreTaggedEntities bool `json:"ignoreTaggedEntities"` } type APIResponse struct { ResponseList []struct { APIStatus int `json:"apiStatus"` InString string `json:"inString"` OutString string `json:"outString"` // Change []string to string } `json:"responseList"` TokenConsumed int `json:"tokenConsumed"` } func main() { text := "Reverie Language Technologies ltd is a great place to work." // Constructing JSON Request Body requestBody := map[string]interface{}{ "data": []string{text}, "isBulk": false, "ignoreTaggedEntities": false, } jsonData, err := json.Marshal(requestBody) if err != nil { log.Fatalf("Error marshaling JSON: %v", err) } // Creating HTTP Request req, err := http.NewRequest("POST", apiURL, bytes.NewBuffer(jsonData)) if err != nil { log.Fatalf("Error creating request: %v", err) } // Setting Request Headers req.Header.Set("Content-Type", "application/json") req.Header.Set("REV-API-KEY", apiKey) req.Header.Set("REV-APP-ID", appID) req.Header.Set("src_lang", "en") req.Header.Set("tgt_lang", "hi") req.Header.Set("domain", "1") req.Header.Set("cnt_lang", "en") req.Header.Set("REV-APPNAME", "Translation") // Making HTTP Request client := &http.Client{} resp, err := client.Do(req) if err != nil { log.Fatalf("Error making request: %v", err) } defer resp.Body.Close() // Handle non-200 response codes if resp.StatusCode != http.StatusOK { log.Fatalf("Unexpected API response status: %d", resp.StatusCode) } // Read Response Body body, err := io.ReadAll(resp.Body) if err != nil { log.Fatalf("Error reading response body: %v", err) } // Unmarshalling JSON Response var apiResponse APIResponse err = json.Unmarshal(body, &apiResponse) if err != nil { log.Fatalf("Error unmarshaling response: %v", err) } // Check if response contains valid translation if len(apiResponse.ResponseList) > 0 { response := apiResponse.ResponseList[0] if len(response.OutString) > 0 { fmt.Println("Translated Text:", response.OutString) } else { fmt.Println("No translated text received.") } // Handling API Status if response.APIStatus != 3 { // Example: 3 might indicate partial success fmt.Printf("Warning: API returned status %d\n", response.APIStatus) } } else { fmt.Println("No response from API") } } ``` ### Results In order to see the results from Reverie, you must run the application. Run your application from the terminal. Your transcripts will appear in your shell. ```bash JavaScript theme={null} # Run your application using the file you created in the previous step # Example: npm start ``` ```python Python theme={null} # Run your application using the file you created in the previous step # Example: python main.py ``` ```go GoLang theme={null} // Run your application using the file you created in the previous step // Example: go run main.go ``` ### Analyzing the Response The API returns a `responseList`, which is an array containing the localized content. Each item includes the `inString`, representing the original input text in the source language, and the corresponding `outString`, which contains the translated text in the requested target language. # International Reseller Source: https://docs.reverieinc.com/usage-guides/localization/international-reseller [Braahmam](https://www.braahmam.net/) serves as our trusted reseller partner for markets outside India. For any localisation-related opportunities in these regions, please contact sales@braahmam.net # Key Features Source: https://docs.reverieinc.com/usage-guides/localization/key-features ### `domain` The Domain refers to the universe in which you use the Transliteration API. Example- Health Care, Insurance, Legal, etc. Refer to [Supporting Domain](/usage-guides/localization/supported-domains) to see the available domains. **For Example**: ```bash generic theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ] }' ``` ```bash bfsi theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: bfsi' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ] }' ``` ### `enableNmt` Specify whether the content localization process should use NMT technology or not. i.e., When the enableNmt value is true, the system will initially refer to the Lookup database to localize content. If the content is not available in the database, then the NMT is used for translation. Note - By default, the enableNmt= true **For Example**: ```bash enableNmt = true theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ] "enableNmt": true }' ``` ```bash enableNmt = false theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ] "enableNmt": false }' ``` ### `enableTransliteration` Specify whether the content localization process should use transliteration technology or not. i.e., When the enableTransliteration value is true, the system will initially refer to the Lookup database to localize content. If the content is not available in the database, then nmt is used for translation. If nmt fails, transliteration is called. Note - By default, the enableTransliteration= true **For Example**: ```bash enableTransliteration = true theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ] "enableTransliteration": true }' ``` ```bash enableTransliteration = false theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ] "enableTransliteration": false }' ``` ### `enableLookup` The parameter will specify whether the application should refer to the Lookup DB or not. i.e., when the enableLookup is true, the system will initially refer to the Database to fetch contents. Note - By default, the enableLookup= true. **For Example**: ```bash enableLookup = true theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ] "enableLookup": true }' ``` ```bash enableLookup = false theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ] "enableLookup": false }' ``` ### `nmtMask` The feature to screen the non-dictionary words used in a sentence. In other words, the mask will indicate the words that should not be translated into the target language. Note - By default, the nmtMask = false. Note - To set the nmtMask = true, it is mandatory the src\_lang = en (English). **For Example**: ```bash nmtMask = true theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ] "nmtMask": true }' ``` ```bash nmtMask = false theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ] "nmtMask": false }' ``` ### `nmtMaskTerms` Determines the Words that are to be masked. Note - On defining values in the nmtMaskTerms, then automatically the nmtMask is set to true. Example - Masking a term - "nmtMaskTerms": \["Reverie Language Technologies"] Here, the API will mask the term Reverie Language Technologies, if found in the source content, and will transliterate the word. **For Example**: ```bash nmtMaskTerms = true theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ], "nmtMask": true, "nmtMaskTerms": { "Reverie Language Technologies":"Reverie Language Technologies" } }' ``` ```bash nmtMaskTerms = false theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ], "nmtMask": false }' ``` **Response** ```json nmtMaskTerms = true theme={null} { "responseList": [ { "inString": "Reverie Language Technologies was established in 2009.", "outString": "Reverie Language Technologies की स्थापना 2009 में की गई थी।", "apiStatus": 3 } ], "tokenConsumed": 102 } ``` ```json nmtMaskTerms = false theme={null} { "responseList": [ { "inString": "Reverie Language Technologies was established in 2009.", "outString": "रेवेरि भाषा प्रौद्योगिकियाँ की स्थापना 2009 में की गई थी।", "apiStatus": 3 } ], "tokenConsumed": 102 } ``` ### `filterProfane` Specify whether you want to filter out profane content from the input. Note - By default, the filterProfane=true. **For Example**: ```bash filterProfane = true theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ] "filterProfane": true }' ``` ```bash filterProfane = false theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: generic' \ --header 'REV-APPNAME: localization' \ --header 'REV-APPVERSION: 3.0' \ --data '{ "data": [ "Reverie Language Technologies was established in 2009.", "The company head office is located in Bengaluru." ] "filterProfane": false }' ``` # Sample Codes Source: https://docs.reverieinc.com/usage-guides/localization/sample-code Access Python SDK samples for seamless content localization using Reverie’s Localization API. Perfect for server-side translation tasks. Explore JavaScript SDK examples to integrate real-time localization into web applications and browser-based experiences. Find GoLang SDK samples for fast, scalable localization solutions in backend systems and APIs. # Supported Domains Source: https://docs.reverieinc.com/usage-guides/localization/supported-domains | Domain ID (For v3.0) | Domain ID (For v2.0) | Description | | -------------------- | -------------------- | ------------------------------------------------------------------------- | | generic | 0 | Default domain; localizes content regardless of specific domain. | | government | 1 | Trained for accurate localization of government terminologies. | | travel | 2 | Localizes travel industry terminologies accurately. | | ecommerce | 3 | Localizes content for the ecommerce domain. | | infotainment | 4 | Translates content for the media and entertainment domain. | | bfsi | 5 | Accurately translates banking, financial services, and insurance content. | | food | 6 | Translates grocery industry terminologies into target languages. | | education | 7 | Translates content from academic books. | | medical | 8 | Serves the healthcare industry with accurate translations. | # Supported Languages Source: https://docs.reverieinc.com/usage-guides/localization/supported-languages | Language | Language Code | | --------- | ------------- | | Hindi | hi | | English | en | | Assamese | as | | Bengali | bn | | Gujarati | gu | | Kannada | kn | | Konkani | kok | | Malayalam | ml | | Marathi | mr | | Maithili | mai | | Odia | or | | Punjabi | pa | | Tamil | ta | | Telugu | te | | Nepali | ne | | Urdu | ur | # Getting Started Source: https://docs.reverieinc.com/usage-guides/speech-to-text-batch/getting-started An introduction to getting transcription data from pre-recorded audio files. This guide will walk you through how to transcribe pre-recorded audio with the Reverie API. We provide two scenarios to try: transcribe a remote file and transcribe a local file. Before you start, you'll need to follow the steps in the [Get your API Credentials](/authentication) to obtain your API key. ## Make your first Call Make your first API Call using the cURL request. Add your own API Credentials where it says `` & `` and then run the following example in a terminal or your favorite API client. ## Step 1 : Upload the Audio File Upload the Audio File to the API. ### Request: Transcribing Audio ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: generic' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_batch' \ --header 'REV-APP-ID: ' \ --header 'subtitles: true' \ --form 'file=@""' ``` ### Response: Success ```json theme={null} { "job_id": "e21f356d-cbf9-4d62-a960-1e9da1805d19", "code": "000", "message": "Success. Request accepted" } ``` In the response, you will receive `job_id`. Please note it. ## Step 2 : Get the Status Send the `job_id` received in the Step 1 as the query parameter to know the status of the ongoing process of transcription. ### Request: Get status of the transcription ```bash theme={null} curl --location --request GET 'https://revapi.reverieinc.com/status?job_id=' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_batch' \ --header 'REV-APP-ID: ' ``` ### Response: Success ```json theme={null} { "job_id": "e21f356d-cbf9-4d62-a960-1e9da1805d19", "code": "000", "message": "Transcript ready.", "status": "completed" } ``` In the response, you will receive `status` = `completed` and `message` = `Transcript ready` once the transcription is complete. Otherwise, you will receive `status` = `applying`. ## Step 3 : Get the Transcript Once the `status` = `completed` in the Step 2, You can use the `job_id` received in the Step 1 or Step 2 as the query parameter to get the Transcript. ### Request: Get transcript of the transcription ```bash theme={null} curl --location --request GET 'https://revapi.reverieinc.com/transcript?job_id=' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_batch' \ --header 'REV-APP-ID: ' ``` ### Response: Success ```json theme={null} { "job_id": "e21f356d-cbf9-4d62-a960-1e9da1805d19", "code": "000", "message": "Transcript ready.", "result": { "transcript": "Hello. Welcome to Reverie.", "original_transcript": "HELLO. WELCOME TO REVERIE.", "channel_number": 1, "words": [ [ { "conf": 0.991683, "end": 0.21, "start": 0.09, "word": "HELLO" }, { "conf": 1.0, "end": 0.6, "start": 0.21, "word": "WELCOME" }, { "conf": 0.99723, "end": 0.72, "start": 0.6, "word": "TO" }, { "conf": 1.0, "end": 1.320315, "start": 0.72, "word": "REVERIE" } ] ], "subtitles": "1\n00:00:00,090 --> 00:00:06,900\nHELLO. WELCOME TO REVERIE.\n\n" } } ``` In this response we see: * `job_id` : A unique Identity number auto-assigned by the API for each request. * `code` : Provides a message code which can be used to look up the nature of the response returned by the API. * `message` :Provides a brief description about the response returned by the API. * `result` : An array of transcript objects including, channel\_number, transcript, list of words with start time, end time and confidence.Please check the sample response. ## SDKs Reverie has several SDKs that can make it easier to use the API. Follow these steps to use the SDK of your choice to make a Reverie Speech-to-Text request. ## Install Dependencies ```bash JavaScript theme={null} npm i @reverieit/reverie-client ``` ```bash Python theme={null} pip install reverie-sdk ``` ## Transcribe Audio from an Audio File To automatically transcribe pre-recorded audio using Reverie’s SDK, follow these steps ```javascript Javascript theme={null} const ReverieClient = require("@reverieit/reverie-client"); const reverieClient = new ReverieClient({ apiKey: "YOUR-API-KEY", appId: "YOUR-APP-ID", }); const response = await reverieClient.stt_batch({ audioFile: file, language: lang, subtitles: subtitles }); console.log("Response from API:", response); ``` ```python Python theme={null} from reverie_sdk import ReverieClient client = ReverieClient( api_key="", app_id="", ) resp = client.asr.stt_file( src_lang="en", data=open("./path/to/audio.wav", "rb").read(), ) print(resp) ``` ```go GoLang theme={null} package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "mime/multipart" "net/http" "os" ) const ( apiURL = "https://revapi.reverieinc.com/" apiKey = "your_api_key" appID = "your_app_id" appName = "stt_file" srcLang = "en" domain = "generic" audioPath = "audio.wav" ) type ApiResponse struct { DisplayText string `json:"display_text"` } func transcribeAudio(filePath string) (string, error) { file, err := os.Open(filePath) if err != nil { return "", fmt.Errorf("error opening file: %v", err) } defer file.Close() var requestBody bytes.Buffer writer := multipart.NewWriter(&requestBody) part, err := writer.CreateFormFile("audio_file", filePath) if err != nil { return "", fmt.Errorf("error creating form file: %v", err) } fileBytes, err := ioutil.ReadAll(file) if err != nil { return "", fmt.Errorf("error reading file: %v", err) } part.Write(fileBytes) writer.Close() req, err := http.NewRequest("POST", apiURL, &requestBody) if err != nil { return "", fmt.Errorf("error creating request: %v", err) } req.Header.Set("src_lang", srcLang) req.Header.Set("domain", domain) req.Header.Set("REV-API-KEY", apiKey) req.Header.Set("REV-APPNAME", appName) req.Header.Set("REV-APP-ID", appID) req.Header.Set("Content-Type", writer.FormDataContentType()) client := &http.Client{} resp, err := client.Do(req) if err != nil { return "", fmt.Errorf("error sending request: %v", err) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return "", fmt.Errorf("error reading response: %v", err) } var apiResponse ApiResponse if err := json.Unmarshal(body, &apiResponse); err != nil { return "", fmt.Errorf("error parsing JSON: %v", err) } return apiResponse.DisplayText, nil } func main() { transcription, err := transcribeAudio(audioPath) if err != nil { fmt.Println("Error:", err) return } fmt.Println("Transcription:", transcription) } ``` ## Results In order to see the results from Reverie, you must run the application. Run your application from the terminal. Your transcripts will appear in your shell. ```bash JavaScript theme={null} # Run your application using the file you created in the previous step # Example: npm start ``` ```python Python theme={null} # Run your application using the file you created in the previous step # Example: python main.py ``` ```go GoLang theme={null} // Run your application using the file you created in the previous step // Example: go run main.go ``` ## Analyzing the Response ```json theme={null} { "job_id": "e21f356d-cbf9-4d62-a960-1e9da1805d19", "code": "000", "message": "Transcript ready.", "result": { "transcript": "Hello. Welcome to Reverie.", "original_transcript": "HELLO. WELCOME TO REVERIE.", "channel_number": 1, "words": [ [ { "conf": 0.991683, "end": 0.21, "start": 0.09, "word": "HELLO" }, { "conf": 1.0, "end": 0.6, "start": 0.21, "word": "WELCOME" }, { "conf": 0.99723, "end": 0.72, "start": 0.6, "word": "TO" }, { "conf": 1.0, "end": 1.320315, "start": 0.72, "word": "REVERIE" } ] ], "subtitles": "1\n00:00:00,090 --> 00:00:06,900\nHELLO. WELCOME TO REVERIE.\n\n" } } ``` In this response we see: * `job_id` : A unique Identity number auto-assigned by the API for each request. * `code` : Provides a message code which can be used to look up the nature of the response returned by the API. * `message` :Provides a brief description about the response returned by the API. * `result` : An array of transcript objects including, channel\_number, transcript, list of words with start time, end time and confidence.Please check the sample response. # Key Features Source: https://docs.reverieinc.com/usage-guides/speech-to-text-batch/key-features ### `domain` This field identifies your use case type and set of the terminology defined for transcription. e.g. for general audio is ‘generic’. Refer to [Supporting Domain](/usage-guides/speech-to-text/supported-domains) to see the available domains. **For Example**: ```bash generic theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: generic' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_batch' \ --header 'REV-APP-ID: ' \ --form 'file=@""' ``` ```bash bfsi theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: bfsi' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_batch' \ --header 'REV-APP-ID: ' \ --form 'file=@""' ``` ### `format` The audio sampling rate and the data format of the speech. Refer to [Supporting Audio Formats](/usage-guides/speech-to-text/supported-audio-formats) to know the supporting audio formats. By default, the `format` = 16k\_int16. (WAV, Signed 16 bit, 16,000 or 16K Hz). **For Example**: ```bash format = 16k_int16 theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: generic' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_batch' \ --header 'REV-APP-ID: ' \ --header 'format: 16k_int16' \ --form 'file=@""' ``` ```bash format = wav theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: bfsi' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_batch' \ --header 'REV-APP-ID: ' \ --header 'format: wav' \ --form 'file=@""' ``` ### `subtitles` Enables subtitling from the audio file. **For Example**: ```bash subtitles = true theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: generic' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_batch' \ --header 'REV-APP-ID: ' \ --header 'subtitles: true' \ --form 'file=@""' ``` ```bash subtitles = false theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: bfsi' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_batch' \ --header 'REV-APP-ID: ' \ --header 'subtitles: false' \ --form 'file=@""' ``` **Response**: ```json subtitles = true theme={null} { "job_id": "e21f356d-cbf9-4d62-a960-1e9da1805d19", "code": "000", "message": "Transcript ready.", "result": { "transcript": "Hello. Welcome to Reverie.", "original_transcript": "HELLO. WELCOME TO REVERIE.", "channel_number": 1, "subtitles": "1\n00:00:00,090 --> 00:00:06,900\nHELLO. WELCOME TO REVERIE.\n\n" } } ``` ```json subtitles = false theme={null} { "job_id": "e21f356d-cbf9-4d62-a960-1e9da1805d19", "code": "000", "message": "Transcript ready.", "result": { "transcript": "Hello. Welcome to Reverie.", "original_transcript": "HELLO. WELCOME TO REVERIE.", "channel_number": 1, } } ``` # Sample Codes Source: https://docs.reverieinc.com/usage-guides/speech-to-text-batch/sample-code Access Python SDK samples for real-time speech transcription on GitHub {" "} Explore JavaScript SDK samples for speech-to-text streaming on GitHub Find GoLang SDK samples for speech transcription on GitHub # Getting Started Source: https://docs.reverieinc.com/usage-guides/speech-to-text-file/getting-started An introduction to getting transcription data from pre-recorded audio files. This guide will walk you through how to transcribe pre-recorded audio with the Reverie API. We provide two scenarios to try: transcribe a remote file and transcribe a local file. Before you start, you'll need to follow the steps in the [Get your API Credentials](/authentication) to obtain your API key. ## Make your first Call Make your first API Call using the cURL request. Add your own API Credentials where it says `` & `` and then run the following example in a terminal or your favorite API client. ### Step 1 : Upload the Audio File #### Request : Transcribing Audio ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'src_lang: hi' \ --header 'domain: generic' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_file' \ --header 'REV-APP-ID: ' \ --form 'audio_file=@"" ``` #### Request: Transcribing Audio other than Default Format ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'src_lang: hi' \ --header 'domain: generic' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_file' \ --header 'REV-APP-ID: ' \ --header 'format: mp3' --form 'audio_file=@""' ``` #### Response: Success ```json theme={null} { "id": "ddf4ebda44af4fdf95118af9a6f14d46fce12ed85347471d", "success": true, "final": true, "text": "नाइनटी एट पॉइंट थ्री एफएम पर प्ले करिए", "cause": "EOF received", "confidence": 0.891, "display_text": "98.3 एफएम पर प्ले करिए" } ``` #### Response: Error Message ```json theme={null} { "id": "03e4f260551345e6832bf62ba273e0096fd303e72f94453f", "success": false, "text": "", "final": true, "confidence": 1.0, "cause": "no file given", "display_text": "" } ``` ## API References ### HTTP Request URL | URL Elements | Sample URL | | ------------------- | ---------------------------------------------------------------- | | https\://(hostname) | [https://revapi.reverieinc.com/](https://revapi.reverieinc.com/) | #### Headers {" "} API key shared by the Reverie team {" "} APP ID shared by the Reverie team {" "} Value if this string should always be `stt_file` {" "} * Specify the language code.
* Example: `hi`
* Refer to section [Language Codes](/usage-guides/speech-to-text/supported-languages) for valid language code.
{" "} * This field identifies your use case type and set of the terminology defined for transcription.
* e.g. for general audio is ‘generic’
* It is only required for the first API i.e Upload File API.
{" "} * Mention the audio sample rate and file format of the uploaded file.
* Refer to section [Supported Audio Formats](/usage-guides/speech-to-text/supported-audio-formats) for valid audio format code.
* It is only required for the first API i.e Upload File API * Note: * By default, the format = `16k_int16`. (WAV, Signed 16 bit, 16,000 or 16K Hz). * It is an optional parameter.
#### Query Parameter {" "} * An audio file for which the transcript is desired. #### Response {" "} * A unique Identity number auto-assigned by the API for each request, to be used to fetch job status and transcripts. {" "} * Provides true or false based on the nature of the response returned by the API. {" "} * Provides whether the response is the final response returned by the API. {" "} * Provides the trascripted response returned by the API for the audio file. {" "} * Reason for obtaining the final output, generally due to End Of File (EOF) received. {" "} * Provides the confidence on the scale of 0 - 1 for the output. {" "} * Provides the display text for the final output based on some post processing. ## SDKs Reverie has several SDKs that can make it easier to use the API. Follow these steps to use the SDK of your choice to make a Reverie Speech-to-Text request. ## Install Dependencies ```bash JavaScript theme={null} npm i @reverieit/reverie-client ``` ```bash Python theme={null} pip install reverie-sdk ``` ## Transcribe Audio from an Audio File To automatically transcribe pre-recorded audio using Reverie’s SDK, follow these steps ```javascript Javascript theme={null} const ReverieClient = require("@reverieit/reverie-client"); const reverieClient = new ReverieClient({ apiKey: "YOUR-API-KEY", appId: "YOUR-APP-ID", }); const response = await reverieClient.stt_file({ audioFile: file, language: lang, }); console.log("Response from API:", response); ``` ```python Python theme={null} from reverie_sdk import ReverieClient client = ReverieClient( api_key="", app_id="", ) resp = client.asr.stt_file( src_lang="en", data=open("./path/to/audio.wav", "rb").read(), ) print(resp) ``` ```go GoLang theme={null} package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "mime/multipart" "net/http" "os" ) const ( apiURL = "https://revapi.reverieinc.com/" apiKey = "your_api_key" appID = "your_app_id" appName = "stt_file" srcLang = "en" domain = "generic" audioPath = "audio.wav" ) type ApiResponse struct { DisplayText string `json:"display_text"` } func transcribeAudio(filePath string) (string, error) { file, err := os.Open(filePath) if err != nil { return "", fmt.Errorf("error opening file: %v", err) } defer file.Close() var requestBody bytes.Buffer writer := multipart.NewWriter(&requestBody) part, err := writer.CreateFormFile("audio_file", filePath) if err != nil { return "", fmt.Errorf("error creating form file: %v", err) } fileBytes, err := ioutil.ReadAll(file) if err != nil { return "", fmt.Errorf("error reading file: %v", err) } part.Write(fileBytes) writer.Close() req, err := http.NewRequest("POST", apiURL, &requestBody) if err != nil { return "", fmt.Errorf("error creating request: %v", err) } req.Header.Set("src_lang", srcLang) req.Header.Set("domain", domain) req.Header.Set("REV-API-KEY", apiKey) req.Header.Set("REV-APPNAME", appName) req.Header.Set("REV-APP-ID", appID) req.Header.Set("Content-Type", writer.FormDataContentType()) client := &http.Client{} resp, err := client.Do(req) if err != nil { return "", fmt.Errorf("error sending request: %v", err) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return "", fmt.Errorf("error reading response: %v", err) } var apiResponse ApiResponse if err := json.Unmarshal(body, &apiResponse); err != nil { return "", fmt.Errorf("error parsing JSON: %v", err) } return apiResponse.DisplayText, nil } func main() { transcription, err := transcribeAudio(audioPath) if err != nil { fmt.Println("Error:", err) return } fmt.Println("Transcription:", transcription) } ``` ## Results In order to see the results from Reverie, you must run the application. Run your application from the terminal. Your transcripts will appear in your shell. ```bash JavaScript theme={null} # Run your application using the file you created in the previous step # Example: npm start ``` ```python Python theme={null} # Run your application using the file you created in the previous step # Example: python main.py ``` ```go GoLang theme={null} // Run your application using the file you created in the previous step // Example: go run main.go ``` ## Analyzing the Response ```json theme={null} { "id": "ddf4ebda44af4fdf95118af9a6f14d46fce12ed85347471d", "success": true, "final": true, "text": "नाइनटी एट पॉइंट थ्री एफएम पर प्ले करिए", "cause": "EOF received", "confidence": 0.891, "display_text": "98.3 एफएम पर प्ले करिए" } ``` In this response we see: * `id` : A unique Identity number auto-assigned by the API for each request. * `success` : Provides a message code which can be used to look up the nature of the response returned by the API. * `final` :Provides a brief description about the response returned by the API. * `text` : An array of transcript objects including, channel\_number, transcript, list of words with start time, end time and confidence.Please check the sample response. * `cause` : An array of transcript objects including, channel\_number, transcript, list of words with start time, end time and confidence.Please check the sample response. * `confidence` : An array of transcript objects including, channel\_number, transcript, list of words with start time, end time and confidence.Please check the sample response. * `display_text` : An array of transcript objects including, channel\_number, transcript, list of words with start time, end time and confidence.Please check the sample response. # Key Features Source: https://docs.reverieinc.com/usage-guides/speech-to-text-file/key-features ### `domain` This field identifies your use case type and set of the terminology defined for transcription. e.g. for general audio is ‘generic’. Refer to [Supporting Domain](/usage-guides/speech-to-text/supported-domains) to see the available domains. **For Example**: ```bash generic theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: generic' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_file' \ --header 'REV-APP-ID: ' \ --form 'file=@""' ``` ```bash bfsi theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: bfsi' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_file' \ --header 'REV-APP-ID: ' \ --form 'file=@""' ``` ### `format` The audio sampling rate and the data format of the speech. Refer to [Supporting Audio Formats](/usage-guides/speech-to-text/supported-audio-formats) to know the supporting audio formats. By default, the `format` = 16k\_int16. (WAV, Signed 16 bit, 16,000 or 16K Hz). **For Example**: ```bash format = 16k_int16 theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: generic' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_file' \ --header 'REV-APP-ID: ' \ --header 'format: 16k_int16' \ --form 'file=@""' ``` ```bash format = wav theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: bfsi' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_file' \ --header 'REV-APP-ID: ' \ --header 'format: wav' \ --form 'file=@""' ``` ### `logging` Possible Values are: 1. `true` - stores audio and keep transcripts in logs. 2. `no_audio` - does not store audios but keep transcripts in logs. 3. `no_transcript` - does not keep transcripts in logs but stores audios. 4. `false` - does not keep neither audios nor transcripts in log. Default value is `true` **For Example**: ```javascript logging = true theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: bfsi' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_file' \ --header 'REV-APP-ID: ' \ --header 'format: wav' \ --header 'logging: true' --form 'file=@""' ``` ```javascript logging = false theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: bfsi' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_file' \ --header 'REV-APP-ID: ' \ --header 'format: wav' \ --header 'logging: false' --form 'file=@""' ``` ### `punctuate` It will enable punctuation and capitalisation in the transcript. The values it can take are `true` and `false`. Supported languages are: `en`, `hi`. Default value is true **For Example**: ```javascript punctuate = true theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: bfsi' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_file' \ --header 'REV-APP-ID: ' \ --header 'format: wav' \ --header 'punctuate: true' --form 'file=@""' ``` ```javascript punctuate = false theme={null} curl --location --request POST 'https://revapi.reverieinc.com/upload' \ --header 'src_lang: hi' \ --header 'domain: bfsi' \ --header 'REV-API-KEY: ' \ --header 'REV-APPNAME: stt_file' \ --header 'REV-APP-ID: ' \ --header 'format: wav' \ --header 'punctuate: false' --form 'file=@""' ``` # Getting Started Source: https://docs.reverieinc.com/usage-guides/speech-to-text-streaming/getting-started An introduction to getting transcription data from live streaming audio in real time. In this guide, you’ll learn how to automatically transcribe live streaming audio in real time using Reverie's SDKs, which are supported for use with the Reverie API. Before you start, you'll need to follow the steps in the [Get your API Credentials](/authentication) to obtain your API key. ### Include the SDK To use Reverie's Speech-to-Text Streaming SDK, include the following CDN in your project: ```html JavaScript theme={null} ``` ```python Python theme={null} # No need to include any script ``` ### Install Dependencies ```bash JavaScript theme={null} npm i @reverieit/reverie-client ``` ```bash Python theme={null} pip install reverie_sdk[py3x] # example: # pip install reverie_sdk[py37] pip install pyaudio ``` ### Transcribe Audio from a Remote Stream The following code shows how to transcribe audio from a remote audio stream like a microphone ```javascript Javascript theme={null} const ReverieClient = require("@reverieit/reverie-client"); const reverieClient = new ReverieClient({ apiKey: "YOUR-API-KEY", appId: "YOUR-APP-ID", }); await reverieClient.init_stt({ src_lang: "hi", callback: (event) => { console.log("STT event:", event); }, element: document.getElementById("transcript"), domain: "generic" }); // Start/Stop streaming await reverieClient.start_stt(); await reverieClient.stop_stt(); ``` ```python Python theme={null} import pyaudio, asyncio from reverie_sdk import ReverieClient from reverie_sdk.services.asr import AudioStream client = ReverieClient( api_key="REVERIE_API_KEY", app_id="REVERIE_APP_ID", ) stream = AudioStream() pa = pyaudio.PyAudio() def mic_callback(in_data, frame_count, time_info, status): try: asyncio.run(stream.add_chunk_async(in_data)) except: return (None, pyaudio.paAbort) return (None, pyaudio.paContinue) async def main(): pa_stream = pa.open( rate=RATE, channels=CHANNELS, format=FORMAT, frames_per_buffer=CHUNK_SIZE, input=True, stream_callback=mic_callback, ) pa_stream.start_stream() print("listening... press ctrl+C to stop", flush=True) try: await client.asr.stt_stream_async( src_lang="en", bytes_or_stream=stream, callback=print, continuous="0", domain="generic", format="16k_int16", logging="true", punctuate="true", silence=15, timeout=15, ) except Exception as err: print(err) finally: pa_stream.stop_stream() pa_stream.close() asyncio.run(main()) pa.terminate() ``` ### Results In order to see the results from Reverie, you must run the application. Run your application from the terminal. Your transcripts will appear in your shell. ```bash JavaScript theme={null} # Run your application using the file you created in the previous step # Example: npm start ``` ```python Python theme={null} # Run your application using the file you created in the previous step # Example: python main.py ``` ### Analyzing the Response ```json theme={null} { "id": "bb261bd789af4ba487a2667f8d942d4d7e0195fd1c8e4073", "success": true, "text": "आत्म निर्भर योजना इस योजना अथवा अभियान का उद्देश्य एक सौ तीस करोड़ भारतवासियों को आत्मनिर्भर बनाना है ताकि देश का हर नागरिक संकट की इस घड़ी में कदम से कदम मिलाकर चल सके", "display_text": "आत्म निर्भर योजना इस योजना अथवा अभियान का उद्देश्य 130 करोड़ भारतवासियों को आत्मनिर्भर बनाना है ताकि देश का हर नागरिक संकट की इस घड़ी में कदम से कदम मिलाकर चल सके", "final": true, "confidence": 0.743304, "cause": "EOF received" } ``` In this response we see: * `id` : API will auto-assign assign a unique identification number for each request. * `success` : Will indicate the functional status of the API: * If the `success` = true, then the API is functioning and ready to generate output. * If the `success` = false, then the API is not functional and has some errors * `final` : Will report whether the received output is partial or final: * If the `final` = true, then the received text is the final output. * If the `final` = false, then the text received is partial and is still processing the file. * `cause` : Reason for obtaining the final output. * `text` : The streaming audio input is converted into text format in the requested language. * `confidence` : The level of confidence that Streaming STT API has in the accuracy of the transcription. * `display_text` : The beautified text of the final transcript. If the final transcript consists of digits, URL, app names, it is quickly converted to a readable format for the user. # Key Features Source: https://docs.reverieinc.com/usage-guides/speech-to-text-streaming/key-features ### `domain` The universe in which the Streaming STT API is used for transcribing the speech. Refer to [Supporting Domain](/usage-guides/speech-to-text/supported-domains) to see the available domains. **For Example**: ```javascript generic theme={null} const initGenericSTT = async () => { const config = { apikey: , appId: , language: 'hi', domain: 'generic', // <-- Generic domain eventHandler: (event) => voiceText(event), errorHandler: (error) => console.log('Generic STT Error:', error), }; await window.stt_stream.initSTT(config); }; ``` ```javascript bfsi theme={null} const initGenericSTT = async () => { const config = { apikey: , appId: , language: 'hi', domain: 'bfsi', // <-- BFSI domain eventHandler: (event) => voiceText(event), errorHandler: (error) => console.log('Generic STT Error:', error), }; await window.stt_stream.initSTT(config); }; ``` ### `timeout` The duration to keep a connection open between the application and the STT server. Note: The default timeout = 15 seconds, and the maximum time allowed = 180 seconds. **For Example**: ```javascript timeout = 15 theme={null} const initGenericSTT = async () => { const config = { apikey: , appId: , language: 'hi', domain: 'generic', timeout:15, // <-- timeout = 15 seconds eventHandler: (event) => voiceText(event), errorHandler: (error) => console.log('Generic STT Error:', error), }; await window.stt_stream.initSTT(config); }; ``` ```javascript timeout = 180 theme={null} const initGenericSTT = async () => { const config = { apikey: , appId: , language: 'hi', domain: 'generic', timeout:180, // <-- timeout = 180 seconds eventHandler: (event) => voiceText(event), errorHandler: (error) => console.log('Generic STT Error:', error), }; await window.stt_stream.initSTT(config); }; ``` ### `silence` The time to determine when to end the connection automatically after detecting the silence after receiving the speech data. For Example: Consider `silence` = 15 seconds i.e., On passing the speech for 60 seconds, and if you remain silent, the connection will be open for the next 15 seconds and then will automatically get disconnected. Note: The default `silence`= 1 second, and the maximum `silence` = 30 seconds. **For Example**: ```javascript silence = 1 theme={null} const initGenericSTT = async () => { const config = { apikey: , appId: , language: 'hi', domain: 'generic', silence:1, // <-- silence = 1 seconds eventHandler: (event) => voiceText(event), errorHandler: (error) => console.log('Generic STT Error:', error), }; await window.stt_stream.initSTT(config); }; ``` ```javascript silence = 30 theme={null} const initGenericSTT = async () => { const config = { apikey: , appId: , language: 'hi', domain: 'generic', silence:30, // <-- silence = 30 seconds eventHandler: (event) => voiceText(event), errorHandler: (error) => console.log('Generic STT Error:', error), }; await window.stt_stream.initSTT(config); }; ``` ### `format` The audio sampling rate and the data format of the speech. Refer to [Supporting Audio Formats](/usage-guides/speech-to-text/supported-audio-formats) to know the supporting audio formats. By default, the `format` = 16k\_int16. (WAV, Signed 16 bit, 16,000 or 16K Hz). **For Example**: ```javascript format = 16k_int16 theme={null} const initGenericSTT = async () => { const config = { apikey: , appId: , language: 'hi', domain: 'generic', format:"16k_int16", // <-- format = 16k_int16 eventHandler: (event) => voiceText(event), errorHandler: (error) => console.log('Generic STT Error:', error), }; await window.stt_stream.initSTT(config); }; ``` ```javascript format = wav theme={null} const initGenericSTT = async () => { const config = { apikey: , appId: , language: 'hi', domain: 'generic', format: "wav", // <-- format = wav eventHandler: (event) => voiceText(event), errorHandler: (error) => console.log('Generic STT Error:', error), }; await window.stt_stream.initSTT(config); }; ``` ### `logging` Possible Values are: 1. `true` - stores audio and keep transcripts in logs. 2. `no_audio` - does not store audios but keep transcripts in logs. 3. `no_transcript` - does not keep transcripts in logs but stores audios. 4. `false` - does not keep neither audios nor transcripts in log. Default value is `true` **For Example**: ```javascript logging = true theme={null} const initGenericSTT = async () => { const config = { apikey: , appId: , language: 'hi', logging: true, // <-- logging = true eventHandler: (event) => voiceText(event), errorHandler: (error) => console.log('Generic STT Error:', error), }; await window.stt_stream.initSTT(config); }; ``` ```javascript logging = false theme={null} const initGenericSTT = async () => { const config = { apikey: , appId: , language: 'hi', logging: false, // <-- logging = false eventHandler: (event) => voiceText(event), errorHandler: (error) => console.log('Generic STT Error:', error), }; await window.stt_stream.initSTT(config); }; ``` ### `punctuate` It will enable punctuation and capitalisation in the transcript. The values it can take are `true` and `false`. Supported languages are: `en`, `hi`. Default value is true **For Example**: ```javascript punctuate = true theme={null} const initGenericSTT = async () => { const config = { apikey: , appId: , language: 'hi', punctuate: true, // <-- punctuate = true eventHandler: (event) => voiceText(event), errorHandler: (error) => console.log('Generic STT Error:', error), }; await window.stt_stream.initSTT(config); }; ``` ```javascript punctuate = false theme={null} const initGenericSTT = async () => { const config = { apikey: , appId: , language: 'hi', punctuate: false, // <-- punctuate = false eventHandler: (event) => voiceText(event), errorHandler: (error) => console.log('Generic STT Error:', error), }; await window.stt_stream.initSTT(config); }; ``` ### `continuous` It will enable continuous decoding even after silence is detected. Can take value `true`/`1` or `false`/`0`. Default value is `false`/`0` **For Example**: ```javascript continuous = true theme={null} const initGenericSTT = async () => { const config = { apikey: , appId: , language: 'hi', continuous: true, // <-- continuous = true eventHandler: (event) => voiceText(event), errorHandler: (error) => console.log('Generic STT Error:', error), }; await window.stt_stream.initSTT(config); }; ``` ```javascript continuous = false theme={null} const initGenericSTT = async () => { const config = { apikey: , appId: , language: 'hi', continuous: false, // <-- continuous = false eventHandler: (event) => voiceText(event), errorHandler: (error) => console.log('Generic STT Error:', error), }; await window.stt_stream.initSTT(config); }; ``` # Sample Codes Source: https://docs.reverieinc.com/usage-guides/speech-to-text-streaming/sample-code Access Python SDK samples for real-time speech transcription on GitHub {" "} Explore JavaScript SDK samples for speech-to-text streaming on GitHub # Supported Audio Formats Source: https://docs.reverieinc.com/usage-guides/speech-to-text/supported-audio-formats The Speech-to-Text solution supports various audio formats for flexible integration: | Audio Format | Description | | ------------ | ---------------------------------------------------------------- | | 16k\_int16 | Default format: Signed 16-bit, 16KHz sampling rate in WAV format | | 16k\_uint8 | Unsigned 8-bit, 16KHz sampling rate in WAV format | | 8k\_int16 | Signed 16-bit, 8KHz sampling rate in WAV format | | 8k\_uint8 | Unsigned 8-bit, 8KHz sampling rate in WAV format | | opus\_16k | Opus-encoded audio frames, 16KHz sampling rate | | opus\_8k | Opus-encoded audio frames, 8KHz sampling rate | | ogg\_opus | Opus-encoded audio frames in Ogg container | | 16k\_ulaw | µ-Law audio frames, 16KHz sampling rate | | 8k\_ulaw | µ-Law audio frames, 8KHz sampling rate | # Supported Domains Source: https://docs.reverieinc.com/usage-guides/speech-to-text/supported-domains | Domain | Description | | ------------ | ---------------------------------------------------------------- | | generic | Trained to transcribe speech across industries. | | bfsi | Optimized for banking and financial terminologies. | | ecomm | Tailored for E-commerce and FMCG-specific terms. | | healthcare | Specialized in medical and healthcare terminology. | | voice-search | Handles voice commands with smart formatting for search. | | alphanumeric | Accurately transcribes mixed letters and numbers. | | names | Trained to recognize and transcribe person names. | | address | Optimized for transcribing address details. | | language | Supports regional language variants (e.g., 'Bengali', 'Bangla'). | | yes-no | Recognizes diverse yes/no responses (e.g., 'Haan', 'Yes'). | | email | Precisely transcribes email addresses. | # Supported Languages Source: https://docs.reverieinc.com/usage-guides/speech-to-text/supported-languages The Speech-to-Text solution supports transcription in multiple languages, tailored for diverse regional and linguistic needs: * `en` - Indian English * `hi` - Hindi * `hi_en` - Hinglish * `bn` - Bengali * `gu` - Gujarati * `kn` - Kannada * `ml` - Malayalam * `mr` - Marathi * `pa` - Punjabi * `ta` - Tamil * `te` - Telugu * `as` - Assamese * `or` - Odia * `te_en` - Telgish * `ta_en` - Tamlish * `ml_en` - Malayalish * `kn_en` - Kannada + English * `mr_en` - Marathi + English # Getting Started Source: https://docs.reverieinc.com/usage-guides/text-to-speech/getting-started Reverie's TTS (Text-to-Speech) is a solution that turns text into lifelike speech, allowing you to create applications that talk in multiple Indic languages and build comprehensive speech-enabled products. In this guide, you’ll learn how to automatically transcribe live streaming audio in real time using Reverie's SDKs, which are supported for use with the Reverie API. Before you start, you'll need to follow the steps in the [Get your API Credentials](/authentication) to obtain your API KEY & APP ID. ### Make your first Call Make your first API Call using the cURL request. Add your own API Credentials where it says `` & `` and then run the following example in a terminal or your favorite API client. ```bash cURL theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'REV-APPNAME: tts' \ --header 'speaker: hi_female' \ --header 'Content-Type: application/json' \ --data-raw '{ "text": "किसान होंगे आत्मनिर्भर, समृद्ध भारत" }' ``` By default, the API will return the `WAV` audio file with a sampling rate of `22.05KHz`. The audio file will contain the voice of the selected model saying the words that you sent in your request. ### SDKs Reverie has several SDKs that can make it easier to use the API. Follow these steps to use the SDK of your choice to make a Reverie TTS request. ### Install Dependencies ```bash JavaScript theme={null} npm i @reverieit/reverie-client ``` ```bash Python theme={null} pip install reverie-sdk ``` ### Generate audio from text The following code shows how to generate Speech from the Text provided . ```javascript Javascript theme={null} const ReverieClient = require("@reverieit/reverie-client"); const reverieClient = new ReverieClient({ apiKey: "YOUR-API-KEY", appId: "YOUR-APP-ID", }); try { const audioBlob = await reverieClient.text_to_speech({ text: text, speaker: speaker, speed: speed, pitch: pitch, }); const audioUrl = URL.createObjectURL(audioBlob); console.log("Audio URL is:", audioUrl); } catch (error) { console.error("Error:", error); } ``` ```python Python theme={null} from reverie_sdk import ReverieClient client = ReverieClient( api_key="MY_API_KEY", app_id="MY_APP_ID", ) with open("./big_text.txt", encoding="utf-8") as f: text = f.read() for resp_idx, resp in enumerate( client.tts.tts_streaming( text=text, speaker="en_male", max_words_per_chunk=5, fast_sentence_fragment=False, ) ): print(f"{resp_idx:08d} {resp.duration:10.3f}") resp.save_audio( f".path/to/output/{resp_idx:08d}.wav", create_parents=True, overwrite_existing=True, ) ``` ```go Go theme={null} package main import ( "bytes" "fmt" "io" "net/http" "os" ) func sendRequest(payload string, filename string) { url := "https://revapi.reverieinc.com/" req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(payload))) if err != nil { fmt.Println("Request creation error:", err) return } // Set Headers req.Header.Set("REV-API-KEY", "") req.Header.Set("REV-APP-ID", "") req.Header.Set("REV-APPNAME", "tts") req.Header.Set("speaker", "hi_female") //Set Speaker req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Request error:", err) return } defer resp.Body.Close() // Create a file to save the response file, err := os.Create(filename) if err != nil { fmt.Println("File creation error:", err) return } defer file.Close() // Copy response body to file _, err = io.Copy(file, resp.Body) if err != nil { fmt.Println("File write error:", err) return } fmt.Println("Audio saved as", filename) } func main() { // Request 1: Plain text TTS payload1 := `{ "text": ["भारत मेरा देश है।", "मेरी कंपनी का नाम रेवेरी लैंग्वेज टेक्नोलॉजीज है।"], "speed": 1, "pitch": 0, "format": "WAV" }` sendRequest(payload1, "output1.wav") // Request 2: SSML-based TTS payload2 := `{ "ssml": " Hello. ", "speed": 1, "pitch": 0, "format": "mp3" }` sendRequest(payload2, "output2.mp3") } ``` ### Results In order to see the results from Reverie, you must run the application. Run your application from the terminal. Your transcripts will appear in your shell. ```bash JavaScript theme={null} # Run your application using the file you created in the previous step # Example: npm start ``` ```python Python theme={null} # Run your application using the file you created in the previous step # Example: python main.py ``` ```go GoLang theme={null} // Run your application using the file you created in the previous step // Example: go run main.go ``` ### Analyzing the Response Reverie Dashboard ​By default, the Reverie Text-to-Speech (TTS) API returns audio in the `WAV` format with a sampling rate of `22.05 kHz (22,050 Hz)`. This sampling rate is commonly used in speech synthesis, offering a balance between audio quality and file size. You may play it to listen to the synthesized speech output and evaluate its clarity, naturalness, and suitability for your application. # Key Features Source: https://docs.reverieinc.com/usage-guides/text-to-speech/key-features ### `ssml` Tags The SSML input to synthesize an audio output. If you want to follow W3 standards, the ssml field must be used and not the text field. Refer [here](/usage-guides/text-to-speech/ssml-tags) to know more about SSML Inputs. | SSML Tag | Description | | ----------- | ------------------------------------------------------------------------------- | | `` | Controls the pitch, rate, and volume of speech. | | `` | Defines how the enclosed text should be spoken (e.g., as a number, date, etc.). | | `` | Substitutes one word or phrase for another when speaking. | | `` | Adds a pause in speech for a specified duration. | | `

` | Indicates a paragraph break, resulting in a pause. | | `` | Represents a sentence break, adding a pause. | | `` | The root tag that defines the speech content. | | `` | Specifies which voice to use for speech (e.g., male, female). | ### `speed` The speech rate of the audio file. Allows values: from 0.5 (slowest speed rate) up to 1.5 (fastest speed rate). Note: By default, speed = 1 (normal speed). **For Example**: ```bash cURL theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'REV-APPNAME: tts' \ --header 'speaker: hi_female' \ --header 'Content-Type: application/json' \ --data-raw '{ "text": ["भारत मेरा देश है। मेरी कंपनी का नाम रेवेरी लैंग्वेज टेक्नोलॉजीज है।" ], "speed": 1, }' ``` ```` ### `pitch` Speaking pitch, in the range Allows values: from -3 up tp 3. 3 indicates an increase of 3 semitones from the original pitch. -3 indicates a decrease of 3 semitones from the original pitch. Note: By default, the pitch = 0 (zero) **For Example**: ```bash cURL curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'REV-APPNAME: tts' \ --header 'speaker: hi_female' \ --header 'Content-Type: application/json' \ --data-raw '{ "text": ["भारत मेरा देश है। मेरी कंपनी का नाम रेवेरी लैंग्वेज टेक्नोलॉजीज है।" ], "pitch": -3, }' ```` ### `sample_rate` The sampling rate (in hertz) to synthesize the audio output. Refer to [Supporting Sampling Rate](/usage-guides/text-to-speech/supported-sampling-rates), to know the supporting audio sample rates. Note: By default, the sample\_rate = 22050 Hz (22.05kHz) **For Example**: ```bash cURL theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'REV-APPNAME: tts' \ --header 'speaker: hi_female' \ --header 'Content-Type: application/json' \ --data-raw '{ "text": ["भारत मेरा देश है। मेरी कंपनी का नाम रेवेरी लैंग्वेज टेक्नोलॉजीज है।" ], "sample_rate": 22050, }' ``` ### `format` The speech audio format to generate the audio file. Refer to [Supporting Audio Formats](/usage-guides/text-to-speech/supported-audio-formats), to know the supporting audio formats. Note: By default, the format = WAV **For Example**: ```bash cURL theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'REV-APPNAME: tts' \ --header 'speaker: hi_female' \ --header 'Content-Type: application/json' \ --data-raw '{ "text": ["भारत मेरा देश है। मेरी कंपनी का नाम रेवेरी लैंग्वेज टेक्नोलॉजीज है।" ], "format": wav, }' ``` # Sample Codes Source: https://docs.reverieinc.com/usage-guides/text-to-speech/sample-code Access Python SDK samples for generating lifelike speech using Reverie’s TTS API. Ideal for server-side TTS processing and automation. {" "} Explore JavaScript SDK examples to integrate real-time Text-to-Speech directly into web applications and browser-based experiences. Find GoLang SDK samples to implement fast and scalable TTS solutions for backend systems and APIs. # SSML Tags Source: https://docs.reverieinc.com/usage-guides/text-to-speech/ssml-tags ## SSML Tags for Text-to-Speech Customization SSML (Speech Synthesis Markup Language) tags allow you to customize how a text-to-speech engine generates audio. SSML gives you precise control over speech characteristics like pauses, pitch, speed, and pronunciation, enabling natural and context-appropriate audio output. Reverie’s TTS API supports SSML to structure text, switch voices, and customize pronunciation for various formats like dates, currencies, and units. ## Core SSML Tags ### `` and `` The root element for any SSML document. Surround all text to be spoken with this tag.\ **Note**: The `` tag is mandatory. Encapsulates text and other tags, specifying the voice to use via the `name` attribute. Supports multiple voices in a single request. `

` represents a Paragraph. Use the tag to add a pause between paragraphs in the text. **Note**: By default, the API will separate the paragraphs by 800ms break. ` ` represents a Sentence. Use the tag to add a pause between lines or sentences in the text. **Note**: By default, the API will separate the sentences within a paragraph by a 400ms break. Recommend using the `

` and `` tags to structure your requests, especially when using ``. For `` Tag: ```xml theme={null}

This is a sentence

``` For `` Tag: ```xml theme={null} This is an example. यह एक उदाहरण है ``` ### `` It represents a pause in the speech. Set the length of the pause with the time attribute. Add pause of a specified duration, either in seconds or milliseconds. `` is currently not supported within a sentence. It can only exist before or between sentences or paragraphs. | Attribute | Description | | ---------- | ------------------------------------------------------------------------------------------------------------ | | `strength` | (Optional) Strength of the pause inserted. Values: `none`, `x-weak`, `weak`, `medium`, `strong`, `x-strong`. | | `time` | (Optional) Duration of the pause, e.g., `"1s"`, `"750ms"`. Unit must be specified. Default: `"400ms"`. | ```xml theme={null} Fetching results Found 3 items ``` ### `` Pronounce the specified word or phrase as a different word or phrase. Specify the pronunciation to substitute with the alias attribute. | Attribute | Description | | --------- | ------------------------------------------------------- | | `alias` | The word or phrase to speak in place of the tagged text | ```xml theme={null} www ``` ### `` The `` tag will allow you to provide instructions for how to speak a text file. The TTS engine will automatically detect many of these features, but the say-as command will enable you to mark them specifically. Use the `` tag with the interpret-as attribute to tell the TTS how to speak certain characters, words, and numbers. | Attribute | Description | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | | `interpret-as` | Uses some available possibility values to speak the given text. In the below section, we provide you the values available interpret-as | ```xml theme={null} www ``` #### `Cardinal` Interprets the numerical text as a cardinal number, as in 1,2,3,4 By default, the API will understand and pronounce the numbers in Cardinal format. **Example**: The API will interpret 1234 as One thousand two hundred and thirty-four. ```xml theme={null} 1234 ``` #### `Ordinal` This value will interpret and speak the ordinal value for the given digit within the enclosed tag. | Value | Interpret Ordinal Value | | ----- | ----------------------- | | 44 | Forty-Fourth | | 2 | Second | ```xml theme={null} 2 ``` #### `Character` This value will speak the characters in a given text within the enclosed tag. | Value | Interpret Ordinal Value | | ----- | -------------------------------------------- | | HELLO | API will pronounce each character separately | | 50WS | Five Zero W S | ```xml theme={null} 50WS ``` #### `Digits` This value spells out the digits in a given number within the enclosed tag. | Value | Interpret Digits | | ----- | ------------------ | | 44 | Four Four | | 1234 | One Two Three Four | ```xml theme={null} 1234 ``` #### `Units` Interpret a value as a measurement. The value should be a number followed by a unit or just a unit. The units supported by the TTS API are: | Units | Interpreted as | | ------------------- | -------------- | | kgs, kg | kilograms | | gms, gm, g | grams | | mgs, mg | milligrams | | kms, km | kilometers | | cms, cm | centimeters | | mtr, m | meters | | mm | millimeters | | ltrs, ltr, lt, l, ℓ | liters | | ft | feet | | in | inches | | lbs, lb | pounds | | hrs, hr | hours | | min | minutes | | sec, s | seconds | ```xml theme={null} 5l of oil is added to your cart. ``` #### `Date` This value will speak the enclosed tag’s date, using the format given in the associated format attribute. The format attribute is mandatory for use with the date value of interpret-as. | | Denoted as | Digit Length | | ----- | ---------- | ------------- | | Date | d | 1 or 2 digits | | Month | m | 1 or 2 digits | | Year | y | 4 digits | **Supported Date Formats:** | Date Format | Interpret Date | | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `dmy` | **day-month-year**
Example: 10-02-1990 is read as Tenth February, Nineteen Ninety
Sample Code:
`10-2-1990` | | `mdy` | **month-day-year**
Example: 02-10-1990 is read as Tenth February, Nineteen Ninety
Sample Code:
`2-10` | | `dm` | **day-month**
Example: 10-2 is read as Tenth February
Sample Code:
`10-2` | | `md` | **month-day**
Example: 02-10 is read as Tenth February
Sample Code:
`2-10` | #### `Currency` Use the currency parameter to control the synthesis of monetary quantities. The currency formats supported and spoken by the API is: | Currency | Symbol | API Interpretation | | --------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------ | | Rupee & Paisa | `₹, Rs., र` | Example: `₹`10.50 is read as Ten rupees fifty paise.
Sample Code: ``₹10.50`` | | Dollars & Cents | `$` | Example: `$`10.50 is read as Ten dollars fifty cents.
Sample Code: ``\$10.50`` | | Pounds & Pence | `£` | Example: `£`10.50 is read as Ten pounds fifty pence.
Sample Code: ``£10.50`` | | Euros & Cents | `€` | Example: `€`10.50 is read as Ten euros fifty cents.
Sample Code: ``€10.50`` | #### `URL` This value is used to control the synthesis of the website address. By default, the API will interpret the website address and speak in the right format. The API will pronounce symbols as present in a web address. **Example**: reverieinc.com is pronounced as reverieinc dot com ```xml theme={null} reverieinc.com ``` ### `` The prosody element can be used to adjust the below-listed attributes for the text-to-speech output. | Attribute | Description | | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `pitch` | (optional) Changes the pitch (frequency) of the enclosed text overall.
Values:
Absolute or relative values in Hertz (Hz). e.g. 350Hz, +20Hz, -10Hz.
Relative values in semitones (st). e.g. +1st, -0.5st.
Absolute or relative values in percentage. e.g. 90%, +10%, -5%.
Labels: default, x-low, low, medium, high, x-high. | | `rate` | (optional) Changes the rate of speaking of the enclosed text overall.
Values:
Number as a factor. 1.0 being default. e.g. 0.75, 1.2.
Absolute or relative values in percentage. e.g. 90%, +20%, -10%.
Labels: default, x-slow, slow, medium, fast, x-fast. | | `duration` | (optional) Elapsed time of the enclosed text overall. overrides rate.
Values:
Number with unit (seconds or milliseconds). e.g. 2.5s, 3500ms. | | `volume` | (optional) Changes the loudness of the enclosed text overall.
Values:
Absolute or relative number, 100 being default. e.g. 80, 120, +5, -10.
Absolute or relative values in percentage. e.g. 90%, +20%, -10%.
Relative values in decibels (dB). e.g. +6dB, -6dB.
Labels: default, silent, x-soft, soft, medium, loud, x-loud. | | `contour` | (optional) Changes the pitch at various points as the utterance progresses.
Expressed as a space-separated array of parameter pairs. The first value denotes the location in text as a percentage. The second value denotes the desired pitch. See pitch attribute for possible value expressions.
e.g. ``
Note: This option is available for English and Hindi only. But the request will not fail if this option is used for other languages. It will just not have the intended effect. | | `range` | (optional) Changes the range of pitch variation of the enclosed text. Range refers to the difference between min and max pitch. Refer pitch attribute for possible value expressions.
Note: This option is available for English and Hindi only. But the request will not fail if this option is used for other languages. It will just not have the intended effect. | ```xml theme={null} ``` # Supported Audio Formats Source: https://docs.reverieinc.com/usage-guides/text-to-speech/supported-audio-formats | Audio Format | Description | | ------------ | -------------------- | | **WAV** | Default audio format | | **MP3** | | | **FLAC** | | | **OGG** | | | **OPUS** | | | **PCM** | | # Supported Sampling Rates Source: https://docs.reverieinc.com/usage-guides/text-to-speech/supported-sampling-rates | Sample Rate (Hz) | Description | | -------------------- | ------------------- | | **8000 (8kHz)** | | | **16000 (16kHz)** | | | **22050 (22.05kHz)** | Default sample rate | | **24000 (24kHz)** | | | **44100 (44.1kHz)** | | | **48000 (48kHz)** | | # Speakers Source: https://docs.reverieinc.com/usage-guides/text-to-speech/supported-speakers | Language | Male Speaker | Female Speaker | | -------------- | ----------------------------------------------- | ---------------------------------------- | | Hindi | hi\_male, hi\_male\_2, hi\_male\_3, hi\_male\_4 | hi\_female, hi\_female\_2, hi\_female\_3 | | Bengali | bn\_male, bn\_male\_2 | bn\_female, bn\_female\_2 | | Kannada | kn\_male, kn\_male\_2 | kn\_female, kn\_female\_2 | | Malayalam | ml\_male | ml\_female | | Tamil | ta\_male | ta\_female | | Telugu | te\_male, te\_male\_2 | te\_female, te\_female\_2 | | Gujarati | gu\_male | gu\_female | | Odia | or\_male | or\_female | | Assamese | as\_male | as\_female | | Marathi | mr\_male, mr\_male\_2, mr\_male\_3 | mr\_female, mr\_female\_2, mr\_female\_3 | | Punjabi | pa\_male | pa\_female | | Indian English | en\_male, en\_male\_2 | en\_female, en\_female\_2 | # Getting Started Source: https://docs.reverieinc.com/usage-guides/transliteration/getting-started The Transliteration API is a REST API used to transliterate the content from English to Indic languages and vice-versa. In this guide, you’ll learn how to automatically transcribe live streaming audio in real time using Reverie's SDKs, which are supported for use with the Reverie API. Before you start, you'll need to follow the steps in the [Get your API Credentials](/authentication) to obtain your API KEY & APP ID. ### Make your first Call Make your first API Call using the cURL request. Add your own API Credentials where it says `` & `` and then run the following example in a terminal or your favorite API client. ```bash theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'cnt_lang: en' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["Reverie Language Technologies ltd website address is www.reverieinc.com"], }' ``` By default, The API will return the strings in the target language. ### SDKs Reverie has several SDKs that can make it easier to use the API. Follow these steps to use the SDK of your choice to make a Reverie Transliteration request. ### Install Dependencies ```bash JavaScript theme={null} npm i @reverieit/reverie-client ``` ```bash Python theme={null} pip install reverie-sdk ``` ### Transliterate Text to your preferred language The following code shows how to convert the text to your preferred language. ```javascript JavaScript theme={null} const ReverieClient = require("@reverieit/reverie-client"); const reverieClient = new ReverieClient({ apiKey: "YOUR-API-KEY", appId: "YOUR-APP-ID", }); async function transliterateText() { const translation = await reverieClient.transliterate({ text: "Namaste", src_lang: "en", tgt_lang: "ta", }); console.log(translation); } transliterateText(); ``` ```python Python theme={null} from reverie_sdk import ReverieClient client = ReverieClient( api_key="MY_API_KEY", app_id="MY_APP_ID", ) res = client.t13n.transliteration( data=[ "Reverie Language Technologies is located in Bengaluru ", "The address is Jio Avana, Bellandur, Bengaluru -560102", "The website address is www.reverieinc.com.", ], src_lang="en", cnt_lang="en", tgt_lang="hi", noOfSuggestions=2, ) print(res) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "log" "net/http" ) const ( apiURL = "https://revapi.reverieinc.com/" apiKey = "" appID = "" ) type RequestBody struct { Data []string `json:"data"` IsBulk bool `json:"isBulk"` IgnoreTaggedEntities bool `json:"ignoreTaggedEntities"` } type APIResponse struct { ResponseList []struct { APIStatus int `json:"apiStatus"` InString string `json:"inString"` OutString []string `json:"outString"` } `json:"responseList"` } func main() { text := "Reverie Language Technologies ltd website address is www.reverieinc.com" requestBody := map[string]interface{}{ "data": []string{text}, "isBulk": false, "ignoreTaggedEntities": false, } jsonData, err := json.Marshal(requestBody) if err != nil { log.Fatalf("Error marshaling JSON: %v", err) } req, err := http.NewRequest("POST", apiURL, bytes.NewBuffer(jsonData)) if err != nil { log.Fatalf("Error creating request: %v", err) } req.Header.Set("Content-Type", "application/json") req.Header.Set("REV-API-KEY", apiKey) req.Header.Set("REV-APP-ID", appID) req.Header.Set("src_lang", "en") req.Header.Set("tgt_lang", "hi") req.Header.Set("domain", "1") req.Header.Set("cnt_lang", "en") req.Header.Set("REV-APPNAME", "transliteration") client := &http.Client{} resp, err := client.Do(req) if err != nil { log.Fatalf("Error making request: %v", err) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatalf("Error reading response body: %v", err) } var apiResponse APIResponse err = json.Unmarshal(body, &apiResponse) if err != nil { log.Fatalf("Error unmarshaling response: %v", err) } if len(apiResponse.ResponseList) > 0 && len(apiResponse.ResponseList[0].OutString) > 0 { fmt.Println("Transliterated text:", apiResponse.ResponseList[0].OutString[0]) } else { fmt.Println("No response from API") } } ``` ### Results In order to see the results from Reverie, you must run the application. Run your application from the terminal. Your transcripts will appear in your shell. ```bash JavaScript theme={null} # Run your application using the file you created in the previous step # Example: npm start ``` ```python Python theme={null} # Run your application using the file you created in the previous step # Example: python main.py ``` ```go GoLang theme={null} // Run your application using the file you created in the previous step // Example: go run main.go ``` ### Analyzing the Response The API returns a `responseList`, which is an array containing the transliterated content. Each item includes the `inString`, representing the original text in the source script, and the corresponding `outString`, which is the result of converting that text into the target script. Additionally, the response includes an `api_status` field, where a value of `2` indicates a successful transaction. # Key Features Source: https://docs.reverieinc.com/usage-guides/transliteration/key-features ### `domain` The Domain refers to the universe in which you use the Transliteration API. Example- Health Care, Insurance, Legal, etc. Refer to [Supporting Domain](/usage-guides/transliteration/supported-domains) to see the available domains. **For Example**: ```bash generic theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'cnt_lang: en' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["Reverie Language Technologies ltd website address is www.reverieinc.com"], }' ``` ```bash bfsi theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 6' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["Reverie Language Technologies ltd website address is www.reverieinc.com"], }' ``` ### `cnt_lang` The language of the words in the input text. Example -“data”: “Singh Sahab aap Kahan the.” In the example above, the Hindi language words are written in the English language script (Roman Script). So cnt\_lang = “hi” This is an optional parameter. If no value is provided, by default the value is the same as src\_lang. **For Example**: ```bash cnt_lang = en theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'cnt_lang: en' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["Reverie Language Technologies ltd website address is www.reverieinc.com"], }' ``` ### `isBulk` Specify whether the API should initially search in the Exception DB to transliterate the input text. Note: By default, the isBulk= true and will not search in the Exception DB. **For Example**: ```bash isBulk = true theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["Reverie Language Technologies ltd website address is www.reverieinc.com"], "isBulk" :true, }' ``` ```bash isBulk = false theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["Reverie Language Technologies ltd website address is www.reverieinc.com"], "isBulk" :false, }' ``` ### `noOfSuggestions` Mention the number of transliteration suggestions the API should return for the input text. Note: By default, the noOfSuggestions = 1, means the API will return only one transliteration suggestion for the input string. **For Example**: ```bash noOfSuggestions = 1 theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["Rama"], "noOfSuggestions" :1, }' ``` ```bash noOfSuggestions = 2 theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["Rama"], "noOfSuggestions" :2, }' ``` **Response** ```json noOfSuggestions = 1 theme={null} { "responseList": [ { "inString": "Rama", "outString": [ "रामा" ], "status": 2 } ] } ``` ```json noOfSuggestions = 2 theme={null} { "responseList": [ { "inString": "Rama", "outString": [ "रामा", "रमा" ], "status": 2 } ] } ``` ### `abbreviate` The abbreviate will Validate whether any Abbreviations/ Acronyms are passed in the input text and will transliterate it accurately. Note - By default, the abbreviate = true. Note - if the value is false, the API will consider the abbreviation as a word and transliterate it to the nearest available word. Note - In the input text, pass the abbreviations in upper case. **For Example**: ```bash abbreviate = true theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["Rama"], "abbreviate" :true, }' ``` ```bash abbreviate = false theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["Rama"], "abbreviate" :false, }' ``` ### `convertNumber` Specify whether to convert the numbers in the input text to the target language script based on the value type. * Three types of values for this parameter: * local: This value can convert the input number to the target language script.\ Example: | Source String | Target String | | ------------- | ------------- | | 2020.04 | २०२०.०४ | * words: This value can convert numbers into words with respect to the target language.\ Example: | Source String | Target String | | ------------- | ------------- | | 505 | पांच सौ पांच | * roman: This value can convert Roman numbers to English numbers.\ Example: * If the user types `sector V` in English, the transliteration would be `सेक्टर 5` in Hindi. * `Block II` will be transliterated as `ब्लॉक 2`. **For Example**: ```bash convertNumber = local theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["2020.04"], "convertNumber" : "local", }' ``` ```bash convertNumber = words theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["505"], "convertNumber" : "words", }' ``` ```bash convertNumber = roman theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["sector V"], "convertNumber" : "roman", }' ``` **Response** ```json convertNumber = local theme={null} { "responseList": [ { "inString": "2020.04", "outString": [ "२०२०.०४" ], "status": 2 } ] } ``` ```json convertNumber = words theme={null} { "responseList": [ { "inString": "505", "outString": [ "पांच सौ पांच" ], "status": 2 } ] } ``` ```json convertNumber = roman theme={null} { "responseList": [ { "inString": "sector V", "outString": [ "सेक्टर 5" ], "status": 2 } ] } ``` ### `ignoreTaggedEntities` Specify whether you want to retain the entities like email ID and URL in the input script. Note: By default, the ignoreTaggedEntities = true and will transliterate the email ID and URL into the target language script. **For Example**: ```bash ignoreTaggedEntities = true theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["Check product details in www.reverieinc.com"], "ignoreTaggedEntities" :true, }' ``` ```bash ignoreTaggedEntities = false theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["Check product details in www.reverieinc.com"], "ignoreTaggedEntities" :false, }' ``` **Response** ```json ignoreTaggedEntities = true theme={null} { "responseList": [ { "inString": "Check product details in www.reverieinc.com", "outString": [ "चेक प्रोडक्ट डिटेल्स इन डब्ल्युडब्ल्युडब्ल्यु.रेवरीइंक.कॉम" ], "status": 2 } ] } ``` ```json ignoreTaggedEntities = false theme={null} { "responseList": [ { "inString": "Check product details in www.reverieinc.com", "outString": [ "चेक प्रोडक्ट डिटेल्स इन www.reverieinc.com" ], "status": 2 } ] } ``` ### `convertOrdinal` This is used for transliterating ordinal values to English numbers. Note - Default value = False **For Example**: ```bash convertOrdinal = true theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["15th Main"], "convertOrdinal" :true, }' ``` ```bash convertOrdinal = false theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["15th Main"], "convertOrdinal" :false, }' ``` **Response** ```json convertOrdinal = true theme={null} { "responseList": [ { "inString": "15th Main", "outString": [ "15 मेन" ], "status": 2 } ] } ``` ```json convertOrdinal = false theme={null} { "responseList": [ { "inString": "15th Main", "outString": [ "फिफ्टीन्थ मेन" ], "status": 2 } ] } ``` ### `abbreviationWithoutDot` This is used to produce the abbreviation output without a dot. Note - Default value = False **For Example**: ```bash abbreviationWithoutDot = true theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["SMS"], "abbreviationWithoutDot" :true, }' ``` ```bash abbreviationWithoutDot = false theme={null} curl --location --request POST 'https://revapi.reverieinc.com/' \ --header 'Content-Type: application/json' \ --header 'REV-API-KEY: ' \ --header 'REV-APP-ID: ' \ --header 'src_lang: en' \ --header 'tgt_lang: hi' \ --header 'domain: 1' \ --header 'REV-APPNAME: transliteration' \ --data-raw '{"data": ["SMS"], "abbreviationWithoutDot" :false, }' ``` **Response** ```json abbreviationWithoutDot = true theme={null} { "responseList": [ { "inString": "SMS", "outString": [ "एसएमएस" ], "status": 2 } ] } ``` ```json abbreviationWithoutDot = false theme={null} { "responseList": [ { "inString": "SMS", "outString": [ "एस.एम.एस." ], "status": 2 } ] } ``` # Sample Codes Source: https://docs.reverieinc.com/usage-guides/transliteration/sample-code Access Python SDK samples for seamless content transliteration using Reverie’s Transliteration API. Ideal for server-side script conversion. Explore JavaScript SDK examples to integrate real-time transliteration into web applications and browser-based experiences. Find GoLang SDK samples for fast, scalable transliteration solutions in backend systems and APIs. # Supported Domains Source: https://docs.reverieinc.com/usage-guides/transliteration/supported-domains | Domain ID | Description | | --------- | --------------------------------------------------------------------------- | | 1 | Transliterates generic content regardless of specific domain. | | 2 | Transliterates people’s names and surnames. | | 9 | Transliterates location details like street name, city name, state, etc. | | 4 | Transliterates source content from English script to Indic language script. | | 6 | Transliterates banking and financial terminologies accurately. | | 7 | Transliterates brand and product catalog in the ecommerce domain. | | 22,26 | Transliterates food and grocery items like menus, packaged food, and more. | | 25 | Transliterates song lyrics, movie titles, artist names, and media content. | # Supported Languages Source: https://docs.reverieinc.com/usage-guides/transliteration/supported-languages | Language | Language Code | | --------- | ------------- | | Hindi | hi | | Assamese | as | | Bengali | bn | | Gujarati | gu | | Kannada | kn | | Malayalam | ml | | Marathi | mr | | Odia | or | | Punjabi | pa | | Tamil | ta | | Telugu | te | | English | en | | Urdu | ur | | Sindhi | sd | | Dogri | doi | | Nepali | ne | | Konkani | kon | | Bodo | brx | | Kashmiri | ks | | Maithili | mai | | Manipuri | mni | | Sanskrit | sa | | Santhali | sat | # Call Center Transcription Source: https://docs.reverieinc.com/use-cases/call-center-transcription This project demonstrates how to leverage the Reverie SDK to process and transcribe audio data from call center interactions using Automatic Speech Recognition (ASR). The overall flow of the code is designed to interact with Reverie's API to perform a variety of tasks related to speech-to-text conversion, including: ### Install Dependencies ```bash Python theme={null} pip install pyaudio pip install reverie-sdk pip install python-dotenv ``` ### How does it Works? 1. **Environment Setup**:
All sensitive credentials, such as API keys and application IDs, are securely loaded from environment variables. This ensures that sensitive information is not hardcoded into the script, promoting security and flexibility. ```python Python theme={null} import os import dotenv dotenv.load_dotenv("../.env") REVERIE_APP_ID = os.environ.get("REVERIE_APP_ID") REVERIE_API_KEY = os.environ.get("REVERIE_API_KEY") ``` 2. **Client Initialization**:
A ReverieClient is initialized with the necessary credentials to interact with Reverie's ASR services. The client is the primary interface through which the transcription and other API services are accessed. ```python Python theme={null} from reverie_sdk import ReverieClient client = ReverieClient( api_key=REVERIE_API_KEY, app_id=REVERIE_APP_ID, ) ``` 3. **Audio Processing and Transcription**:
The project is designed to handle various audio formats, processing them through Reverie’s ASR system. This includes batch processing for handling multiple files, real-time transcription, or other speech-to-text functionalities. ```python Python theme={null} client.asr.stt_batch( "en", open("/home/rohnak.agarwal/Documents/sdk_sample/sample.en.rev.wav", "rb").read(), ) ``` 4. **Result Management**: After transcribing the audio, the system outputs the transcription results. These results can then be stored, analyzed, or used for further processing depending on the use case (e.g., customer service analysis, data extraction, etc.). ```python Python theme={null} for res in client.asr.stt_batch( "en", open("/home/rohnak.agarwal/Documents/sdk_sample/sample.en.rev.wav", "rb").read(), ): print(res) ``` ### Sample Code ```python Python theme={null} import os from reverie_sdk import ReverieClient import dotenv dotenv.load_dotenv("../.env") REVERIE_APP_ID = os.environ.get("REVERIE_APP_ID") REVERIE_API_KEY = os.environ.get("REVERIE_API_KEY") client = ReverieClient( api_key=REVERIE_API_KEY, app_id=REVERIE_APP_ID, ) for res in client.asr.stt_batch( "en", open("/home/rohnak.agarwal/Documents/sdk_sample/sample.en.rev.wav", "rb").read(), ): print(res) ``` # Speech To Speech Source: https://docs.reverieinc.com/use-cases/speech-to-speech This Python script demonstrates a real-time Speech-to-Speech (STS) translation system using the Reverie SDK. The script captures speech from the microphone, transcribes it into text, translates it into a target language, and finally converts the translated text back into speech, which is then played back to the user. ### Install Dependencies ```bash Python theme={null} pip install pyaudio pip install reverie-sdk pip install python-dotenv pip install pydub ``` ### How does it Works? The main steps involved in the script are as follows:
1. **Environment Setup**:
The script loads essential API credentials (REVERIE\_APP\_ID and REVERIE\_API\_KEY) from environment variables using the dotenv package. These credentials are required to authenticate with the Reverie API. ```python Python theme={null} import os import dotenv from reverie_sdk import ReverieClient dotenv.load_dotenv("../.env") REVERIE_APP_ID = os.environ.get("REVERIE_APP_ID") REVERIE_API_KEY = os.environ.get("REVERIE_API_KEY") client = ReverieClient( api_key=REVERIE_API_KEY, app_id=REVERIE_APP_ID, ) ``` 2. **Real-Time Audio Capture**:
The script uses pyaudio to capture real-time audio input from the microphone. This audio is then streamed asynchronously to the Reverie ASR (Automatic Speech Recognition) service for transcription into text. ```python Python theme={null} import pyaudio import asyncio from reverie_sdk.services.asr import AudioStream stream = AudioStream() pa = pyaudio.PyAudio() def mic_callback(in_data, frame_count, time_info, status): try: asyncio.run(stream.add_chunk_async(in_data)) except Exception as e: print(f"Error in mic callback: {e}") return (None, pyaudio.paAbort) return (None, pyaudio.paContinue) pa_stream = pa.open( rate=16000, channels=1, format=pyaudio.paInt16, frames_per_buffer=1024, input=True, stream_callback=mic_callback, ) pa_stream.start_stream() ``` 3. **Speech-to-Text (STT) Conversion**:
The captured audio is processed and transcribed using Reverie’s ASR service. The transcription occurs in real-time, providing immediate feedback as the speech is converted into text. ```python Python theme={null} await client.asr.stt_stream_async( src_lang=source_lang, bytes_or_stream=stream, callback=asr_callback, format="16k_int16", punctuate="true", ) ``` 4. **Translation**:
Once the transcription is complete, the text is sent to Reverie’s NMT (Neural Machine Translation) service to be translated from the source language (e.g., Hindi) to a target language (e.g., English). The translated text is returned for further processing. ```python Python theme={null} src_lang = "hi" tgt_lang = "en" resp: str = asyncio.run(speech_to_text(src_lang)) if len(resp.strip()) > 0: tgt_resp = ( client.nmt.localization( [resp], src_lang=src_lang, tgt_lang=tgt_lang, enableTransliteration=False, enableNmt=True, ) .responseList[0] .outString ) print(tgt_resp) ``` 5. **Text-to-Speech (TTS) Conversion**:
The translated text is then sent to Reverie’s TTS (Text-to-Speech) service to convert it into speech. The generated audio is played back to the user, providing a seamless speech-to-speech translation experience. ```python Python theme={null} tts_resp = client.tts.tts( f"{tgt_lang}_female", tgt_resp, ) print(tts_resp) ``` 6. **Optional Audio Saving**:
The generated speech audio can optionally be saved to a file (e.g., .wav) for later use or playback. ```python Python theme={null} tts_resp.save_audio("./sample.wav", overwrite_existing=True) ``` 7. **Audio Playback**:
Using the pydub library, the resulting audio is played back in real-time to the user, completing the cycle of speech-to-text, translation, and speech-to-speech output. ```python Python theme={null} from pydub import AudioSegment, playback import io playback.play(AudioSegment.from_file(io.BytesIO(tts_resp.audio_bytes), format="wav")) ``` 8. **Error Handling**:
The script includes error handling to manage potential issues during the microphone capture, transcription, translation, and speech synthesis processes. ```python Python theme={null} import traceback try: # [Audio streaming, transcription, translation, and TTS code] except Exception as err: print(f"Error in Speech-to-Text: {err}") traceback.print_exc() finally: pa_stream.stop_stream() pa_stream.close() ``` ### Sample Code ```python Python theme={null} import asyncio import io import os import traceback import pyaudio from pydub import AudioSegment, playback from reverie_sdk import ReverieClient from reverie_sdk.services.asr import ReverieAsrResult, AudioStream import dotenv dotenv.load_dotenv("../.env") REVERIE_APP_ID = os.environ.get("REVERIE_APP_ID") REVERIE_API_KEY = os.environ.get("REVERIE_API_KEY") client = ReverieClient( api_key=REVERIE_API_KEY, app_id=REVERIE_APP_ID, ) async def speech_to_text(source_lang): stream = AudioStream() pa = pyaudio.PyAudio() def mic_callback(in_data, frame_count, time_info, status): try: asyncio.run(stream.add_chunk_async(in_data)) except Exception as e: print(f"Error in mic callback: {e}") return (None, pyaudio.paAbort) return (None, pyaudio.paContinue) pa_stream = pa.open( rate=16000, channels=1, format=pyaudio.paInt16, frames_per_buffer=1024, input=True, stream_callback=mic_callback, ) pa_stream.start_stream() print("Listening at STT..") asr_responses: list[ReverieAsrResult] = [] def asr_callback(resp: ReverieAsrResult): print(resp) asr_responses.append(resp) try: await client.asr.stt_stream_async( src_lang=source_lang, bytes_or_stream=stream, callback=asr_callback, format="16k_int16", punctuate="true", ) while True: if len(asr_responses) == 0: continue if asr_responses[-1].final: print(asr_responses[-1].display_text) return asr_responses[-1].display_text except Exception as err: print(f"Error in Speech-to-Text: {err}") traceback.print_exc() finally: pa_stream.stop_stream() pa_stream.close() src_lang = "hi" tgt_lang = "en" resp: str = asyncio.run(speech_to_text(src_lang)) if len(resp.strip()) > 0: tgt_resp = ( client.nmt.localization( [resp], src_lang=src_lang, tgt_lang=tgt_lang, enableTransliteration=False, enableNmt=True, ) .responseList[0] .outString ) print(tgt_resp) tts_resp = client.tts.tts( f"{tgt_lang}_female", tgt_resp, ) print(tts_resp) # optional: save the audio # tts_resp.save_audio("./sample.wav", overwrite_existing=True) playback.play(AudioSegment.from_file(io.BytesIO(tts_resp.audio_bytes), format="wav")) ``` # Speech Translation Source: https://docs.reverieinc.com/use-cases/speech-translation This script demonstrates the integration of real-time Speech-to-Text (STT) and Machine Translation (NMT) using the Reverie SDK. It captures audio input from a microphone, converts the speech into text using the Reverie ASR service, and then translates the transcribed text into a target language using Reverie NMT. ### Install Dependencies ```bash Python theme={null} pip install pyaudio pip install reverie-sdk pip install python-dotenv ``` ### How does it Works? The script follows these main steps:
1. **Environment Setup**:
The script loads the required credentials (REVERIE\_APP\_ID and REVERIE\_API\_KEY) from environment variables using the dotenv library. These credentials are essential for authenticating API requests to the Reverie SDK. ```python Python theme={null} import os import dotenv from reverie_sdk import ReverieClient dotenv.load_dotenv("../.env") REVERIE_APP_ID = os.environ.get("REVERIE_APP_ID") REVERIE_API_KEY = os.environ.get("REVERIE_API_KEY") client = ReverieClient( api_key=REVERIE_API_KEY, app_id=REVERIE_APP_ID, ) ``` 2. **Real-Time Audio Streaming**:
The script uses pyaudio to capture audio from the microphone in real-time. The captured audio is sent to the Reverie ASR service for continuous transcription via the AudioStream object. The audio data is streamed asynchronously, providing live transcription results. ```python Python theme={null} import pyaudio import asyncio from reverie_sdk.services.asr import AudioStream stream = AudioStream() pa = pyaudio.PyAudio() def mic_callback(in_data, frame_count, time_info, status): try: asyncio.run(stream.add_chunk_async(in_data)) except Exception as e: print(f"Error in mic callback: {e}") return (None, pyaudio.paAbort) return (None, pyaudio.paContinue) pa_stream = pa.open( rate=16000, channels=1, format=pyaudio.paInt16, frames_per_buffer=1024, input=True, stream_callback=mic_callback, ) pa_stream.start_stream() ``` 3. **Speech-to-Text (STT) Conversion**:
The captured audio is processed by the Reverie ASR service, which transcribes the spoken words into text. The transcription happens in real-time, and each segment of the transcribed text is displayed as it is received. ```python Python theme={null} await client.asr.stt_stream_async( src_lang=source_lang, bytes_or_stream=stream, callback=asr_callback, format="16k_int16", punctuate="true", ) ``` 4. **Callback Function for ASR Results**:
A callback function is used to handle the ASR responses. Once the transcription is finalized, the transcribed text is returned and printed. ```python Python theme={null} from reverie_sdk.services.asr import ReverieAsrResult asr_responses: list[ReverieAsrResult] = [] def asr_callback(resp: ReverieAsrResult): print(resp) asr_responses.append(resp) while True: if len(asr_responses) == 0: continue if asr_responses[-1].final: print(asr_responses[-1].display_text) return asr_responses[-1].display_text ``` 5. **Text Translation**:
After obtaining the transcribed text, the script sends it to the Reverie NMT service for translation into the specified target language (e.g., from Hindi to English in this case). The translation result is then printed. ```python Python theme={null} src_lang = "hi" tgt_lang = "en" resp: str = asyncio.run(speech_to_text(src_lang)) if len(resp.strip()) > 0: tgt_resp = ( client.nmt.localization( [resp], src_lang=src_lang, tgt_lang=tgt_lang, enableTransliteration=False, enableNmt=True, ) .responseList[0] .outString ) print(tgt_resp) ``` 6. **Error Handling**:
Comprehensive error handling is included to ensure smooth operation, including managing microphone input errors and any potential issues during the transcription or translation processes. ```python Python theme={null} import traceback try: # [Audio streaming and transcription code] except Exception as err: print(f"Error in Speech-to-Text: {err}") traceback.print_exc() finally: pa_stream.stop_stream() pa_stream.close() ``` ### Sample Code ```python Python theme={null} import asyncio import os import traceback import pyaudio from reverie_sdk import ReverieClient from reverie_sdk.services.asr import ReverieAsrResult, AudioStream import dotenv dotenv.load_dotenv("../.env") REVERIE_APP_ID = os.environ.get("REVERIE_APP_ID") REVERIE_API_KEY = os.environ.get("REVERIE_API_KEY") client = ReverieClient( api_key=REVERIE_API_KEY, app_id=REVERIE_APP_ID, ) async def speech_to_text(source_lang): stream = AudioStream() pa = pyaudio.PyAudio() def mic_callback(in_data, frame_count, time_info, status): try: asyncio.run(stream.add_chunk_async(in_data)) except Exception as e: print(f"Error in mic callback: {e}") return (None, pyaudio.paAbort) return (None, pyaudio.paContinue) pa_stream = pa.open( rate=16000, channels=1, format=pyaudio.paInt16, frames_per_buffer=1024, input=True, stream_callback=mic_callback, ) pa_stream.start_stream() print("Listening at STT..") asr_responses: list[ReverieAsrResult] = [] def asr_callback(resp: ReverieAsrResult): print(resp) asr_responses.append(resp) try: await client.asr.stt_stream_async( src_lang=source_lang, bytes_or_stream=stream, callback=asr_callback, format="16k_int16", punctuate="true", ) while True: if len(asr_responses) == 0: continue if asr_responses[-1].final: print(asr_responses[-1].display_text) return asr_responses[-1].display_text except Exception as err: print(f"Error in Speech-to-Text: {err}") traceback.print_exc() finally: pa_stream.stop_stream() pa_stream.close() src_lang = "hi" tgt_lang = "en" resp: str = asyncio.run(speech_to_text(src_lang)) if len(resp.strip()) > 0: tgt_resp = ( client.nmt.localization( [resp], src_lang=src_lang, tgt_lang=tgt_lang, enableTransliteration=False, enableNmt=True, ) .responseList[0] .outString ) print(tgt_resp) ``` # Voice Agent Source: https://docs.reverieinc.com/use-cases/voice-agent This Python script demonstrates how to capture real-time audio from a microphone and convert it into text using the Reverie SDK's Speech-to-Text (STT) service. The process is asynchronous and handles audio streaming efficiently to provide real-time transcription. ### Install Dependencies ```bash Python theme={null} pip install pyaudio pip install reverie-sdk pip install python-dotenv ``` ### How does it Works? The main steps involved in the script are as follows:
1. **Environment Configuration**:
The script loads API credentials (REVERIE\_APP\_ID and REVERIE\_API\_KEY) from environment variables using the dotenv package. These credentials are essential for interacting with the Reverie SDK's ASR (Automatic Speech Recognition) service. ```python Python theme={null} import os import dotenv from reverie_sdk import ReverieClient dotenv.load_dotenv("../.env") REVERIE_APP_ID = os.environ.get("REVERIE_APP_ID") REVERIE_API_KEY = os.environ.get("REVERIE_API_KEY") client = ReverieClient( api_key=REVERIE_API_KEY, app_id=REVERIE_APP_ID, ) ``` 2. **Real-Time Audio Capture**:
The script uses the pyaudio library to stream audio from the user's microphone in real-time. The audio is captured in 16kHz, mono format (16-bit signed integer), and streamed asynchronously to Reverie's ASR service for transcription. ```python Python theme={null} import pyaudio import asyncio stream = AudioStream() pa = pyaudio.PyAudio() def mic_callback(in_data, frame_count, time_info, status): try: asyncio.run(stream.add_chunk_async(in_data)) except Exception as e: print(f"Error in mic callback: {e}") return (None, pyaudio.paAbort) return (None, pyaudio.paContinue) pa_stream = pa.open( rate=16000, channels=1, format=pyaudio.paInt16, frames_per_buffer=1024, input=True, stream_callback=mic_callback, ) pa_stream.start_stream() ``` 3. **Speech-to-Text (STT) Conversion**:
The captured audio is sent in small chunks to the Reverie ASR system, which transcribes the speech into text. The transcription is processed as it is received, with results updated in real-time. ```python Python theme={null} from reverie_sdk.services.asr import ReverieAsrResult, AudioStream await client.asr.stt_stream_async( src_lang=source_lang, bytes_or_stream=stream, callback=asr_callback, format="16k_int16", punctuate="true", ) ``` 4. **Asynchronous Processing**:
An asynchronous function handles the audio streaming and transcription. A callback function is used to manage the incoming transcription results, which are accumulated and processed until a final transcription result is achieved. ```python Python theme={null} async def speech_to_text(source_lang): asr_responses: list[ReverieAsrResult] = [] def asr_callback(resp: ReverieAsrResult): print(resp) asr_responses.append(resp) while True: if len(asr_responses) == 0: continue if asr_responses[-1].final: print(asr_responses[-1].display_text) return asr_responses[-1].display_text ``` 5. **Error Handling**:
The script includes robust error handling to manage any issues that may arise during the microphone input, audio streaming, or ASR transcription process. ```python Python theme={null} import traceback try: # [Audio streaming and transcription code] except Exception as err: print(f"Error in Speech-to-Text: {err}") traceback.print_exc() finally: pa_stream.stop_stream() pa_stream.close() ``` 6. **Output**:
Once the transcription is complete, the final text is printed out. The transcription happens in the source language (Hindi in this example), and it’s ready for further processing or translation if needed. ### Sample Code ```python Python theme={null} import asyncio import os import traceback import pyaudio from reverie_sdk import ReverieClient from reverie_sdk.services.asr import ReverieAsrResult, AudioStream import dotenv dotenv.load_dotenv("../.env") REVERIE_APP_ID = os.environ.get("REVERIE_APP_ID") REVERIE_API_KEY = os.environ.get("REVERIE_API_KEY") client = ReverieClient( api_key=REVERIE_API_KEY, app_id=REVERIE_APP_ID, ) async def speech_to_text(source_lang): stream = AudioStream() pa = pyaudio.PyAudio() def mic_callback(in_data, frame_count, time_info, status): try: asyncio.run(stream.add_chunk_async(in_data)) except Exception as e: print(f"Error in mic callback: {e}") return (None, pyaudio.paAbort) return (None, pyaudio.paContinue) pa_stream = pa.open( rate=16000, channels=1, format=pyaudio.paInt16, frames_per_buffer=1024, input=True, stream_callback=mic_callback, ) pa_stream.start_stream() print("Listening at STT..") asr_responses: list[ReverieAsrResult] = [] def asr_callback(resp: ReverieAsrResult): print(resp) asr_responses.append(resp) try: await client.asr.stt_stream_async( src_lang=source_lang, bytes_or_stream=stream, callback=asr_callback, format="16k_int16", punctuate="true", ) while True: if len(asr_responses) == 0: continue if asr_responses[-1].final: print(asr_responses[-1].display_text) return asr_responses[-1].display_text except Exception as err: print(f"Error in Speech-to-Text: {err}") traceback.print_exc() finally: pa_stream.stop_stream() pa_stream.close() asyncio.run(speech_to_text("hi")) ``` # Voice Search Source: https://docs.reverieinc.com/use-cases/voice-search This Python script demonstrates how to implement a real-time voice search system using Reverie SDK’s Speech-to-Text (STT) service. The script captures audio input from the microphone, transcribes it into text, and processes the text for further use (such as conducting a search query, triggering actions, or further processing). ### Install Dependencies ```bash Python theme={null} pip install pyaudio pip install reverie-sdk pip install python-dotenv ``` ### How does it Works? The main steps involved in the script are as follows:
1. **Environment Configuration**:
The script loads essential credentials (REVERIE\_APP\_ID and REVERIE\_API\_KEY) from environment variables using the dotenv package. These credentials are required for accessing the Reverie SDK and its services. ```python Python theme={null} import os import dotenv from reverie_sdk import ReverieClient dotenv.load_dotenv("../.env") REVERIE_APP_ID = os.environ.get("REVERIE_APP_ID") REVERIE_API_KEY = os.environ.get("REVERIE_API_KEY") client = ReverieClient( api_key=REVERIE_API_KEY, app_id=REVERIE_APP_ID, ) ``` 2. **Real-Time Audio Capture:**:
The script uses the pyaudio library to stream audio data from the microphone. The audio is captured in real-time, with the system processing 16kHz, mono audio in 16-bit signed integer format. ```python Python theme={null} import pyaudio import asyncio stream = AudioStream() pa = pyaudio.PyAudio() def mic_callback(in_data, frame_count, time_info, status): try: asyncio.run(stream.add_chunk_async(in_data)) except Exception as e: print(f"Error in mic callback: {e}") return (None, pyaudio.paAbort) return (None, pyaudio.paContinue) pa_stream = pa.open( rate=16000, channels=1, format=pyaudio.paInt16, frames_per_buffer=1024, input=True, stream_callback=mic_callback, ) pa_stream.start_stream() ``` 3. **Speech-to-Text (STT) Conversion**:
The audio data is continuously streamed and sent to Reverie's Automatic Speech Recognition (ASR) service for transcription. The system listens for spoken words and converts them into text in the specified source language (in this case, English). ```python Python theme={null} from reverie_sdk.services.asr import ReverieAsrResult, AudioStream await client.asr.stt_stream_async( src_lang=source_lang, bytes_or_stream=stream, callback=asr_callback, format="16k_int16", punctuate="true", domain="voice_search", ) ``` 4. **Voice Search Use Case:**:
The stt\_stream\_async method is used with the "voice\_search" domain. This allows the system to process and transcribe speech, making it ideal for voice search applications where users speak their search queries, and the system translates those queries into text for further action. ```python Python theme={null} await client.asr.stt_stream_async( src_lang=source_lang, bytes_or_stream=stream, callback=asr_callback, format="16k_int16", punctuate="true", domain="voice_search", ) ``` 5. **Real-Time Transcription:**:
The transcription occurs in real-time, with each segment of speech being converted into text and displayed immediately. Once the system recognizes a complete, final transcription, the result is returned and printed. ```python Python theme={null} async def speech_to_text(source_lang): asr_responses: list[ReverieAsrResult] = [] def asr_callback(resp: ReverieAsrResult): print(resp) asr_responses.append(resp) while True: if len(asr_responses) == 0: continue if asr_responses[-1].final: print(asr_responses[-1].display_text) return asr_responses[-1].display_text ``` 6. **Error Handling:**:
The script includes error handling to manage potential issues during the audio capture, streaming, and transcription process, ensuring the system continues functioning smoothly in case of interruptions. ``` import traceback try: # [Audio streaming and transcription code] except Exception as err: print(f"Error in Speech-to-Text: {err}") traceback.print_exc() finally: pa_stream.stop_stream() pa_stream.close() ``` 7. **Output**:
The final transcribed text is printed to the console, which could then be used for various purposes, such as initiating a search query, performing a task, or further processing based on the transcription result. ### Sample Code ```python Python theme={null} import asyncio import os import traceback import pyaudio from reverie_sdk import ReverieClient from reverie_sdk.services.asr import ReverieAsrResult, AudioStream import dotenv dotenv.load_dotenv("../.env") REVERIE_APP_ID = os.environ.get("REVERIE_APP_ID") REVERIE_API_KEY = os.environ.get("REVERIE_API_KEY") client = ReverieClient( api_key=REVERIE_API_KEY, app_id=REVERIE_APP_ID, ) async def speech_to_text(source_lang): stream = AudioStream() pa = pyaudio.PyAudio() def mic_callback(in_data, frame_count, time_info, status): try: asyncio.run(stream.add_chunk_async(in_data)) except Exception as e: print(f"Error in mic callback: {e}") return (None, pyaudio.paAbort) return (None, pyaudio.paContinue) pa_stream = pa.open( rate=16000, channels=1, format=pyaudio.paInt16, frames_per_buffer=1024, input=True, stream_callback=mic_callback, ) pa_stream.start_stream() print("Listening at STT..") asr_responses: list[ReverieAsrResult] = [] def asr_callback(resp: ReverieAsrResult): print(resp) asr_responses.append(resp) try: await client.asr.stt_stream_async( src_lang=source_lang, bytes_or_stream=stream, callback=asr_callback, format="16k_int16", punctuate="true", domain="voice_search", ) while True: if len(asr_responses) == 0: continue if asr_responses[-1].final: print(asr_responses[-1].display_text) return asr_responses[-1].display_text except Exception as err: print(f"Error in Speech-to-Text: {err}") traceback.print_exc() finally: pa_stream.stop_stream() pa_stream.close() asyncio.run(speech_to_text("en")) ```