
正文
调用 google speech api (使用Google语音识别引擎)
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
完全参考自:
http://mikepultz.com/2011/03/accessing-google-speech-api-chrome-11/
http://aiku.me/bar/10448042
附:http://src.chromium.org/viewvc/chrome/trunk/src/content/browser/speech/
curl 命令行
curl -H "Content-Type: audio/x-flac; rate=8000" "https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=en-US" -F myfile="@org.flac" -k -o 'org_xx.txt'
wget 命令行
wget -O 'org_xx.txt' --user-agent="Mozilla/5.0" --post-file=org.flac --header="Content-Type: audio/x-flac; rate=8000" "http://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=en-US"
perl脚本 myspeech
#! /usr/bin/perl
require LWP::UserAgent; my $url = "https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=en-US";
my $audio = ""; open(FILE, "<" . $ARGV[]);
while(<FILE>)
{
$audio .= $_;
}
close(FILE); my $ua = LWP::UserAgent->new; my $response = $ua->post($url, Content_Type => "audio/x-flac; rate=8000", Content => $audio); if ($response->is_success)
{
print $response->content;
}
运行方式 ./myspeech org.flac







