我按照以下链接: http://zaf.github.io/asterisk-speech-recog/
现在我想使用IBM Blumix Watson Speech to Text而不是google speech-recog。 任何人都可以使用链接上提供的代码帮助我。
正在使用谷歌语音引擎。但我想使用IBM Bluemix。
#!/usr/bin/perl
use strict;
use warnings;
require LWP::UserAgent;
use WWW::Curl::Easy;
my $url = 'https://stream.watsonplatform.net/speech-to-text/api';
my $ua;
my $fh;
my $audio;
my $response;
my $headers;
my $username = 'username';
my $password = 'password';
local $ENV{'HTTPS_DEBUG'} = 1;
open($fh, "<", "test.flac") or die "Can't read file: $!";
$audio = do { local $/; <$fh> };
close($fh);
$ua = LWP::UserAgent->new;
$response = $ua->post($url, Content_Type => "audio/flac",Transfer_Encoding => "chunked", Content => $audio);
$response->authorization_basic($username, $password);
my $cont = $response->content;
print $cont;
然后它给了我输出
SSL_connect:before/connect initialization
SSL_connect:SSLv2/v3 write client hello A
SSL_connect:SSLv3 read server hello A
SSL_connect:SSLv3 read server certificate A
SSL_connect:SSLv3 read server done A
SSL_connect:SSLv3 write client key exchange A
SSL_connect:SSLv3 write change cipher spec A
SSL_connect:SSLv3 write finished A
SSL_connect:SSLv3 flush data
SSL_connect:SSLv3 read finished A
500 write failed:
答案 0 :(得分:0)
这有效:
curl -X POST -u uuuu:ppppp --header“Content-Type:audio / wav”--header“Transfer-Encoding:chunked”--data-binary @ ira_47s_16khz.wav“https://stream.watsonplatform.net/speech-to-text/api/v1/recognize?continuous=true”
我不熟悉Asterisk / Perl,但是将curl调用与代码进行比较似乎是:
主持人看起来不对劲。使用正确的URL,您应该开始收到返回消息和错误代码
内容类型略有不同
在代码中找不到数据二进制块。 (它应该在那里,因为你的代码适用于Google api)