<gh_stars>1-10
import base64
import requests
import os
import json

headers = {
    "Content-Type": "application/json",
}

requests_url = "https://vop.baidu.com/server_api"

format = "wav"
rate = 16000
dev_pid = 1536
channel = 1
token = "<KEY>"
cuid = "00:0c:29:53:5f:2f"
len = os.path.getsize('16k.wav')
f = open('16k.wav', 'rb')
speech = base64.b64encode(f.read()).decode("utf-8")

payloads = {"format": format,
            "rate": rate,
            "dev_pid": dev_pid,
            "channel": channel,
            "token": token,
            "cuid": cuid,
            "len": len,
            "speech": speech, }
response = requests.post(url=requests_url, data=json.dumps(payloads), headers=headers)
print(response.json())

import base64
import requests
import os
import json

headers = {
    "Content-Type": "application/json",
}

requests_url = "https://vop.baidu.com/server_api"

format = "wav"
rate = 16000
dev_pid = 1536
channel = 1
token = "<KEY>"
cuid = "00:0c:29:53:5f:2f"
len = os.path.getsize('16k.wav')
f = open('16k.wav', 'rb')
speech = base64.b64encode(f.read()).decode("utf-8")

payloads = {"format": format,
            "rate": rate,
            "dev_pid": dev_pid,
            "channel": channel,
            "token": token,
            "cuid": cuid,
            "len": len,
            "speech": speech, }
response = requests.post(url=requests_url, data=json.dumps(payloads), headers=headers)
print(response.json())