Use this file to discover all available pages before exploring further.
In this guide, we’ll show you how to setup automatic server error retry logic in your transcription process.Server errors indicate a server-side issue during the transcription process. These rarely happen, but can occasionally occur on our side. If a transcription fails due to a server error, we recommend that you resubmit the file for transcription to allow another server to process the audio. If the issue persists, please reach out to our support team: support@assemblyai.comThis workflow is designed to automatically retry these transcripts if a server error is encountered.
If your transcription fails due to a server error on our side, we will
automatically retry the request up to three times. You can find this option in
your Account Settings.
Import the assemblyai and time package and set your API key:
import assemblyai as aaiimport timeaai.settings.api_key = "YOUR_API_KEY"
Create a function that handles errors that may occur during the transcription process. The default number of retires is 1. The default wait time before retranscribing is 5 seconds.
def handle_error_transcription(audio_url, transcriber, config, retries=1, wait_time=5): for attempt in range(retries + 1): transcript = transcriber.transcribe(audio_url, config) if transcript.error == "Server error, developers have been alerted": if attempt < retries: print(f"Encountered a server error. Retrying in {wait_time} second(s)...") time.sleep(wait_time) else: print("Retry failed with a server error. Please contact AssemblyAI Support: support@assemblyai.com") return None elif transcript.status == aai.TranscriptStatus.error: print(f"Transcription failed: {transcript.error}") return None else: return transcript
Define the audio file that you want to transcribe.
audio_url = "YOUR_AUDIO_URL"
Create a Transcriber object and specify features in TranscriptionConfig.
Call the function to handle transcription with error handling. Specify number of retries and wait time. Return the transcribed text if transcription is successful.