transcription_api.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
   def transcribe(self, request):
        # ...The rest of the data loading is too much to fit here 
        # check out this repo to see the full implementation!
        
        # Initialize Configuration and retrieve the API key
        config = Configuration()
        assembly_api_key = config.get("ASSEMBLY_AI_API_KEY")

        # Request transcription
        headers = {
            "authorization": assembly_api_key,
            "content-type": "application/json"
        }
        transcript_request = {
            "audio": audio_data,
            "wait": True
        }  
        response = requests.post(
          f"{self.assembly_api_url}/transcript", \
          json=transcript_request, \
          headers=headers
        )