import requests
import json
secret_key = "SECRET_KEY"
# loads the audio into memory
with open("/path/to/your/file.mp3", mode="rb") as file:
post_body = file.read()
API_URL = "https://api.speechtext.ai/recognize?"
header = {'Content-Type': "application/octet-stream"}
options = {
"key" : secret_key,
"language" : "en-US",
"punctuation" : True,
"format" : "mp3"
}
# send an audio file to SpeechText.AI
r = requests.post(API_URL, headers = header, params = options, data = post_body)