Find and Replace
Deepgram API Playground
Try this feature out in our API Playground.
replace string
Pre-recorded Streaming:NovaStreaming: Flux All available languages
Enable Feature
Section titled “Enable Feature”To enable Find and Replace, use the following parameter in the querystring:
replace=TERM_OR_PHRASE_TO_FIND:REPLACEMENT_TERM_OR_PHRASE
The find term should be always be lowercase and the replacement term can be any case.
To transcribe audio from a file on your computer, run the following curl command in a terminal or your favorite API client.
Replace a Single Term
Section titled “Replace a Single Term”To replace a single term, send one instance of the replace parameter in the query string when calling the API:
replace=monika:monica
replace=monika:Monica
Replace Multiple Terms
Section titled “Replace Multiple Terms”You can replace multiple terms individually:
replace=monika:monica&replace=hailee:hailey
replace=monika:monica&replace=Hailee:Hailey
Replace a Phrase
Section titled “Replace a Phrase”You can replace a phrase. URL-encode the phrase when submitting it.
replace=monika%20jon:monica%20john
replace=monika%20jon:Monica%20John
Remove a Term or Phrase
Section titled “Remove a Term or Phrase”You can remove a term or phrase by not submitting a replacement.
replace=monika
Capitalization
Section titled “Capitalization”You can selectively replace capitalized words by capitalizing the word-to-be-replaced.
This is particularly useful for proper nouns and named entities. Deepgram’s transcription will make an educated guess when spelling unfamiliar named entities. In some cases, the capitalization of words or proper nouns may be incorrect so you can use capitalization to correct any inconsistencies. For example:
replace=ZenDesk:Zendesk
Backwards Compatibility
Section titled “Backwards Compatibility”Prior to support for capitalization, replace=zendesk=Zendesk would replace all instances of the letters zendesk (ignoring capitalization) with Zendesk. To maintain backwards compatibility, the behavior is the same when the word-to-be-replaced is composed of entirely lowercase letters.
When submitting replacements for the same word with different capitalization, the capitalized version of the word takes precedence. For example, if you submit replace=It:The%20monster&replace=it:the%20monster, It will be replaced with The monster and it will be replaced with the monster because the replacement for It takes precedence over it. However, if you submit only replace=it:the%20monster, both it and It will be replaced with the monster to maintain backwards compatibility.
Analyze Response
Section titled “Analyze Response”We want to replace the term “kpis” in this audio file with the full term “Key Performance Indicators”.
In our terminal, we run the following command:
When the file is finished processing, you’ll receive a JSON response. Let’s look more closely at the words object within the alternatives object within this response. Notice that the audio contains an occurrence of the word “kpis”:
...
{
"alternatives": [
{
"words": [
...
{
"word":"kpis",
"start":14.20957,
"end":14.70957,
"confidence":0.9946289
},
...
]
...
}
]
}However, this has been replaced with “Key Performance Indicators”.
{
"alternatives": [
{
"words": [
...
{
"word": "Key",
"start": 14.20957,
"end": 14.355842,
"confidence": 0.99620026
},
{
"word": "Performance",
"start": 14.355842,
"end": 14.502113,
"confidence": 0.99620026
},
{
"word": "Indicators",
"start": 14.502114,
"end": 14.648386,
"confidence": 0.99620026
},
...
]
...
}
]
}In this part of the response, notice:
- the replacement word
Keyretains the samestartvalue as the original wordkpis. - the replacement words have different
endvalues than the original wordkpis. This is because we replaced one word with three words, so the total time was divided roughly evenly between the words. If we were replacing one word with one word, the start and end times would be the same.