D
D
Dmitry2016-04-11 18:12:31
Python
Dmitry, 2016-04-11 18:12:31

How to make an HTTP POST request to Yandex SpeechKit Cloud in Python 3?

Good evening. You need to transfer a voice file and recognize the text. I use Yandex SpeechKit Cloud technology.
API You
need to send a POST request. But the report keeps getting 400.
What am I doing wrong?
I am attaching the code:

import requests
from config import key

uuid = '88F1A7CB-90D9-D1B6-A40D-50465DE28C54'
url = 'https://asr.yandex.net/asr_xml?key=' + key + '&uuid=' + uuid + '&topic=queries&lang=ru-RU'
headers = {"Content-type": 'audio/x-mpeg-3'}
files = {'output.mp3': open('output.mp3', 'rb')}

tmp = requests.post(url, headers, files)
print(tmp)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nizzkos, 2016-05-05
@Flex24

https://github.com/art1415926535/Yandex_speech_api...

U
u_aleroev, 2018-08-13
@u_aleroev

import requests
from bs4 import BeautifulSoup

UNDEFINED_STRING='undefined'
KEY = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX'
#UUID можно любой (01ae13cb744628b58fb536d496daa1e6)
UUID='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'


url = 'https://asr.yandex.net/asr_xml?key=' + KEY + '&uuid=' + UUID + '&topic=queries&lang=ru-RU'
headers = {"Content-Type": 'audio/x-mpeg-3'}
#файл распознования
data = open ('test.mp3', 'rb')
    
response = requests.post(url, headers=headers, data=data)

soup = BeautifulSoup(response.text, 'html.parser')

#soup.variant
result=UNDEFINED_STRING
answers=soup.findAll('variant')
if(len(answers)>0):
    result=answers[0].text
else:
    print(UNDEFINED_STRING)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question