A text-to-speech Callback allows you to have your submitted text processed asynchronously.
callbackstring
Text to Speech Request Text to Speech Stream English Only
Deepgram’s Callback feature allows you to supply a callback URL to which generated text-to-speech audio can be returned. When passed, Deepgram will immediately respond with arequest_id before processing your text asynchronously.
Enable Feature
To enable Callback, when you call Deepgram’s API, add acallback parameter in the query string and set it to the URL to which you would like transcriptions sent:
callback=URL
To synthesize text-to-speech and generate an audio file, run the following cURL command in a terminal or your favorite API client:
Your callback URLs may reference thehttp orhttps protocols.
Authenticating Callback Requests
Authentication ensures the security and integrity of callback requests. There are two main methods for authenticating callback requests: using Basic Auth and utilizing the dg-token request header.
Using Basic Auth
You may embed username-password authentication credentials in the callback URL in the formathttps://username:[email protected]. However, it’s important to note that only ports 80, 443, 8080, and 8443 are permitted for callbacks.
Only ports 80, 443, 8080, and 8443 are permitted for callbacks.
Using thedg-token Request Header
Alternatively, the callback request itself contains a header named dg-token. This header is automatically set to the API Key Identifier associated with the API Key used to submit the original request. This method provides a secure and straightforward means of authentication.
Results
When Deepgram has finished analyzing the text, it will send aPOST request to the provided callback URL with an appropriate HTTP status code.
If the HTTP status code of the response to the callbackPOST request is unsuccessful (not 200-299), Deepgram will retry the callback up to 10 times with a 30 second delay between attempts.
UsingCallBack_Method
To enable the Callback Method, include thecallback_method parameter in the query string. By default, the method supportsPOST, but you can specifyPUT instead.