и часть статьи - http://habrahabr.ru/blogs/hardware/129936/
во второй есть часть статьи на перле
sub toText
{
my $num = shift;
print "+OK - Trying recognize text\n";
my $curl = WWW::Curl::Easy->new;
$curl->setopt(CURLOPT_HEADER,1);
$curl->setopt(CURLOPT_POST,1);
#$curl->setopt(CURLOPT_VERBOSE, 1);
my @myheaders=();
$myheaders[0] = "Content-Type: audio/x-flac; rate=16000";
$curl->setopt(CURLOPT_HTTPHEADER, \@myheaders);
$curl->setopt(CURLOPT_URL, 'https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=ru-RU');
my $curlf = WWW::Curl::Form->new;
$curlf->formaddfile("data/input-$num.flac", 'myfile', "audio/x-flac");
$curl->setopt(CURLOPT_HTTPPOST, $curlf);
my $response_body;
$curl->setopt(CURLOPT_WRITEDATA,\$response_body);
# Starts the actual request
my $retcode = $curl->perform;
# Looking at the results...
if ($retcode == 0) {
$response_body =~ /\n\r\n(.*)/g;
my $json = $1;
my $json_xs = JSON::XS->new();
$json_xs->utf8(1);
my @hypo = $json_xs->decode($json)->{'hypotheses'};
my $dost = $hypo[0][0]{'confidence'};
my $text = $hypo[0][0]{'utterance'};
$dost = 0.0 if !defined $dost;
$text = "" if !defined $text;
print "+OK - Text is: \"$text\", confidence is: $dost\n";
if($dost > 0.5)
{
checkcmd($text);
}
{
print "+ERR - Confidence is lower, then 0.5\n";
#sayText("Комманда не распознана!");
}
} else {
# Error code, type of error, error message
print("+ERR - $retcode ".$curl->strerror($retcode)." ".$curl->errbuf);
}
system("rm data/input-$num.flac");
}
я пишу следующим образом
>>> conn = httplib.HTTPSConnection('www.google.com')
>>> d = open('demo.flac', 'rb')
>>> data = d.read()
>>> headers = {"Content-Type": "audio/x-flac; rate=16000", "User-Agent":"Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWe
bKit/533.3 (KHTML, like Gecko) Chrome/5.0.360.0 Safari/533.3"}
>>> conn.request("POST", 'speech-api/v1/recognize?xjerr=1&client=chromium&lang=ru-RU', data, headers)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python27\lib\httplib.py", line 955, in request
self._send_request(method, url, body, headers)
File "D:\Python27\lib\httplib.py", line 989, in _send_request
self.endheaders(body)
File "D:\Python27\lib\httplib.py", line 951, in endheaders
self._send_output(message_body)
File "D:\Python27\lib\httplib.py", line 811, in _send_output
self.send(msg)
File "D:\Python27\lib\httplib.py", line 787, in send
self.sock.sendall(data)
File "D:\Python27\lib\ssl.py", line 220, in sendall
v = self.send(data[count:])
File "D:\Python27\lib\ssl.py", line 189, in send
v = self._sslobj.write(data)
socket.error: [Errno 10054]
>>>