zoukankan      html  css  js  c++  java
  • 调用 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

     1 #! /usr/bin/perl
     2 require LWP::UserAgent;
     3 
     4 my $url = "https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=en-US";
     5 my $audio = "";
     6 
     7 open(FILE, "<" . $ARGV[0]);
     8 while(<FILE>)
     9 {
    10      $audio .= $_;
    11 }
    12 close(FILE);
    13 
    14 my $ua = LWP::UserAgent->new;
    15 
    16 my $response = $ua->post($url, Content_Type => "audio/x-flac; rate=8000", Content => $audio);
    17 
    18 if ($response->is_success)
    19 {
    20      print $response->content;
    21 }

    运行方式  ./myspeech  org.flac

  • 相关阅读:
    select详解
    java Map及Map.Entry详解
    Java 基本类型
    java 获取String出现最多次数的字段
    java 居民身份证的校验
    java 删除文件
    Java 导出excel进行换行
    获取文件及其文件路径
    List<Map<String,Object>> 中文排序
    Java ----单个list 删除元素
  • 原文地址:https://www.cnblogs.com/openix/p/3584208.html
Copyright © 2011-2022 走看看