- Categories:
File functions (AI Functions)
AI_TRANSCRIBE¶
Transcribes text from an audio or video file with optional timestamps and speaker labels. AI_TRANSCRIBE supports numerous languages, and audio can contain more than one language. Timestamps and speaker labels are extracted based on the specified timestamp granularity, as shown in the table below.
Timestamp granularity |
Result |
|---|---|
Default |
Transcription of entire audio file in one piece |
Word |
Transcription with timestamps for each word |
Speaker |
Indicates who is speaking, and a timestamp, at each change of speaker |
Syntax¶
Arguments¶
Required:
audio_fileA FILE type object representing an audio file. Use TO_FILE function to create a reference to your staged file.
Optional:
optionsAn OBJECT value containing zero or more of the following fields.
timestamp_granularity: A string specifying the desired timestamp granularity. Possible values are:"word": The file is transcribed as a series of words, each with its own timestamp."speaker": The file is transcribed as a series of conversational “turns,” each with its own timestamp and speaker label.
If this field is not specified, the entire file is transcribed as a single segment without timestamps by default.
return_error_detailsA BOOLEAN flag that indicates whether to return error details in case of error. When set to TRUE, the function returns an OBJECT that contains the value and the error message, one of which is NULL depending on whether the function succeeded or failed. See Error behavior for details.
Returns¶
An string containing a JSON representation of the transcription result. The JSON object contains the following fields:
"audio_duration": The total duration of the audio file in seconds."text": The transcription of the complete audio file, provided when thetimestamp_granularityfield is not specified."segments": An array of segments, provided when thetimestamp_granularityfield is set to"word"or"speaker". Each segment is a JSON object containing the following fields:"start": The start time of the segment in seconds."end": The end time of the segment in seconds."text": The transcription text for the segment."speaker_label": The label of the speaker for the segment, provided when thetimestamp_granularityfield is set tospeaker. Labels are of the form “SPEAKER_00”, “SPEAKER_01”, etc. and are assigned in the order speakers are detected in the audio file.
Error behavior¶
By default, if AI_TRANSCRIBE can’t process the input, the function returns NULL. If the query processes multiple rows, rows with errors return NULL and don’t prevent the query from completing.
The return value on error depends on the return_error_details
argument. The following table shows the return value based on the return_error_details argument:
return_error_detailsReturn value
Description
FALSENot passedNULL
TRUE
OBJECT with
valueanderrorfieldsvalue: A VARCHAR value containing the transcription result, or NULL if an error occurred.error: A VARCHAR value that contains the error message if an error occurred, or NULL if the function succeeded.
For more information about error handling for AI functions, see Snowflake Cortex AI Function: Multirow error handling improvements.
Access control requirements¶
Users must use a role that has been granted the SNOWFLAKE.CORTEX_USER database role. See Cortex LLM privileges for more information on this role.
Usage notes¶
For a list of supported languages, see Supported languages
Supported languages are automatically detected. A file can contain multiple languages, each of which is recognized and transcribed. For accurate language detection, speech must begin within the first five seconds of the file.
AI_TRANSCRIBE supports the following audio and video file formats:
Audio
FLAC, MP3, MP4, OGG, WAV, WEBM
Video
MKV, MP4, OGV, WEBM
Video files must contain at least one audio track in FLAC, MP3, OPUS, VORBIS, or WAV format.
Factors such as sample rate, bit depth, and number of channels do not affect transcription, but they might make the file too large to process if they are too high. Internally, AI_TRANSCRIBE uses monophonic audio at 16 KHz, and resamples input files when they are not already in this format
The maximum audio file size is 700 MB.
The maximum audio file duration is 60 minutes when timestamp granularity is set to “word” or “speaker”. If timestamp granularity is not used, the maximum duration is 120 minutes.
Examples¶
For examples, see AI Audio examples.
Troubleshooting¶
If the function fails, it raises an error. Common error messages include:
Error Message |
Situation and Solution |
|---|---|
Invalid options object |
The option provided for the |
No response from server |
The audio file cannot be retrieved, perhaps because of an expired scoped URL. |
File too large. Maximum size is 734,003,200 Bytes, file exceeds this limit. |
The provided audio file exceeds the maximum file size. |
Invalid file format. Only [‘flac’, ‘mp3’, ‘ogg’, ‘wav’, ‘webm’] files are supported, or WebM file does not contain an audio stream. |
The audio file is not one of the supported formats, which are listed in the error message. WebM files support multiple media types, so make sure the file contains an audio stream. If the file is in a supported format, check that it is not corrupted. |
File will be too large after resampling it to 16000 Hertz. Expected size is 3,355,444,448,000.0 Bytes. |
The provided audio file is too large after resampling to 16 KHz. If the provided audio has a lower sample rate, its resampled size is larger than the original, and could potentially exceed the maximum allowed file size. |
Audio duration too long: 6052.10 seconds. Maximum allowed: 3600 seconds. or Audio duration too long: 7335.28 seconds. Maximum allowed: 7200 seconds. |
The provided audio file is too long. If you are using timestamp granularity, the maximum duration is 60 minutes (3600 seconds). |
Unsupported detected language |
The audio file contains a language that is not supported by AI_TRANSCRIBE. |
Regional availability¶
AI_TRANSCRIBE is available in the following regions:
AWS US West 2 (Oregon)
AWS US East 1 (N. Virginia)
AWS EU Central 1 (Frankfurt)
Azure East US 2 (Virginia)
Legal notices¶
Refer to Snowflake AI and ML.
Limitations¶
Snowflake Cortex functions do not support dynamic tables.