import requests import json import time import yaml import yt_dlp import assemblyai as aai with open("config.yaml", "r") as file: params = yaml.safe_load(file) transcriber = aai.Transcriber() aai.settings.api_key = params["ASSEMBLY_AI_TOKEN"] def assemblyai_transcribe(audio_url): if audio_url is None: return "" with yt_dlp.YoutubeDL() as ydl: info = ydl.extract_info(audio_url, download=False) for format in info["formats"][::-1]: if format["resolution"] == "audio only" and format["ext"] == "m4a": url = format["url"] break transcript = transcriber.transcribe(url) return transcript.text