Spaces:
Running
Running
File size: 738 Bytes
2019311 173f4a0 2019311 173f4a0 2019311 173f4a0 2019311 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import requests
import json
import time
import yaml
import yt_dlp
import assemblyai as aai
from dotenv import load_dotenv
import os
load_dotenv()
with open("config.yaml", "r") as file:
params = yaml.safe_load(file)
transcriber = aai.Transcriber()
aai.settings.api_key = os.environ['ASSEMBLYAI_API_KEY']
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 |