如何使用 IBM Blumix Watson Speech to Text 作为 Asterisk 上的语音引擎
How to use IBM Blumix Watson Speech to Text as speech engine on Asterisk
我遵循了下面的 link:
http://zaf.github.io/asterisk-speech-recog/
现在我想使用 IBM Blumix Watson Speech to Text 而不是 google speech-recog。
任何人都可以使用 link.
上提供的代码帮助我解决这个问题
它正在使用 google 语音引擎。但我想使用 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:
这个有效:
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 您应该开始收到 return 消息和错误代码
内容类型略有不同
在代码中找不到数据二进制块。 (但是它应该在那里,因为您的代码适用于 Google api)
我遵循了下面的 link: http://zaf.github.io/asterisk-speech-recog/
现在我想使用 IBM Blumix Watson Speech to Text 而不是 google speech-recog。 任何人都可以使用 link.
上提供的代码帮助我解决这个问题它正在使用 google 语音引擎。但我想使用 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:
这个有效:
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 您应该开始收到 return 消息和错误代码
内容类型略有不同
在代码中找不到数据二进制块。 (但是它应该在那里,因为您的代码适用于 Google api)