VS2017环境集成百度语音识别API工程


百度语音识别通过REST API的方式给开发者提供一个通用的HTTP接口,基于该接口,开发者可以轻松的获取语音识别能力,本工程演示了如何在VS2017下使用语音识别服务REST API,具体介绍可见 http://blog.csdn.net/update_sh/article/details/77914559
资源截图
代码片段和文件信息
/***************************************************************************
 * 
 * Copyright (c) 2014 Baidu.com Inc. All Rights Reserved
 * 
 **************************************************************************/
 
#include “base64.h“

static const std::string base64_chars = 
             “ABCDEFGHIJKLMNOPQRSTUVWXYZ“
             “abcdefghijklmnopqrstuvwxyz“
             “0123456789+/“;


static inline bool is_base64(unsigned char c) {
  return (isalnum(c) || (c == ‘+‘) || (c == ‘/‘));
}

std::string base64_encode(unsigned char const* bytes_to_encode unsigned int in_len) {
  std::string ret;
  int i = 0;
  int j = 0;
  unsigned char char_array_3[3];
  unsigned char char_array_4[4];

  while (in_len--) {
    char_array_3[i++] = *(bytes_to_encode++);
    if (i == 3) {
      char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
      char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
      char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
      char_array_4[3] = char_array_3[2] & 0x3f;

      for(i = 0; (i <4) ; i++)
        ret += base64_chars[char_array_4[i]];
      i = 0;
    }
  }

  if (i)
  {
    for(j = i; j < 3; j++)
      char_array_3[j] = ‘‘;

    char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
    char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
    char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
    char_array_4[3] = char_array_3[2] & 0x3f;

    for (j = 0; (j < i + 1); j++)
      ret += base64_chars[char_array_4[j]];

    while((i++ < 3))
      ret += ‘=‘;

  }

  return ret;

}

std::string base64_decode(std::string const& encoded_string) {
  int in_len = encoded_string.size();
  int i = 0;
  int j = 0;
  int in_ = 0;
  unsigned char char_array_4[4] char_array_3[3];
  std::string ret;

  while (in_len-- && ( encoded_string[in_] != ‘=‘) && is_base64(encoded_string[in_])) {
    char_array_4[i++] = encoded_string[in_]; in_++;
    if (i ==4) {
      for (i = 0; i <4; i++)
        char_array_4[i] = base64_chars.find(char_array_4[i]);

      char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
      char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
      char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];

      for (i = 0; (i < 3); i++)
        ret += char_array_3[i];
      i = 0;
    }
  }

  if (i) {
    for (j = i; j <4; j++)
      char_array_4[j] = 0;

    for (j = 0; j <4; j++)
      char_array_4[j] = base64_chars.find(char_array_4[j]);

    char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
    char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
    char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];

    for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
  }

  return ret;
}



 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2935  2014-05-28 14:38  baidu_voice_recoaidu_voicease64.cpp

     文件        452  2014-05-29 10:51  baidu_voice_recoaidu_voicease64.h

     文件     331776  2017-09-08 18:02  baidu_voice_recoaidu_voicecurlincurl.exe

     文件    3001856  2017-09-07 16:43  baidu_voice_recoaidu_voicecurlinlibcrypto-1_1-x64.dll

     文件     416768  2017-09-08 18:02  baidu_voice_recoaidu_voicecurlinlibcurl.dll

     文件     219136  2016-11-02 16:37  baidu_voice_recoaidu_voicecurlinlibssh2.dll

     文件     516608  2017-09-07 16:44  baidu_voice_recoaidu_voicecurlinlibssl-1_1-x64.dll

     文件      96860  2017-08-08 00:42  baidu_voice_recoaidu_voicecurlincludecurlcurl.h

     文件       3034  2017-08-14 08:04  baidu_voice_recoaidu_voicecurlincludecurlcurlver.h

     文件       3473  2017-08-08 00:42  baidu_voice_recoaidu_voicecurlincludecurleasy.h

     文件       2071  2017-08-08 00:42  baidu_voice_recoaidu_voicecurlincludecurlmprintf.h

     文件      16094  2017-08-08 00:42  baidu_voice_recoaidu_voicecurlincludecurlmulti.h

     文件       1329  2017-08-08 00:42  baidu_voice_recoaidu_voicecurlincludecurlstdcheaders.h

     文件      20711  2017-08-13 18:10  baidu_voice_recoaidu_voicecurlincludecurlsystem.h

     文件      42101  2017-08-08 00:42  baidu_voice_recoaidu_voicecurlincludecurl ypecheck-gcc.h

     文件       8255  2017-09-08 18:02  baidu_voice_recoaidu_voicecurlliblibcurl.exp

     文件      14074  2017-09-08 18:02  baidu_voice_recoaidu_voicecurlliblibcurl.lib

     文件      11346  2017-07-26 17:40  baidu_voice_recoaidu_voicejsonjson-forwards.h

     文件      71025  2017-08-09 18:53  baidu_voice_recoaidu_voicejsonjson.h

     文件      11608  2017-09-08 18:45  baidu_voice_recoaidu_voicejson-cppjsonjson-forwards.h

     文件      71793  2017-09-08 20:20  baidu_voice_recoaidu_voicejson-cppjsonjson.h

     文件     157809  2017-09-08 20:03  baidu_voice_recoaidu_voicejson-cppjsoncpp.cpp

     文件     156887  2017-08-09 18:53  baidu_voice_recoaidu_voicejsoncpp.cpp

     文件       7280  2017-09-09 12:46  baidu_voice_recoaidu_voicesample.cpp

     文件       1443  2017-09-09 13:22  baidu_voice_recoaidu_voice_reco.sln

     文件       6360  2017-09-09 13:26  baidu_voice_recoaidu_voice_reco.vcxproj

     文件       1173  2017-09-08 19:52  baidu_voice_recoaidu_voice_reco.vcxproj.filters

     文件        375  2017-09-09 13:26  baidu_voice_recoaidu_voice_reco.vcxproj.user

     文件      52512  2014-06-06 18:51  baidu_voice_reco est.pcm

     目录          0  2017-09-09 13:20  baidu_voice_recoaidu_voicecurlincludecurl

............此处省略13个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)