Perl 谷歌应用引擎接收音频二进制流

Perl 谷歌应用引擎接收音频二进制流,perl,google-app-engine,Perl,Google App Engine,回答后更新:代码现在已修复,请在下面查找正确的代码 我试图从一个perl脚本(在我的服务器上)发布到我的google应用程序引擎,但我不知道如何在google应用程序引擎端执行此操作 这是我用于测试的perl脚本: my $audio = `cat audiotest.flac`; my $url = "http://app.appspot.com/MainPage" #this is not the real url my $ua = LWP::UserAgent->new; my $r

回答后更新:代码现在已修复,请在下面查找正确的代码

我试图从一个perl脚本(在我的服务器上)发布到我的google应用程序引擎,但我不知道如何在google应用程序引擎端执行此操作

这是我用于测试的perl脚本:

my $audio = `cat audiotest.flac`;
my $url = "http://app.appspot.com/MainPage" #this is not the real url
my $ua = LWP::UserAgent->new;
my $response = $ua->post($url, Content_Type => "audio/x-flac; rate=16000", Content => $audio);
if ($response->is_success)
{
 print $response->content;
}
这就是我发送flac二进制流的方式,但问题是googleappengine如何接收并处理它。这就是我在python中试图做的(但代码不正确和/或没有意义)


结果应该是返回我提交给谷歌语音到文本服务(也称为x-webkit-speech)的flac音频的字符串表示形式。你知道我应该在urlfetch的有效负载中放入什么吗?以及如何返回结果?谢谢

由于您将音频文件作为请求正文而不是表单的一部分发送,因此可以使用
self.request.body
访问它


我有点困惑,为什么要将音频文件发送到App Engine,以便它可以发送到另一个服务。

我很快会尝试一下,并让您知道它是否有效。这背后的原因是我想通过谷歌的应用程序引擎,这样我就可以得到适当的账单,而不是一起被禁止使用这项服务(因为发送了大量的音频文件)。谢谢你的回答,这正是我想要的,干杯。
class MainPage(webapp.RequestHandler):  
def post(self):
    destinationURL = "http://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=en-US"
    result = urlfetch.fetch(url=destinationURL, payload= self.request.body, method=urlfetch.POST, headers={'Content-Type': 'audio/x-flac; rate=16000'})  
    self.response.out.write(result.content)