• 大小: 1.6MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-15
  • 语言: 其他
  • 标签: VS2017  C++  

资源简介

百度语音识别通过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] = ‘\0‘;

    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_reco\baidu_voice\base64.cpp

     文件        452  2014-05-29 10:51  baidu_voice_reco\baidu_voice\base64.h

     文件     331776  2017-09-08 18:02  baidu_voice_reco\baidu_voice\curl\bin\curl.exe

     文件    3001856  2017-09-07 16:43  baidu_voice_reco\baidu_voice\curl\bin\libcrypto-1_1-x64.dll

     文件     416768  2017-09-08 18:02  baidu_voice_reco\baidu_voice\curl\bin\libcurl.dll

     文件     219136  2016-11-02 16:37  baidu_voice_reco\baidu_voice\curl\bin\libssh2.dll

     文件     516608  2017-09-07 16:44  baidu_voice_reco\baidu_voice\curl\bin\libssl-1_1-x64.dll

     文件      96860  2017-08-08 00:42  baidu_voice_reco\baidu_voice\curl\include\curl\curl.h

     文件       3034  2017-08-14 08:04  baidu_voice_reco\baidu_voice\curl\include\curl\curlver.h

     文件       3473  2017-08-08 00:42  baidu_voice_reco\baidu_voice\curl\include\curl\easy.h

     文件       2071  2017-08-08 00:42  baidu_voice_reco\baidu_voice\curl\include\curl\mprintf.h

     文件      16094  2017-08-08 00:42  baidu_voice_reco\baidu_voice\curl\include\curl\multi.h

     文件       1329  2017-08-08 00:42  baidu_voice_reco\baidu_voice\curl\include\curl\stdcheaders.h

     文件      20711  2017-08-13 18:10  baidu_voice_reco\baidu_voice\curl\include\curl\system.h

     文件      42101  2017-08-08 00:42  baidu_voice_reco\baidu_voice\curl\include\curl\typecheck-gcc.h

     文件       8255  2017-09-08 18:02  baidu_voice_reco\baidu_voice\curl\lib\libcurl.exp

     文件      14074  2017-09-08 18:02  baidu_voice_reco\baidu_voice\curl\lib\libcurl.lib

     文件      11346  2017-07-26 17:40  baidu_voice_reco\baidu_voice\json\json-forwards.h

     文件      71025  2017-08-09 18:53  baidu_voice_reco\baidu_voice\json\json.h

     文件      11608  2017-09-08 18:45  baidu_voice_reco\baidu_voice\json-cpp\json\json-forwards.h

     文件      71793  2017-09-08 20:20  baidu_voice_reco\baidu_voice\json-cpp\json\json.h

     文件     157809  2017-09-08 20:03  baidu_voice_reco\baidu_voice\json-cpp\jsoncpp.cpp

     文件     156887  2017-08-09 18:53  baidu_voice_reco\baidu_voice\jsoncpp.cpp

     文件       7280  2017-09-09 12:46  baidu_voice_reco\baidu_voice\sample.cpp

     文件       1443  2017-09-09 13:22  baidu_voice_reco\baidu_voice_reco.sln

     文件       6360  2017-09-09 13:26  baidu_voice_reco\baidu_voice_reco.vcxproj

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

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

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

     目录          0  2017-09-09 13:20  baidu_voice_reco\baidu_voice\curl\include\curl

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

评论

共有 条评论