deepgram-python-sdk: Getting error in pre-recorded audio

from deepgram import Deepgram
import asyncio
import json

# Your Deepgram API Key
apiKey = "******"

# Name and extension of the file you downloaded (e.g., sample.wav)
PATH_TO_FILE = 'Voice_sample_1.m4a'


async def transcribe_audio(audio_file):
    # Initialize the deepgram SDK
    dg_client = Deepgram(apiKey)
    # Open the audio file
    with open(audio_file, 'rb') as audio:
        # Replace mimetype as appropriate
        source = {'buffer': audio, 'mimetype': 'audio/m4a'}
        response = await dg_client.transcription.prerecorded(source, options={"punctuate": True})
        print(json.dumps(response, indent=4))
        return json.dumps(response, indent=4)


transcribedData = asyncio.run(transcribe_audio(PATH_TO_FILE))
with open("trancribedData.json", 'w') as jsonfile:
    jsonfile.write(transcribedData)
print("Transcribed data ready!")
jsonFile = open("trancribedData.json")
fileData = json.load(jsonFile)
print(fileData["results"]["channels"][0]["alternatives"][0]["transcript"])
filedata1 = fileData["results"]["channels"]
print(filedata1[0]["alternatives"][0]["transcript"])

I’m getting this after executing the above code. Please help me what I did wrong?

raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host api.deepgram.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1091)')]

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (9 by maintainers)

Most upvoted comments

Hi @lorcan2440 ! Happy to hear you were able to get the NodeJS SDK up and running. I’m still curious why the Python SDK wasn’t working for you. I’m really sorry you were having issues. I’m still looking into a possible cause. As always, if you ever have any questions or concerns please feel to keep reaching out to us. We’re here to help 😃