import gradio as gr import os import json import requests import time # AssemblyAI transcript endpoint (where we submit the file) transcript_endpoint = "https://api.assemblyai.com/v2/transcript" def get_transcript_url(url, api_token): headers={ "Authorization": api_token, "Content-Type": "application/json" } # JSON that tells the API which file to trancsribe json={"audio_url": url} response = requests.post( transcript_endpoint, json=json, headers=headers # Authorization to link this transcription with your account ) polling_endpoint = f"https://api.assemblyai.com/v2/transcript/{response.json()['id']}" while True: transcription_result = requests.get(polling_endpoint, headers=headers).json() if transcription_result['status'] == 'completed': break elif transcription_result['status'] == 'error': raise RuntimeError(f"Transcription failed: {transcription_result['error']}") else: time.sleep(3) return transcription_result['text'] title = """