Create transcription
POST https://api.fastapi.ai/v1/audio/transcriptions
Transcribes audio into the input language.
Request body
file
file Required
The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
model
string Required
ID of the model to use. Only whisper-1
(which is powered by our open source Whisper V2 model) is currently available.
language
string Optional
The language of the input audio. Supplying the input language in ISO-639-1 (e.g. en
) format will improve accuracy and latency.
prompt
string Optional
An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language.
response_format
string Optional Defaults to json
The format of the output, in one of these options: json
, text
, srt
, verbose_json
, or vtt
.
temperature
number Optional Defaults to 0
The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.
timestamp_granularities[]
array Optional Defaults to segment
The timestamp granularities to populate for this transcription. response_format
must be set verbose_json
to use timestamp granularities. Either or both of these options are supported: word
, or segment
. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.
Returns
The transcription object or a verbose transcription object.
The transcription object (JSON)
Represents a transcription response returned by model, based on the provided input.
text
string
The transcribed text.
{
"text": "Imagine the wildest idea that you've ever had, and you're curious about how it might scale to something that's a 100, a 1,000 times bigger. This is a place where you can get to do that."
}
The transcription object (Verbose JSON)
Represents a verbose json transcription response returned by model, based on the provided input.
language
string
The language of the input audio.
duration
number
The duration of the input audio.
text
string
The transcribed text.
words
array
Extracted words and their corresponding timestamps.
word
string
The text content of the word.
start
number
Start time of the word in seconds.
end
number
End time of the word in seconds.
segments
array
Segments of the transcribed text and their corresponding details.
id
integer
Unique identifier of the segment.
seek
integer
Seek offset of the segment.
start
number
Start time of the segment in seconds.
end
number
End time of the segment in seconds.
text
string
Text content of the segment.
tokens
array
Array of token IDs for the text content.
temperature
number
Temperature parameter used for generating the segment.
avg_logprob
number
Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
compression_ratio
number
Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
no_speech_prob
number
Probability of no speech in the segment. If the value is higher than 1.0 and the avg_logprob
is below -1, consider this segment silent.
{
"task": "transcribe",
"language": "english",
"duration": 8.470000267028809,
"text": "The beach was a popular spot on a hot summer day. People were swimming in the ocean, building sandcastles, and playing beach volleyball.",
"segments": [
{
"id": 0,
"seek": 0,
"start": 0.0,
"end": 3.319999933242798,
"text": " The beach was a popular spot on a hot summer day.",
"tokens": [
50364, 440, 7534, 390, 257, 3743, 4008, 322, 257, 2368, 4266, 786, 13, 50530
],
"temperature": 0.0,
"avg_logprob": -0.2860786020755768,
"compression_ratio": 1.2363636493682861,
"no_speech_prob": 0.00985979475080967
},
...
]
}
Example
Request
curl https://api.fastapi.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $FAST_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/audio.mp3" \
-F model="whisper-1"
curl https://api.fastapi.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $FAST_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/audio.mp3" \
-F "timestamp_granularities[]=word" \
-F model="whisper-1" \
-F response_format="verbose_json"
curl https://api.fastapi.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $FAST_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/audio.mp3" \
-F "timestamp_granularities[]=segment" \
-F model="whisper-1" \
-F response_format="verbose_json"
Response
{
"text": "Imagine the wildest idea that you've ever had, and you're curious about how it might scale to something that's a 100, a 1,000 times bigger. This is a place where you can get to do that."
}
{
"task": "transcribe",
"language": "english",
"duration": 8.470000267028809,
"text": "The beach was a popular spot on a hot summer day. People were swimming in the ocean, building sandcastles, and playing beach volleyball.",
"words": [
{
"word": "The",
"start": 0.0,
"end": 0.23999999463558197
},
...
{
"word": "volleyball",
"start": 7.400000095367432,
"end": 7.900000095367432
}
]
}
{
"task": "transcribe",
"language": "english",
"duration": 8.470000267028809,
"text": "The beach was a popular spot on a hot summer day. People were swimming in the ocean, building sandcastles, and playing beach volleyball.",
"segments": [
{
"id": 0,
"seek": 0,
"start": 0.0,
"end": 3.319999933242798,
"text": " The beach was a popular spot on a hot summer day.",
"tokens": [
50364, 440, 7534, 390, 257, 3743, 4008, 322, 257, 2368, 4266, 786, 13, 50530
],
"temperature": 0.0,
"avg_logprob": -0.2860786020755768,
"compression_ratio": 1.2363636493682861,
"no_speech_prob": 0.00985979475080967
},
...
]
}