实现语音转文本,语音合成功能

master
ganshihao 5 months ago
parent 256f06f9e7
commit 30dbb4d7e0

@ -0,0 +1,30 @@
# asr-linux-cpp-demo
## 简介
Linux C++ SDK 仅有在线长语音功能,包含在线语义。没有任何离线功能。
- 仅支持x64 linux 操作系统 g++ 4.8 以上版本
在centos 4 6 7 及ubuntu 14.04 g++ 4.8 版本测试通过
**SDK内部限制个线程并发即最多支持个音频的实时识别。 **
## 运行
sample目录下有三个实例工程
sample/asr 运行 sh build_and_run.sh
sample/asrDemo2 下 run目录中运行 sh build_and_run.sh 。同时也是为Clion工程
sample/asrDemo-srt 阅读该目录下的readme文件再运行
## 完整文档
http://ai.baidu.com/docs#/ASR-Linux-SDK/top
## 项目地址
https://github.com/Baidu-AIP/asr-linux-cpp-demo

@ -0,0 +1,2 @@
3.0.0.30628d440-V1
1. 新增自训练平台支持LMID参数

@ -0,0 +1,6 @@
cd sample
cd asr && make clean && rm core main *.log
cd ..
cd asrDemo2/run && make clean
cd ../..
cd asrDemo-srt && rm -rf run/*

@ -0,0 +1,234 @@
//
// bds_ASRDefines.hpp
// SDKTester
//
// Created by baidu on 16/2/23.
// Copyright © 2016年 baidu. All rights reserved.
//
#ifndef bds_ASRDefines_h
#define bds_ASRDefines_h
#include <string>
//#include "bds_int_types.h"
#include <stdint.h>
namespace bds {
#pragma mark - 设定采样率
typedef enum TBDVoiceRecognitionRecordSampleRateFlags
{
EVoiceRecognitionRecordSampleRateAuto = 0,
EVoiceRecognitionRecordSampleRate8K,
EVoiceRecognitionRecordSampleRate16K,
} TBDVoiceRecognitionRecordSampleRateFlags;
#pragma mark - 语音识别类型
typedef enum TBDVoiceRecognitionProperty
{
EVoiceRecognitionPropertyMusic = 10001, // 音乐
EVoiceRecognitionPropertyVideo = 10002, // 视频
EVoiceRecognitionPropertyApp = 10003, // 应用
EVoiceRecognitionPropertyWeb = 10004, // web
EVoiceRecognitionPropertySearch = 10005, // 热词
EVoiceRecognitionPropertyEShopping = 10006, // 电商&购物
EVoiceRecognitionPropertyHealth = 10007, // 健康&母婴
EVoiceRecognitionPropertyCall = 10008, // 打电话
EVoiceRecognitionPropertySong = 10009, // 录歌识别
EVoiceRecognitionPropertyShake = 10010, // 摇一摇拾台
EVoiceRecognitionPropertyMedicalCare = 10052, // 医疗
EVoiceRecognitionPropertyCar = 10053, // 汽车
EVoiceRecognitionPropertyCatering = 10054, // 娱乐餐饮
EVoiceRecognitionPropertyFinanceAndEconomics = 10055, // 财经
EVoiceRecognitionPropertyGame = 10056, // 游戏
EVoiceRecognitionPropertyCookbook = 10057, // 菜谱
EVoiceRecognitionPropertyAssistant = 10058, // 助手
EVoiceRecognitionPropertyRecharge = 10059, // 话费充值
EVoiceRecognitionPropertyMap = 10060, // 地图
EVoiceRecognitionPropertyInput = 20000, // 输入
// 离线垂类
EVoiceRecognitionPropertyContacts = 100014, // 联系人指令
EVoiceRecognitionPropertySetting = 100016, // 手机设置
EVoiceRecognitionPropertyTVInstruction = 100018, // 电视指令
EVoiceRecognitionPropertyPlayerInstruction = 100019, // 播放器指令
EVoiceRecognitionPropertyRadio = 100020, // 收音机
} TBDVoiceRecognitionProperty;
#pragma mark - 设置识别语言
typedef enum TBDVoiceRecognitionLanguage
{
EVoiceRecognitionLanguageChinese = 0,
EVoiceRecognitionLanguageCantonese,
EVoiceRecognitionLanguageEnglish,
EVoiceRecognitionLanguageSichuanDialect,
} TBDVoiceRecognitionLanguage;
#pragma mark - 语音识别请求资源类型
typedef enum TBDVoiceRecognitionProtocol
{
EPROTOCOL_DEFAULT = 0,
EPROTOCOL_SEARCH_NBEST = 1,
EPROTOCOL_INPUT_NBEST_PROTOCOL = 2,
EPROTOCOL_POST_PROTOCOL = 101,
EPROTOCOL_WISE_PROTOCOL = 300,
EPROTOCOL_WISE_TEXT_PROTOCOL = 301,
EPROTOCOL_AUDIO_DA_PROTOCOL = 302,
EPROTOCOL_NLU_PROTOCOL = 303,
EPROTOCOL_NLU_TEXT_PROTOCOL = 304,
EPROTOCOL_WISE_NLU_PROTOCOL = 305,
EPROTOCOL_TALK_PROTOCOL = 306,
EPROTOCOL_SEARCH_MUSIC_PROTOCOL = 1000,
} TBDVoiceRecognitionProtocol;
#pragma mark - 调试日志级别
typedef enum TBDVoiceRecognitionDebugLogLevel
{
EVRDebugLogLevelOff = 0,
EVRDebugLogLevelFatal = 1,
EVRDebugLogLevelError = 2,
EVRDebugLogLevelWarning = 3,
EVRDebugLogLevelInformation = 4,
EVRDebugLogLevelDebug = 5,
EVRDebugLogLevelTrace = 6
} TBDVoiceRecognitionDebugLogLevel;
#pragma mark - 语音识别状态
typedef enum TBDVoiceRecognitionClientWorkStatus
{
EVoiceRecognitionClientWorkStatusStartWorkIng, // 识别工作开始,开始采集及处理数据
EVoiceRecognitionClientWorkStatusStart, // 检测到用户开始说话
EVoiceRecognitionClientWorkStatusEnd, // 本地声音采集结束,等待识别结果返回并结束录音
EVoiceRecognitionClientWorkStatusNewRecordData, // 录音数据回调
EVoiceRecognitionClientWorkStatusFlushData, // 连续上屏
EVoiceRecognitionClientWorkStatusFinish, // 语音识别功能完成,服务器返回正确结果
EVoiceRecognitionClientWorkStatusMeterLevel, // 当前音量回调
EVoiceRecognitionClientWorkStatusCancel, // 用户取消
EVoiceRecognitionClientWorkStatusError, // 发生错误
/* 离线引擎状态 */
EVoiceRecognitionClientWorkStatusLoaded, // 离线引擎加载完成
EVoiceRecognitionClientWorkStatusUnLoaded, // 离线引擎卸载完成
/* CHUNK状态 */
EVoiceRecognitionClientWorkStatusChunkThirdData, // CHUNK: 识别结果中的第三方数据
EVoiceRecognitionClientWorkStatusChunkVPRes, // CHUNK: 声纹会议返回信息 vp_res
EVoiceRecognitionClientWorkStatusChunkNlu, // CHUNK: 识别结果中的语义结果
EVoiceRecognitionClientWorkStatusChunkEnd, // CHUNK: 识别过程结束
/* LOG */
EVoiceRecognitionClientWorkStatusFeedback, // Feedback: 识别过程反馈的打点数据
/* Only for iOS */
EVoiceRecognitionClientWorkStatusRecorderEnd, // 录音机关闭,页面跳转需检测此时间,规避状态条 (iOS)
/* LONG SPEECH END */
EVoiceRecognitionClientWorkStatusLongSpeechEnd // 长语音结束状态
} TBDVoiceRecognitionClientWorkStatus;
#pragma mark - 语音识别策略
typedef enum TBDVoiceRecognitionStrategy
{
EVR_STRATEGY_ONLINE = 0, // 在线识别
EVR_STRATEGY_OFFLINE, // 离线识别
EVR_STRATEGY_ONLINE_PRI, // 在线优先
EVR_STRATEGY_OFFLINE_PRI, // 离线优先
EVR_STRATEGY_BOTH, // 并行模式
} TBDVoiceRecognitionStrategy;
#pragma mark - 语音识别离线引擎类型
typedef enum TBDVoiceRecognitionOfflineEngineType
{
EVR_OFFLINE_ENGINE_INPUT = 0, // 离线引擎输入法模式
EVR_OFFLINE_ENGINE_NAVI, // 离线引擎导航模式
EVR_OFFLINE_ENGINE_GRAMMER, // 离线引擎语法模式
} TBDVoiceRecognitionOfflineEngineType;
#pragma mark - 识别结果类型
typedef enum TBDVoiceRecognitionResultType
{
EVR_RESULT_TYPE_ERROR = -1, // Error code
EVR_RESULT_TYPE_EMPTY = 0, // Empty reply
EVR_RESULT_TYPE_PARTIAL = 1, // Partial result
EVR_RESULT_TYPE_NBEST = 2, // Nbest result
EVR_RESULT_TYPE_CN = 3, // CN result
EVR_RESULT_TYPE_RESOURCE = 4, // NLU & resource result
EVR_RESULT_TYPE_THIRD = 5, // CHUNK: Third party data
EVR_RESULT_TYPE_FINISH = 6, // CHUNK: Finish
EVR_RESULT_TYPE_END = 7, // CHUNK: End
EVR_RESULT_TYPE_VP_RES = 8, // vp_res
} TBDVoiceRecognitionResultType;
#pragma mark - 网络类型
typedef enum TBDVoiceRecognitionNetworkType
{
EVR_NETWORK_TYPE_NO = 0,
EVR_NETWORK_TYPE_2G,
EVR_NETWORK_TYPE_3G,
EVR_NETWORK_TYPE_4G,
EVR_NETWORK_TYPE_WIFI,
} TBDVoiceRecognitionNetworkType;
#pragma mark - 语音压缩类型
typedef enum TBDVoiceRecognitionAudioCompressionType
{
EVR_AUDIO_COMPRESSION_MIN = 0,
EVR_AUDIO_COMPRESSION_PCM = 1,
EVR_AUDIO_COMPRESSION_BV32 = 2,
EVR_AUDIO_COMPRESSION_AMR = 3,
EVR_AUDIO_COMPRESSION_MAX = 4,
} TBDVoiceRecognitionAudioCompressionType;
#pragma mark - 语音识别错误通知状态分类
typedef enum TVoiceRecognitionClientErrorDomain
{
EVRClientErrorDomainRecord = 10, // 录音设备出错
EVRClientErrorDomainVAD = 20, // 语音数据处理过程出错
EVRClientErrorDomainOnline = 30, // 在线识别引擎出错
EVRClientErrorDomainLocalNetwork = 31, // 本地网络联接出错
EVRClientErrorDomainHTTP = 32, // HTTP协议错误
EVRClientErrorDomainServer = 33, // 服务器返回错误
EVRClientErrorDomainOffline = 34, // 离线引擎返回错误
EVRClientErrorDomainCommon = 40, // 其他错误
} TVoiceRecognitionClientErrorDomain;
#pragma mark - 语音识别错误通知状态
typedef enum TVoiceRecognitionClientErrorCode
{
EVRClientErrorCodeRecoderException = (EVRClientErrorDomainRecord << 16) | (0x0000FFFF & 1), // 录音设备异常
EVRClientErrorCodeRecoderNoPermission = (EVRClientErrorDomainRecord << 16) | (0x0000FFFF & 2), // 无录音权限
EVRClientErrorCodeRecoderUnAvailable = (EVRClientErrorDomainRecord << 16) | (0x0000FFFF & 3), // 录音设备不可用
EVRClientErrorCodeInterruption = (EVRClientErrorDomainRecord << 16) | (0x0000FFFF & 4), // 录音中断
EVRClientErrorCodeVADException = (EVRClientErrorDomainVAD << 16) | (0x0000FFFF & 1), // 前端库异常
EVRClientErrorCodeNoSpeech = (EVRClientErrorDomainVAD << 16) | (0x0000FFFF & 2), // 用户未说话
EVRClientErrorCodeShort = (EVRClientErrorDomainVAD << 16) | (0x0000FFFF & 3), // 用户说话声音太短
EVRClientErrorCodeOnlineExceptioin = (EVRClientErrorDomainOnline << 16) | (0x0000FFFF & 1), // 在线识别引擎异常
EVRClientErrorCodeOnlineNetworkUnavailable = (EVRClientErrorDomainOnline << 16) | (0x0000FFFF & 2), // 网络不可用
EVRClientErrorCodeOnlineTokenFailed = (EVRClientErrorDomainOnline << 16) | (0x0000FFFF & 3), // 获取token失败
EVRClientErrorCodeOnlineResolveUrlFailed = (EVRClientErrorDomainOnline << 16) | (0x0000FFFF & 4), // 解析url失败
EVRClientErrorCodeLocalTimeout = (EVRClientErrorDomainLocalNetwork << 16) | (0x0000FFFF & 1), // 请求超时
EVRClientErrorCodeServerParamError = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3001), // 协议参数错误
EVRClientErrorCodeServerRecognError = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3002), // 识别过程出错
EVRClientErrorCodeServerNoFindResult = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3003), // 没有找到匹配结果
EVRClientErrorCodeServerAppNameUnknownError = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3004), // AppnameUnkown错误
EVRClientErrorCodeServerSpeechQualityProblem = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3005), // 声音不符合识别要求
EVRClientErrorCodeServerSpeechTooLong = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3006), // 语音过长
EVRClientErrorCodeServerSpeechParamsUnknow = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3008), // 上行参数未知,(可能是gzip解压失败)
EVRClientErrorCodeServerSpeechNoUploadLink = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3011), // 只有下行链接没有上行链接
EVRClientErrorCodeCommonBusy = (EVRClientErrorDomainCommon << 16) | (0x0000FFFF & 4095), // 识别器忙
EVRClientErrorCodeCommonPropertyListInvalid = (EVRClientErrorDomainCommon << 16) | (0x0000FFFF & 2), // 垂类设置有误
EVRClientErrorCodeCommonEnqueueError = (EVRClientErrorDomainCommon << 16) | (0x0000FFFF & 3) // 语音数据enqueue失败
} TVoiceRecognitionClientErrorCode;
#pragma mark -- INTERNAL DEFINES
#pragma mark - 语音识别模式
typedef enum TBDVoiceRecognitionMode {
EVR_MODE_MULTI_SENTENCE = 0,
EVR_MODE_SINGLE_SENTENCE,
EVR_MODE_MUSIC,
EVR_MODE_SHAKE,
} TBDVoiceRecognitionMode;
}
#endif /* bds_ASRDefines_h */

@ -0,0 +1,54 @@
//
// bds_WakeupDefines.hpp
// BDASRCore
//
// Created by baidu on 16/5/20.
// Copyright © 2016年 baidu. All rights reserved.
//
#ifndef bds_WakeupDefines_hpp
#define bds_WakeupDefines_hpp
namespace bds {
#pragma mark - 唤醒引擎状态
typedef enum TWakeupEngineWorkStatus
{
EWakeupEngineWorkStatusStarted, // 引擎开始工作
EWakeupEngineWorkStatusStopped, // 引擎关闭完成
EWakeupEngineWorkStatusLoaded, // 唤醒引擎加载完成
EWakeupEngineWorkStatusUnLoaded, // 唤醒引擎卸载完成
EWakeupEngineWorkStatusTriggered, // 命中唤醒词
EWakeupEngineWorkStatusError, // 引擎发生错误
} TWakeupEngineWorkStatus;
#pragma mark - 唤醒引擎错误分类
typedef enum TWakeupEngineErrorDomain
{
EWakeupEngineErrorDomainRecord = 10, // 录音设备出错
EWakeupEngineErrorDomainEngine = 38, // 录音设备出错
} TWakeupEngineErrorDomain;
#pragma mark - 唤醒引擎错误状态
typedef enum TWakeupEngineErrorCode
{
EWakeupEngineRecoderException = (EWakeupEngineErrorDomainRecord << 16) | (0x0000FFFF & 1), // 录音设备异常
EWakeupEngineRecoderNoPermission = (EWakeupEngineErrorDomainRecord << 16) | (0x0000FFFF & 2), // 无录音权限
EWakeupEngineRecoderUnAvailable = (EWakeupEngineErrorDomainRecord << 16) | (0x0000FFFF & 3), // 录音设备不可用
EWakeupEngineRecoderInterruption = (EWakeupEngineErrorDomainRecord << 16) | (0x0000FFFF & 4), // 录音中断
EWakeupEngineExceptioin = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 1), // 唤醒引擎异常
EWakeupEngineNoLicense = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 2), // 无授权文件
EWakeupEngineLicenseInvalid = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 3), // 授权文件异常
EWakeupEngineWakeupWordsInvalid = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 4), // 唤醒次异常
EWakeupEngineDatFileInvalid = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 5), // 模型文件异常
EWakeupEngineInitializeFailed = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 6), // 引擎初始化失败
EWakeupEngineAllocMemFailed = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 7), // 内存分配失败
EWakeupEngineResetFailed = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 8), // 引擎重置失败
EWakeupEngineFreeFailed = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 9), // 引擎释放失败
EWakeupEngineArchiNotSupportted = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 10), // 引擎不支持该架构
} TWakeupEngineErrorCode;
}
#endif /* bds_WakeupDefines_hpp */

@ -0,0 +1,581 @@
#ifndef _BD_ASR_DEFINITIONS_H_
#define _BD_ASR_DEFINITIONS_H_
#include <string>
namespace bds {
/*
* SDKType definition to load ASR SDK from
* BDSpeechSDK::get_instance(const std::string &SDKType, std::string &outErrorDescription);
*/
extern const std::string SDK_TYPE_ASR;
/*================================ Message names for using ASR SDK ===============================*/
extern const std::string ASR_CMD_CONFIG;
extern const std::string ASR_CMD_START;
extern const std::string ASR_CMD_PUSH_AUDIO;
extern const std::string ASR_CMD_STOP;
extern const std::string ASR_CMD_CANCEL;
extern const std::string ASR_CMD_KWS_LOAD;
extern const std::string ASR_CMD_KWS_UNLOAD;
extern const std::string BDS_COMMAND_SET_WRITABLE_LIBRARY_DATA_PATH;
/*=============================== Message names for Events from ASR ==============================*/
extern const std::string asr_callback_name;
extern const std::string CALLBACK_ASR_STATUS;
extern const std::string CALLBACK_ASR_RESULT;
extern const std::string CALLBACK_ASR_LEVEL;
extern const std::string CALLBACK_ERROR_DESC;
extern const std::string CALLBACK_ERROR_CODE;
extern const std::string CALLBACK_ERROR_DOMAIN;
extern const std::string CALLBACK_ERROR_SERIAL_NUM;
/*================================ ASR SDK parameter keys ===============================*/
/*
* ASR_PARAM_KEY_CHUNK_KEY
* Value explanation: Chunk
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_CHUNK_KEY;
/*
* ASR_PARAM_KEY_CUID
* Value explanation: CUID
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_CUID;
/*
* ASR_PARAM_KEY_CHUNK_PARAM
* Value explanation: Chunk
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_CHUNK_PARAM;
/*
* ASR_PARAM_KEY_CHUNK_ENABLE
* Value explanation: Chunk
* Value type: int
* Valid value: Enable (1) or Disable (0)
* Default value: 0
*/
extern const std::string ASR_PARAM_KEY_CHUNK_ENABLE;
/*
* ASR_PARAM_KEY_ENABLE_LONG_SPEECH
* Value explanation:
* Value type: bool
* Valid value: Enable (1) or Disable (0)
* Default value: 0
*/
extern const std::string ASR_PARAM_KEY_ENABLE_LONG_SPEECH;
extern const std::string BDS_PARAM_KEY_WRITABLE_LIBRARY_DATA_PATH;
/*
* ASR_PARAM_KEY_SAVE_AUDIO_ENABLE
* Value explanation: ASR
* Value type: bool
* Default value: false
*/
extern const std::string ASR_PARAM_KEY_SAVE_AUDIO_ENABLE;
/*
* ASR_PARAM_KEY_SAVE_AUDIO_PATH
* Value explanation: ASR
* Value type: string
* Default value: "./sdk_save_audio.d"
*/
extern const std::string ASR_PARAM_KEY_SAVE_AUDIO_PATH;
/*================================ Params with Command ===============================*/
/*
* ASR_PARAM_KEY_REALTIME_DATA
* Value explanation:
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_REALTIME_DATA;
/*================================ Debug ===============================*/
/*
* COMMON_PARAM_KEY_DEBUG_LOG_LEVEL
* Value explanation:
* Value type: TBDVoiceRecognitionDebugLogLevel (int)
* Valid value: Be listed in enum TBDVoiceRecognitionDebugLogLevel
* Default value: EVRDebugLogLevelOff
*/
extern const std::string COMMON_PARAM_KEY_DEBUG_LOG_LEVEL;
/*================================ AUDIO ===============================*/
/*
* MIC_PARAM_KEY_AUDIO_FILE_PATH
* Value explanation:
* Value type: std::string
* Default value: -
*/
extern const std::string MIC_PARAM_KEY_AUDIO_FILE_PATH;
/*
* MIC_PARAM_KEY_NEED_CACHE
* Value explanation: Need cached data in recorder.
* Value type: int
* Value requirement: Optional
* Default value: 0
*/
extern const std::string MIC_PARAM_KEY_NEED_CACHE;
/*
* MIC_PARAM_KEY_DISABLE_AUDIO_OPERATION
* Value explanation: Disable sdk audio operation (Set audio session disactive).
* Value type: int
* Value requirement: Optional
* Default value: 0
*/
extern const std::string MIC_PARAM_KEY_DISABLE_AUDIO_OPERATION;
/*================================ BASIC ===============================*/
/*
* ASR_PARAM_KEY_SDK_VERSION
* Value explanation: SDK version
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_SDK_VERSION;
/*
* ASR_PARAM_KEY_START_TONE
* Value explanation:
* Value type: int
* Valid value: Enable (1) or Disable (0)
* Default value: 0
*/
extern const std::string ASR_PARAM_KEY_START_TONE;
/*
* ASR_PARAM_KEY_STRATEGY
* Value explanation:
* Value type: TBDVoiceRecognitionStrategy (int)
* Valid value: Be listed in enum TBDVoiceRecognitionStrategy
* Default value: EVR_STRATEGY_ONLINE
*/
extern const std::string ASR_PARAM_KEY_STRATEGY;
/*
* ASR_PARAM_KEY_SAMPLE_RATE
* Value explanation:
* Value type: TVoiceRecognitionRecordSampleRateFlags (int)
* Valid value: Be listed in enum TVoiceRecognitionRecordSampleRateFlags
* Default value: EVoiceRecognitionRecordSampleRate16K
*/
extern const std::string ASR_PARAM_KEY_SAMPLE_RATE;
/*================================ VAD-MFE ===============================*/
/*
* ASR_PARAM_KEY_MAX_SPEECH_PAUSE
* Value explanation:
* Value type: float (10ms
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_MAX_SPEECH_PAUSE;
/*
* ASR_PARAM_KEY_MAX_WAIT_DURATION
* Value explanation:
* Value type: float (10ms)
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_MAX_WAIT_DURATION;
/*
* ASR_PARAM_KEY_MFE_DNN_DAT_FILE
* Value explanation: MFE
* Value type: string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_MFE_DNN_DAT_FILE;
/*
* ASR_PARAM_KEY_MFE_CMVN_DAT_FILE
* Value explanation: MFE CMVN
* Value type: string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_MFE_CMVN_DAT_FILE;
/*================================ SERVER FUNCTIONS ===============================*/
/*
* ASR_PARAM_KEY_DISABLE_PUNCTUATION
* Value explanation:
* Value type: int
* Valid Value: Disable (1) or Not Disable (0)
* Default value: 0
*/
extern const std::string ASR_PARAM_KEY_DISABLE_PUNCTUATION;
/*
* ASR_PARAM_KEY_ENABLE_SERVER_VAD
* Value explanation: VAD
* Value type: int
* Valid Value: Enable (1) or Disable (0)
* Default value: 1
* VADSDK
*/
extern const std::string ASR_PARAM_KEY_ENABLE_SERVER_VAD;
/*
* ASR_PARAM_KEY_ENABLE_CONTACTS
* Value explanation:
* Value type: int
* Valid Value: Enable (1) or Disable (0)
* Default value: 0
*/
extern const std::string ASR_PARAM_KEY_ENABLE_CONTACTS;
/*
* ASR_PARAM_KEY_ENABLE_EARLY_RETURN
* Value explanation:
* Value type: int
* Valid Values: Enable (1) or Disable (0)
* Default value: 1
*/
extern const std::string ASR_PARAM_KEY_ENABLE_EARLY_RETURN;
/*================================ SERVER ===============================*/
/*
* ASR_PARAM_KEY_API_SECRET_KEY
* Value explanation: SECRET_KEY
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_SECRET_KEY;
/*
* ASR_PARAM_KEY_SERVER_URL
* Value explanation:
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_SERVER_URL;
/*
* ASR_PARAM_KEY_BROWSER_UA
* Value explanation: (Http request header)UA
* Value type: std::string
* Default value: -[UIWebView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"]
*/
extern const std::string ASR_PARAM_KEY_BROWSER_USER_AGENT;
/*
* ASR_PARAM_KEY_APP_ID
* Value explanation: APP_ID
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_APP_ID;
/*
* ASR_PARAM_KEY_LMID
* Value explanation: LMID
* Value type: int
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_LMID;
/*
* ASR_PARAM_KEY_VP_PARAMS
* Value explanation: vp_params
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_VP_PARAMS;
/*
* ASR_PARAM_KEY_API_KEY
* Value explanation: API_KEY
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_API_KEY;
/*================================ Recognition ===============================*/
/*
* ASR_PARAM_KEY_PROPERTY_LIST
* Value explanation:
* Value type: std::string(JSON array)
* Default value: {"property_list":[EVoiceRecognitionPropertySearch]}
* NOTE: Give a JSON string containing "property_list" key. The value for this key
* should be a json array of integers.\
*
*Example: To pass in EVoiceRecognitionPropertyMusic
* and EVoiceRecognitionPropertyVideo the JSON should be as follows:
* {"property_list":[10001,10002]}
*/
extern const std::string ASR_PARAM_KEY_PROPERTY_LIST;
/*
* ASR_PARAM_KEY_PRODUCT_ID
* Value explanation: ID
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_PRODUCT_ID;
/*
* ASR_PARAM_KEY_CITY_ID
* Value explanation: ID
* Value type: int
* Default value: 1
*/
extern const std::string ASR_PARAM_KEY_CITY_ID;
/*
* ASR_PARAM_KEY_PROTOCOL
* Value explanation:
* Value type: TBDVoiceRecognitionProtocol (int)
* Valid value: Be listed in enum TBDVoiceRecognitionProtocol
* Default value: EPROTOCOL_DEFAULT
*/
extern const std::string ASR_PARAM_KEY_PROTOCOL;
/*
* ASR_PARAM_KEY_LANGUAGE
* Value explanation:
* Value type: TBDVoiceRecognitionLanguage (int)
* Valid value: Be listed in enum TBDVoiceRecognitionLanguage
* Default value: EVoiceRecognitionLanguageChinese
*/
extern const std::string ASR_PARAM_KEY_LANGUAGE;
/*
* ASR_PARAM_KEY_ENABLE_NLU
* Value explanation: json
* Value type: int
* Valid value: Enable (1) or Disable (0)
* Default value: 0
*/
extern const std::string ASR_PARAM_KEY_ENABLE_NLU;
/*
* ASR_PARAM_KEY_ENABLE_LOCAL_VAD
* Value explanation:
* Value type: int
* Valid value: Enable (1) or Disable (0)
* Default value: 1
*/
extern const std::string ASR_PARAM_KEY_ENABLE_LOCAL_VAD;
/*
* ASR_PARAM_KEY_ENABLE_MODEL_VAD
* Value explanation: 使modelVAD
* Value type: int
* Valid value: Enable (1) or Disable (0)
* Default value: 0
*/
extern const std::string ASR_PARAM_KEY_ENABLE_MODEL_VAD;
/*
* ASR_PARAM_KEY_MODEL_VAD_DAT_FILE
* Value explanation: modelVAD
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_MODEL_VAD_DAT_FILE;
/*
* ASR_PARAM_KEY_COMPRESSION_TYPE
* Value explanation:
* Value type: TBDVoiceRecognitionAudioCompressionType (int)
* Valid value: Be listed in enum TBDVoiceRecognitionAudioCompressionType
* Default value: EVR_AUDIO_COMPRESSION_BV32
*/
extern const std::string ASR_PARAM_KEY_COMPRESSION_TYPE;
/*
* ASR_PARAM_KEY_ENABLE_DRC
* Value explanation:
* Value type: int
* Valid value: Enable (1) or Disable (0)
* Default value: 1
*/
extern const std::string ASR_PARAM_KEY_ENABLE_DRC;
/*================================ 扩展参数 ===============================*/
/*
* ASR_PARAM_KEY_PAM
* Value explanation:
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_PAM;
/*
* ASR_PARAM_KEY_STC
* Value explanation:
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_STC;
/*
* ASR_PARAM_KEY_LTP
* Value explanation: uid
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_LTP;
/*
* ASR_PARAM_KEY_TXT
* Value explanation:
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_TXT;
/*
* ASR_PARAM_KEY_BUA
* Value explanation: , use for wise
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_BUA;
/*================================ Configuration for contract with server ===============================*/
/*
* ASR_PARAM_KEY_NETWORK_STATUS
* Value explanation:
* Value type: TBDVoiceRecognitionNetworkType (int)
* Valid value: Be listed in enum TBDVoiceRecognitionNetworkType
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_NETWORK_STATUS;
/*
* ASR_PARAM_KEY_APP
* Value explanation: App name
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_APP;
/*
* ASR_PARAM_KEY_PLATFORM
* Value explanation: Platform
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_PLATFORM;
/*
* ASR_PARAM_KEY_COK
* Value explanation: Cookie, use for wise
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_COK;
/*
* ASR_PARAM_KEY_PU
* Value explanation: Pu, use for wise
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_PU;
/*
* ASR_PARAM_KEY_FRM
* Value explanation: From, use for wise
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_FRM;
/*
* ASR_PARAM_KEY_RSV
* Value explanation: Reserve, use for wise
* Value type: std::string (json)
* Default value: -
* Note: Give a json formatted string containing string parameters with keys.
* Example: To pass in 2 parameters (reserved_1 and reserved_2 with values "value 1" and "value 2")
* pass following json string.
* {"reserved_1":"value 1","reserved_2":"value 2"}
*/
extern const std::string ASR_PARAM_KEY_RSV;
/*================================ Offline Engine Verify ===============================*/
/*
* OFFLINE_PARAM_KEY_APP_CODE
* Value explanation: 线APPCODE
* Value type: std::string
* Default value: -
*/
extern const std::string OFFLINE_PARAM_KEY_APP_CODE;
/*
* OFFLINE_PARAM_KEY_LICENSE_FILE_PATH
* Value explanation: 线
* Value type: std::string
* Default value: -
*/
extern const std::string OFFLINE_PARAM_KEY_LICENSE_FILE_PATH;
/*================================ Offline Engine KWS ===============================*/
/*
* ASR_PARAM_KEY_OFFLINE_ENGINE_TYPE
* Value explanation: 线
* Value type: TBDVoiceRecognitionOfflineEngineType (int)
* Valid value: Be listed in enum TBDVoiceRecognitionOfflineEngineType
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_OFFLINE_ENGINE_TYPE;
/*
* ASR_PARAM_KEY_OFFLINE_ENGINE_DAT_FILE_PATH
* Value explanation: 线
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_OFFLINE_ENGINE_DAT_FILE_PATH;
/*
* ASR_PARAM_KEY_OFFLINE_ENGINE_GRAMMER_FILE_PATH
* Value explanation: 线
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_OFFLINE_ENGINE_GRAMMER_FILE_PATH;
/*
* ASR_PARAM_KEY_OFFLINE_ENGINE_GRAMMER_SLOT
* Value explanation: 线
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_OFFLINE_ENGINE_GRAMMER_SLOT;
/*
* ASR_PARAM_KEY_OFFLINE_ENGINE_WAKEUP_WORDS_FILE_PATH
* Value explanation: 使使线
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_OFFLINE_ENGINE_WAKEUP_WORDS_FILE_PATH;
/*
* ASR_PARAM_KEY_OFFLINE_ENGINE_TRIGGERED_WAKEUP_WORD
* Value explanation:
* Value type: std::string
* Default value: -
*/
extern const std::string ASR_PARAM_KEY_OFFLINE_ENGINE_TRIGGERED_WAKEUP_WORD;
extern const std::string PARAM_TYPE_MAX_ASR_INSTANCE_NUM;
}
#endif

@ -0,0 +1,137 @@
//
// bds_WakeupParameters.hpp
// BDASRCore
//
// Created by baidu on 16/5/19.
// Copyright © 2016年 baidu. All rights reserved.
//
#ifndef bds_WakeupParameters_hpp
#define bds_WakeupParameters_hpp
#include <string>
namespace bds {
/*
* SDKType definition to load Wakeup SDK from
* BDSpeechSDK::get_instance(const std::string &SDKType, std::string &outErrorDescription);
*/
extern const std::string SDK_TYPE_WAKEUP;
/*================================ Message names for using Wakeup SDK ===============================*/
extern const std::string WAK_CMD_CONFIG;
extern const std::string WAK_CMD_START;
extern const std::string WAK_CMD_PUSH_AUDIO;
extern const std::string WAK_CMD_STOP;
extern const std::string WAK_CMD_LOAD_ENGINE;
extern const std::string WAK_CMD_UNLOAD_ENGINE;
extern const std::string BDS_COMMAND_SET_WRITABLE_LIBRARY_DATA_PATH;
extern const std::string BDS_COMMAND_GET_EVENT_MANAGER_VERSION;
/*============================= Message names for events from Wakeup SDK ============================*/
extern const std::string wakeup_callback_name;
extern const std::string CALLBACK_WAK_STATUS;
extern const std::string CALLBACK_WAK_RESULT;
extern const std::string CALLBACK_ERROR_DESC;
extern const std::string CALLBACK_ERROR_DOMAIN;
extern const std::string CALLBACK_ERROR_CODE;
extern const std::string BDS_CALLBACK_EVENT_MANAGER_VERSION;
/*================================ Wakeup command parameters ===============================*/
#pragma mark - Debug
/*
* COMMON_PARAM_KEY_DEBUG_LOG_LEVEL
* Value explanation:
* Value type: TBDVoiceRecognitionDebugLogLevel (int)
* Default value: EVRDebugLogLevelOff
*/
extern const std::string COMMON_PARAM_KEY_DEBUG_LOG_LEVEL;
#pragma mark - Offline Engine Verify
/*
* OFFLINE_PARAM_KEY_APP_CODE
* Value explanation: 线APPCODE
* Value type: std::string
* Default value: -
*/
extern const std::string OFFLINE_PARAM_KEY_APP_CODE;
/*
* OFFLINE_PARAM_KEY_LICENSE_FILE_PATH
* Value explanation: 线
* Value type: std::string
* Default value: -
*/
extern const std::string OFFLINE_PARAM_KEY_LICENSE_FILE_PATH;
/*
* OFFLINE_PARAM_KEY_APP_NAME
* Value explanation: 线APPNAME (Linux)
* Value type: std::string
* Default value: -
*/
extern const std::string OFFLINE_PARAM_KEY_APP_NAME;
/*
* OFFLINE_PARAM_KEY_CUID
* Value explanation: 线CUID (Android)
* Value type: std::string
* Default value: -
*/
extern const std::string OFFLINE_PARAM_KEY_CUID;
/*
* OFFLINE_PARAM_KEY_JNI_CONTEXT
* Value explanation: 线JNI_CONTEXT (Android)
* Value type: std::string
* Default value: -
*/
extern const std::string OFFLINE_PARAM_KEY_JNI_CONTEXT;
#pragma mark - Offline Engine Wakeup
/*
* WP_PARAM_KEY_ENABLE_DNN_WAKEUP
* Value explanation: 使DNN
* Value type: bool
* Default value: false
*/
extern const std::string WP_PARAM_KEY_ENABLE_DNN_WAKEUP;
/*
* WP_PARAM_KEY_WAKEUP_WORDS
* Value explanation:
* Value type: std::vector
* Value type: std::string (json format list of words, UTF-8 encoded, list key "words")
* Default value: -
* Example: std::string("{\"words\":[\"小度你好\",\"百度你好\"]}")
*/
extern const std::string WP_PARAM_KEY_WAKEUP_WORDS;
/*
* WP_PARAM_KEY_WAKEUP_WORDS_FILE_PATH
* Value explanation:
* Value type: std::string
* Default value: -
*/
extern const std::string WP_PARAM_KEY_WAKEUP_WORDS_FILE_PATH;
/*
* WP_PARAM_KEY_WAKEUP_DAT_FILE_PATH
* Value explanation:
* Value type: std::string
* Default value: -
*/
extern const std::string WP_PARAM_KEY_WAKEUP_DAT_FILE_PATH;
extern const std::string BDS_PARAM_KEY_WRITABLE_LIBRARY_DATA_PATH;
}
#endif /* bds_WakeupParameters_hpp */

@ -0,0 +1,66 @@
/***************************************************************************
*
* Copyright (c) 2016 Baidu.com, Inc. All Rights Reserved
*
**************************************************************************/
/**
* @file BDSSDKMessage.hpp
* @author Vaino(lappivaeinoe@baidu.com)
* @date 2016/10/26 17:51:32
* @brief Message container to pass commands to SDK and receive events/callbacks from the SDK
*
**/
#ifndef _BDS_SDK_MESSAGE_HPP_
#define _BDS_SDK_MESSAGE_HPP_
#include <map>
#include <vector>
#include <string>
namespace bds {
extern const std::string DATA_CHUNK;
class BDSSDKMessageImpl;
class BDSSDKMessage{
public:
BDSSDKMessage(const std::string &p_name);
BDSSDKMessage();
BDSSDKMessage(const BDSSDKMessage &m);
virtual BDSSDKMessage& operator=(const BDSSDKMessage &m);
std::string name;
/*
char* data;
unsigned int length;
*/
virtual ~BDSSDKMessage();
/* Set parameters to message */
void set_parameter(const std::string &key, const std::string &value);
void set_parameter(const std::string &key, int value);
void set_parameter(const std::string &key, float value);
void set_parameter(const std::string &key, const char* value, int valueLen);
void set_parameter(const std::string &key, const std::vector<std::string> &value);
/* Get keys for parameters set to message */
std::vector<std::string> string_param_keys();
std::vector<std::string> int_param_keys();
std::vector<std::string> float_param_keys();
std::vector<std::string> char_param_keys();
std::vector<std::string> vector_param_keys();
/* Get parameters from message */
bool get_parameter(const std::string &key, std::string &outValue);
bool get_parameter(const std::string &key, int &outValue);
bool get_parameter(const std::string &key, float &outValue);
bool get_parameter(const std::string &key, const char* &outValue, int &outValueLen);
bool get_parameter(const std::string &key, std::vector<std::string> &outValue);
private:
BDSSDKMessageImpl* _impl;
friend class BDSSDKMessageImpl;
};
}
#endif

@ -0,0 +1,49 @@
/***************************************************************************
*
* Copyright (c) 2016 Baidu.com, Inc. All Rights Reserved
*
**************************************************************************/
/**
* @file BDSpeechSDK.hpp
* @author Vaino(lappivaeinoe@baidu.com)
* @date 2016/10/26 17:52:07
* @brief Main interface for speech SDK for Linux.
*
**/
#ifndef _BDS_SPEECH_SDK_HPP_
#define _BDS_SPEECH_SDK_HPP_
#include <string>
#include "BDSSDKMessage.hpp"
namespace bds {
class BDSpeechSDK{
public:
static BDSpeechSDK* get_instance(const std::string &SDKType, std::string &outErrorDescription);
virtual void set_event_listener(void(*listener)(BDSSDKMessage&,void*), void* userParam) = 0;
static void release_instance(BDSpeechSDK* instance);
virtual bool post(BDSSDKMessage &message, std::string &outErrorDescription) = 0;
/*
* Cleanup for closing the program.
* This function will clean up some globals and makes sure that
* everything has been stopped before returning.
* Call is needed only when the whole program is about to shut down
* Not calling this function before returning from main() function of the program may lead to a crash due to async nature of release_instance() functions.
*/
static void do_cleanup();
static void open_log_file(const char *logFileName, int fileSize = 0);
static void close_log_file();
static std::string get_sdk_version();
static int set_global_param(const std::string& param_type, void* value, std::string &outErrorDescription);
protected:
BDSpeechSDK();
virtual ~BDSpeechSDK();
};
}
#endif

Binary file not shown.

File diff suppressed because one or more lines are too long

@ -0,0 +1,54 @@
vec 26
1.485246e+01
1.579741e+01
1.663629e+01
1.698390e+01
1.708107e+01
1.745045e+01
1.752832e+01
1.758490e+01
1.746364e+01
1.743286e+01
1.744198e+01
1.735617e+01
1.735499e+01
1.730315e+01
1.726894e+01
1.729055e+01
1.728198e+01
1.718504e+01
1.712417e+01
1.710584e+01
1.715915e+01
1.723995e+01
1.730050e+01
1.728485e+01
1.728487e+01
1.729697e+01
vec 26
2.764144e-01
2.703758e-01
2.584008e-01
2.514187e-01
2.496835e-01
2.436650e-01
2.391809e-01
2.393867e-01
2.416821e-01
2.443231e-01
2.473226e-01
2.507182e-01
2.540205e-01
2.566869e-01
2.590701e-01
2.611003e-01
2.630226e-01
2.658522e-01
2.699072e-01
2.724641e-01
2.723619e-01
2.699174e-01
2.670183e-01
2.660550e-01
2.658852e-01
2.637595e-01

@ -0,0 +1 @@
fAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõfAEYGGtÓEYXgB_ZBòõ

@ -0,0 +1 @@
66af2eef7a9e6cf37646e6a0c9c0abcbb2149789b4a8c5532796731a694e7254b2f9c4815e0dd162633078eec0e09d31d88485feb9c9980c7d47bd98b0cb413e749e35f7751fa6dc05efe64003bbf8e1c145e4c9b1a625e268cb9bca9b123f7c13992c4a751a85bf356019726c17197279b637d6868a5fe93a59b54cedf4d60d844782908589335de28e5fe6eeba404ee827431a2ee60edaf013c2ca14ba062a2e8e3ee99ec7664a48e646e216a1e7267971fdad4d14f14dda1912723e87408cb244ac92321f6abf04df4a6bf6c2a05a0aecd4d307ed10c461a109315a7bf0b8dd2870d59c4e8ea1b5395fa15da2a4f3f7081cc6bb8543b8f4e240838eb41290

@ -0,0 +1,54 @@
vec 26
1.485246e+01
1.579741e+01
1.663629e+01
1.698390e+01
1.708107e+01
1.745045e+01
1.752832e+01
1.758490e+01
1.746364e+01
1.743286e+01
1.744198e+01
1.735617e+01
1.735499e+01
1.730315e+01
1.726894e+01
1.729055e+01
1.728198e+01
1.718504e+01
1.712417e+01
1.710584e+01
1.715915e+01
1.723995e+01
1.730050e+01
1.728485e+01
1.728487e+01
1.729697e+01
vec 26
2.764144e-01
2.703758e-01
2.584008e-01
2.514187e-01
2.496835e-01
2.436650e-01
2.391809e-01
2.393867e-01
2.416821e-01
2.443231e-01
2.473226e-01
2.507182e-01
2.540205e-01
2.566869e-01
2.590701e-01
2.611003e-01
2.630226e-01
2.658522e-01
2.699072e-01
2.724641e-01
2.723619e-01
2.699174e-01
2.670183e-01
2.660550e-01
2.658852e-01
2.637595e-01

@ -0,0 +1 @@
79bb1333ee01a55a5e1f51286d7c4bc4

@ -0,0 +1,39 @@
## asr Makefile ##
CC=g++
#AR=ar
#FILE_NAME=$(src)
FILE_NAME=src/main.cpp
INC_PATH= -I../../include\
-I../../include/ASR\
SRC_PATH=./src
OBJ_PATH=.
TARGET=$(basename $(FILE_NAME))
LIB_PATH=../../lib
EXTERN_PATH=../../extern/lib
TARGET_PATH=./
CPPFLAGS1=-Wall -O0 -fPIC -g -D__LINUX__ -Wno-unknown-pragmas -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11
CPPFLAGS= $(CPPFLAGS1) $(LIB_PATH)/libBDSpeechSDK.a $(EXTERN_PATH)/libcurl.a $(EXTERN_PATH)/libiconv.a $(EXTERN_PATH)/libz.a $(EXTERN_PATH)/libssl.a $(EXTERN_PATH)/libcrypto.a $(EXTERN_PATH)/libuuid.a -lrt -ldl -lpthread
SRC_FILE=$(shell cd $(SRC_PATH)&&echo *.cpp)
SRC:=$(foreach n,$(SRC_FILE),$(SRC_PATH)/$(n))
OBJ_FILE=$(SRC_FILE:.cpp=.o)
OBJ:=$(foreach n,$(OBJ_FILE),$(OBJ_PATH)/$(n))
DEP_FILE=$(SRC_FILE:.cpp=.d)
DEP:=$(foreach n,$(DEP_FILE),$(OBJ_PATH)/$(n))
$(TARGET):$(SRC)
$(CC) -o $(TARGET) ./$(FILE_NAME) $(INC_PATH) $(CPPFLAGS)
-mv $@ $(TARGET_PATH)
clean:
-rm -f $(OBJ)
-rm -f $(TARGET)
cleanall:
-rm -f $(OBJ)
-rm -f $(TARGET)

@ -0,0 +1,9 @@
# ASR demo
简单地并发测试sdk测试pcm目录下的音频 原始音频目前仅支持16k采样率
测试成功后,可以修改 asr_set_config_params内的设置参数

@ -0,0 +1,2 @@
#!/bin/bash
make && echo && echo "build success, wait 3s to run" && sleep 3 && ./main

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,430 @@
#include <iostream>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <sys/time.h>
//SDK interface
#include "BDSpeechSDK.hpp"
#include "bds_ASRDefines.hpp"
#include "bds_asr_key_definitions.hpp"
using namespace std;
/**
* 0. demo
* 1. asr_set_config_params
* 2. THREAD_NUM 线
* 3. asr_set_start_paramsapp
*/
char audio_dir[256] = "./pcm"; // 与THREAD_NUM一起决定测试的文件名
const int THREAD_NUM = 1; // 测试的线程数最大不能超过10
pthread_t thread_ids[THREAD_NUM]; // 线程信息
pthread_mutex_t thread_mutexes[THREAD_NUM]; // 锁信息用于同步SDK内部回调线程和用户的调用线程的asr_finish_tags
bool asr_finish_tags[THREAD_NUM] = {0}; //线程是否结束识别
int thread_sequeces[THREAD_NUM] = {0};
char file_names[THREAD_NUM][256]; // 每个线程识别的文件名
/**
*
*/
std::string get_gmt_time() {
struct timeval tv;
gettimeofday(&tv, NULL);
struct tm current_time;
localtime_r(&tv.tv_sec, &current_time);
int year = (1900 + current_time.tm_year);
int month = (1 + current_time.tm_mon);
int day = current_time.tm_mday;
int hour = current_time.tm_hour;
int minute = current_time.tm_min;
int sec = current_time.tm_sec;
int msec = (int) (tv.tv_usec / 1000);
char time_ch_buf[128] = {0};
snprintf(time_ch_buf, sizeof(time_ch_buf) / sizeof(char), "%d-%02d-%02d %02d:%02d:%02d.%03d", year, month, day,
hour, minute, sec, msec);
return std::string(time_ch_buf);
}
/**
*
*/
void asr_set_config_params(bds::BDSSDKMessage &cfg_params) {
//const bds::TBDVoiceRecognitionDebugLogLevel sdk_log_level = bds::EVRDebugLogLevelTrace;
const bds::TBDVoiceRecognitionDebugLogLevel sdk_log_level = bds::EVRDebugLogLevelOff; // 关闭详细日志
// app_id app_key app_secret 请测试成功后替换为您在网页上申请的appId appKey和appSecret
const std::string app_id = "10555002";
const std::string chunk_key = "jhRA15uv8Lvd4r9qbtmOODMv";
const std::string secret_key = "f0a12f8261e1121861a1cd3f4ed02f68";
const std::string product_id = "15362";
// const std::string product_id = "1536";// 普通话搜索模型1536普通话搜索模型+语义理解 15361, 普通话输入法模型(有逗号) 1537 , 8001 8002
cfg_params.name = bds::ASR_CMD_CONFIG;
cfg_params.set_parameter(bds::ASR_PARAM_KEY_APP_ID, app_id);
// 自训练平台上线模型的调用参数与product_id 8001 或 8002连用。
// cfg_params.set_parameter(bds::ASR_PARAM_KEY_LMID, 1068); // 设为 product_id = 8002
cfg_params.set_parameter(bds::ASR_PARAM_KEY_CHUNK_KEY, chunk_key);
cfg_params.set_parameter(bds::ASR_PARAM_KEY_PRODUCT_ID, product_id);
cfg_params.set_parameter(bds::COMMON_PARAM_KEY_DEBUG_LOG_LEVEL, sdk_log_level);
// float vad_pause_frames = 30; //设置vad语句静音切分门限, 30帧 = 300ms
// cfg_params.set_parameter(bds::ASR_PARAM_KEY_MAX_SPEECH_PAUSE, vad_pause_frames);
// cfg_params.set_parameter(bds::ASR_PARAM_KEY_SAVE_AUDIO_ENABLE, 1); //是否存识别的音频
// cfg_params.set_parameter(bds::ASR_PARAM_KEY_SAVE_AUDIO_PATH, "sdk_save_audio.d"); //存音频的路径
cfg_params.set_parameter(bds::ASR_PARAM_KEY_ENABLE_LONG_SPEECH, 1); // 强制固定值
cfg_params.set_parameter(bds::ASR_PARAM_KEY_CHUNK_ENABLE, 1); // 强制固定值
const std::string mfe_dnn_file_path = "../../resources/asr_resource/bds_easr_mfe_dnn.dat"; // bds_easr_mfe_dnn.dat文件路径
const std::string mfe_cmvn_file_path = "../../resources/asr_resource/bds_easr_mfe_cmvn.dat"; // bds_easr_mfe_cmvn.dat文件路径
cfg_params.set_parameter(bds::ASR_PARAM_KEY_MFE_DNN_DAT_FILE, mfe_dnn_file_path); // 强制固定值
cfg_params.set_parameter(bds::ASR_PARAM_KEY_MFE_CMVN_DAT_FILE, mfe_cmvn_file_path); // 强制固定值
cfg_params.set_parameter(bds::ASR_PARAM_KEY_COMPRESSION_TYPE, bds::EVR_AUDIO_COMPRESSION_PCM);
// cfg_params.set_parameter(bds::ASR_PARAM_KEY_COMPRESSION_TYPE, bds::EVR_AUDIO_COMPRESSION_BV32); // 有损压缩, 可能遇见音频压缩问题
}
// 设置启动参数
void asr_set_start_params(bds::BDSSDKMessage &start_params) {
const std::string app = "YourOwnName";
start_params.name = bds::ASR_CMD_START;
start_params.set_parameter(bds::ASR_PARAM_KEY_APP, app);
start_params.set_parameter(bds::ASR_PARAM_KEY_PLATFORM, "linux"); //固定值
start_params.set_parameter(bds::ASR_PARAM_KEY_SDK_VERSION, "LINUX TEST"); //固定值
}
/**
* @param file_path IN
* @param push_cmd IN bds::ASR_CMD_PUSH_AUDIO
* @param sdk BDSpeechSDK
* @param thread_seq demo线 asr_finish_tags[thread_seq]线
*/
int asr_online_pushaudio(const char *file_path, const std::string &push_cmd, bds::BDSpeechSDK *sdk, int thread_seq) {
const int audio_buf_len = 320; // 建议320字节一个包
const double per_send_seconds = 0.01; //320字节 16000采样率 sleep 10ms sleep时间与包大小成正比
char audio_buf[audio_buf_len];
FILE *err_output_file = stderr;
FILE *fp = fopen(file_path, "rb");
if (!fp) {
fprintf(err_output_file, "open audio data failed\n");
return 1;
}
std::string err_msg;
bds::BDSSDKMessage push_params;
push_params.name = push_cmd;
bool asr_finished = false;
while (!feof(fp) && !asr_finished) {
size_t read_cnt = fread(audio_buf, 1, audio_buf_len, fp);
if (read_cnt > 0) {
push_params.set_parameter(bds::DATA_CHUNK, audio_buf, (int) read_cnt);
// printf("[%s]push_audio data, size %ld\n", get_gmt_time().c_str(), read_cnt);
if (!sdk->post(push_params, err_msg)) {
fprintf(err_output_file, "push audio data failed for %s\n", err_msg.c_str());
}
//考虑到解码器的识别速度此处的sleep必不可少否则影响识别
usleep(static_cast<long>(per_send_seconds * 1000 * 1000));
}
pthread_mutex_lock(&thread_mutexes[thread_seq]);
asr_finished = asr_finish_tags[thread_seq];
pthread_mutex_unlock(&thread_mutexes[thread_seq]);
}
//告诉sdk后续不会再post音频数据 注意这个调用之后需要紧接着调用asr_online_stop
push_params.set_parameter(bds::DATA_CHUNK, audio_buf, 0);
printf("[%s]push_audio finish\n", get_gmt_time().c_str());
if (!sdk->post(push_params, err_msg)) {
fprintf(err_output_file, "push audio data failed for %s\n", err_msg.c_str());
}
fclose(fp);
return 0;
}
/**
* SDK SDK线线
* @param message IN SDK
* @param user_arg IN set_event_listener
*
*/
void asr_output_callback(bds::BDSSDKMessage &message, void *user_arg) {
int thread_seq = *(int *) user_arg;
FILE *err_output_file = stderr;
if (message.name != bds::asr_callback_name) {
fprintf(err_output_file, "shouldn't call\n");
return;
}
int status = 0;
if (!message.get_parameter(bds::CALLBACK_ASR_STATUS, status)) {
fprintf(err_output_file, "get status failed\n");
return;
}
FILE *result_output_file = stdout;
const char *time = get_gmt_time().c_str();
switch (status) {
case bds::EVoiceRecognitionClientWorkStatusStartWorkIng: {
fprintf(result_output_file, "[%s]识别工作开始\n", time);
fflush(result_output_file);
break;
}
case bds::EVoiceRecognitionClientWorkStatusStart: { // 一句话开始
fprintf(result_output_file, "[%s]检测到开始说话\n", time);
fflush(result_output_file);
break;
}
case bds::EVoiceRecognitionClientWorkStatusEnd: { // 一句话结束
fprintf(result_output_file, "[%s]检测到说话结束\n", time);
fflush(result_output_file);
break;
}
case bds::EVoiceRecognitionClientWorkStatusFlushData: { // 连续上屏,中间结果
std::string json_result;
message.get_parameter(bds::CALLBACK_ASR_RESULT, json_result);
fprintf(result_output_file, "[%s]patial result: %s\n", time, json_result.c_str());
fflush(result_output_file);
break;
}
case bds::EVoiceRecognitionClientWorkStatusFinish: { //一句话的最终结果
std::string json_result;
message.get_parameter(bds::CALLBACK_ASR_RESULT, json_result);
fprintf(result_output_file, "[%s]final result: %s\n", time, json_result.c_str());
fflush(result_output_file);
break;
}
case bds::EVoiceRecognitionClientWorkStatusChunkNlu: { //语义解析
const char *buf;
int len = 0;
message.get_parameter(bds::DATA_CHUNK, buf, len);
fprintf(result_output_file, "[%s]nlu result:", time);
for (int i = 0; i < len; ++i) {
fprintf(result_output_file, "%c", buf[i]);
}
fprintf(result_output_file, "\n");
fflush(result_output_file);
break;
}
//case bds::EVoiceRecognitionClientWorkStatusChunkThirdData: { //第三方结果
// const char* buf;
// int len = 0;
// message.get_parameter(bds::DATA_CHUNK, buf, len);
// //第三方结果未必是文本字符串,所以以%s打印未必有意义
// fprintf(result_output_file, "third final result len[%d]\n", len);
// //for (int i = 0; i < len; ++i) fprintf(result_output_file, "%c", buf[i]);
// fprintf(result_output_file, "\n");
// fflush(result_output_file);
// break;
//}
case bds::EVoiceRecognitionClientWorkStatusLongSpeechEnd: {
// 长语音结束状态 该实例处于空闲状态
pthread_mutex_lock(&thread_mutexes[thread_seq]);
asr_finish_tags[thread_seq] = true;
fprintf(result_output_file, "识别完成\n");
fflush(result_output_file);
pthread_mutex_unlock(&thread_mutexes[thread_seq]);
break;
}
case bds::EVoiceRecognitionClientWorkStatusError: {
// 产生错误 该实例处于空闲状态
int err_code = 0;
int err_domain = 0;
std::string err_desc;
message.get_parameter(bds::CALLBACK_ERROR_CODE, err_code);
message.get_parameter(bds::CALLBACK_ERROR_DOMAIN, err_domain);
message.get_parameter(bds::CALLBACK_ERROR_DESC, err_desc);
std::string sn;
message.get_parameter(bds::CALLBACK_ERROR_SERIAL_NUM, sn);
pthread_mutex_lock(&thread_mutexes[thread_seq]);
asr_finish_tags[thread_seq] = true;
fprintf(result_output_file,
"[%s]识别出错, err_code: %d, err_domain: %d,\
err_desc: %s, sn: %s\n",
get_gmt_time().c_str(), err_code, err_domain, err_desc.c_str(), sn.c_str());
fflush(result_output_file);
pthread_mutex_unlock(&thread_mutexes[thread_seq]);
break;
}
case bds::EVoiceRecognitionClientWorkStatusCancel: {
// 用户取消 该实例处于空闲状态
pthread_mutex_lock(&thread_mutexes[thread_seq]);
asr_finish_tags[thread_seq] = true;
fprintf(result_output_file, "[%s]用户取消\n", get_gmt_time().c_str());
fflush(result_output_file);
pthread_mutex_unlock(&thread_mutexes[thread_seq]);
break;
}
case bds::EVoiceRecognitionClientWorkStatusNewRecordData:
case bds::EVoiceRecognitionClientWorkStatusMeterLevel:
break;
default: {
fprintf(result_output_file, "其它状态%d\n", status);
break;
}
//bds::EVoiceRecognitionClientWorkStatusChunkEnd : { // CHUNK: 识别过程结束
//bds::EVoiceRecognitionClientWorkStatusChunkNlu, // CHUNK: 识别结果中的语义结果
}
}
/**
* SDK
*/
void asr_online_release(bds::BDSpeechSDK *sdk) {
bds::BDSpeechSDK::release_instance(sdk);
}
/**
*
*/
int asr_online_stop(bds::BDSpeechSDK *sdk) {
FILE *err_output_file = stderr;
std::string err_msg;
bds::BDSSDKMessage stop_params;
stop_params.name = bds::ASR_CMD_STOP;
if (!sdk->post(stop_params, err_msg)) {
fprintf(err_output_file, "stop sdk failed for %s\n", err_msg.c_str());
return 1;
}
return 0;
}
static void *asr_thread(void *arg) {
int thread_seq = *(int *) arg;
char *file_name = file_names[thread_seq];
FILE *err_output_file = stderr;
fprintf(stdout, "Will recognize file: %s\n", file_name);
fprintf(stdout, "sdk version :%s\n", bds::BDSpeechSDK::get_sdk_version().c_str());
/* 0 设置日志文件路径如不设置默认输出到stderr */
bds::BDSpeechSDK::open_log_file("asr.log", 25); // 与BDSpeechSDK::close_log_file();配对使用。
// 25 表示 日志文件大小约25*512k 超过后SDK新建一个日志文件旧日志文件覆盖到"asr.log.bak"
/* 1 获取sdk实例 */
std::string err_msg;
bds::BDSpeechSDK *sdk = bds::BDSpeechSDK::get_instance(bds::SDK_TYPE_ASR, err_msg);
if (!sdk) {
fprintf(err_output_file, "thread %d, get sdk failed for %s\n", thread_seq, err_msg.c_str());
return NULL;
}
/* 2 设置输出回调 */
sdk->set_event_listener(&asr_output_callback, (void *) &thread_seq);
/* 3 设置并发送sdk配置参数 */
bds::BDSSDKMessage cfg_params;
asr_set_config_params(cfg_params);
if (!sdk->post(cfg_params, err_msg)) {
fprintf(err_output_file, "thread %d, init sdk failed for %s\n", thread_seq, err_msg.c_str());
bds::BDSpeechSDK::release_instance(sdk);
return NULL;
}
/* 4 设置并发送sdk启动参数 */
bds::BDSSDKMessage start_params;
asr_set_start_params(start_params);
if (!sdk->post(start_params, err_msg)) {
fprintf(err_output_file, "thread %d, start sdk failed for %s\n", thread_seq, err_msg.c_str());
bds::BDSpeechSDK::release_instance(sdk);
return NULL;
}
/* 5 传输音频数据 */
int ret = asr_online_pushaudio(file_name, bds::ASR_CMD_PUSH_AUDIO, sdk, thread_seq);
if (ret) {
fprintf(err_output_file, "thread %d, push audio failed\n", thread_seq);
asr_online_stop(sdk);
bds::BDSpeechSDK::release_instance(sdk);
return NULL;
}
/* 6 发送停止传输音频数据标记 */
asr_online_stop(sdk);
/* 7 等待识别结束 */
bool asr_finished = false;
while (!asr_finished) {
usleep(10000);
pthread_mutex_lock(&thread_mutexes[thread_seq]);
asr_finished = asr_finish_tags[thread_seq];
pthread_mutex_unlock(&thread_mutexes[thread_seq]);
}
/* 8 关闭日志 ,如果之前调用过 open_log_file */
bds::BDSpeechSDK::close_log_file();
/* 8 释放sdk */
asr_online_release(sdk);
fprintf(stdout, "[%s]thread[%d] finish\n", get_gmt_time().c_str(), thread_seq);
fflush(stdout);
return NULL;
}
int main(int argc, char **argv) {
FILE *err_output_file = stderr;
for (int i = 0; i < THREAD_NUM; ++i) {
thread_sequeces[i] = i;
pthread_mutex_init(&thread_mutexes[i], NULL);
snprintf(file_names[i], 256, "%s/16k-%d.pcm", audio_dir, i);
// 新线程中开启每个文件的识别
int32_t ret = pthread_create(&thread_ids[i], NULL, asr_thread,
static_cast<void *>(thread_sequeces + i)); // thread_sequeces[i]的指针
if (ret != 0) {
fprintf(err_output_file, "create thread failed[%d]\n", ret);
return 1;
}
}
for (int i = 0; i < THREAD_NUM; ++i) {
int ret = pthread_join(thread_ids[i], NULL); // 等待所有线程结束
if (ret != 0) {
fprintf(err_output_file, "join thread failed[%d]\n", ret);
return 1;
}
}
//所有任务结束,清理线程池
bds::BDSpeechSDK::do_cleanup();
return 0;
}

@ -0,0 +1,2 @@
#~/bin/sh
valgrind

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />

@ -0,0 +1,29 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/asrDemo-srt.iml" filepath="$PROJECT_DIR$/.idea/asrDemo-srt.iml" />
</modules>
</component>
</project>

@ -0,0 +1,543 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true" buildAllGenerated="true">
<generated>
<config projectName="asrDemo_srt" targetName="asrDemo_srt" />
</generated>
</component>
<component name="CMakeSettings" AUTO_RELOAD="true">
<configurations>
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="05b03179-2043-4d08-b60a-10a98acab567" name="Default" comment="" />
<ignored path="$PROJECT_DIR$/cmake-build-debug/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="CMakeBuildProfile:Debug" />
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="main.cpp" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-342">
<caret line="23" selection-start-line="23" selection-end-line="23" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="srt_file_listener.cpp" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/srt_file_listener.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="456">
<caret line="84" column="35" lean-forward="true" selection-start-line="84" selection-start-column="35" selection-end-line="84" selection-end-column="35" />
<folding>
<element signature="e#36#54#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>eof</find>
<find>sleep</find>
<find>asr_resource</find>
<find>SECRT</find>
<find>_controller</find>
<find>waiting_to</find>
<find>std::endl</find>
<find>RETURN_RECOG_FINISH_OK</find>
<find>_Predicate</find>
<find>_is_finished</find>
<find>mutex</find>
</findStrings>
<dirStrings>
<dir>$PROJECT_DIR$</dir>
<dir>$PROJECT_DIR$/src</dir>
</dirStrings>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/srt_file_listener.hpp" />
<option value="$PROJECT_DIR$/build-env.sh" />
<option value="$PROJECT_DIR$/src/common.h" />
<option value="$PROJECT_DIR$/src/srt_file_listener.cpp" />
<option value="$PROJECT_DIR$/scripts/valgrind.sh" />
<option value="$PROJECT_DIR$/scripts/srt.supp" />
<option value="$PROJECT_DIR$/src/common.cpp" />
<option value="$PROJECT_DIR$/CMakeLists.txt" />
<option value="$PROJECT_DIR$/src/recognizer.hpp" />
<option value="$PROJECT_DIR$/src/recognizer.cpp" />
<option value="$PROJECT_DIR$/src/main.cpp" />
</list>
</option>
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="OCFindUsagesOptions" text="true" ivars="false" properties="true" derivedClasses="false" />
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="98" />
<option name="y" value="24" />
<option name="width" value="1067" />
<option name="height" value="796" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="asrDemo_srt" type="b2602c69:ProjectViewProjectNode" />
<item name="asrDemo-srt" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="asrDemo_srt" type="b2602c69:ProjectViewProjectNode" />
<item name="asrDemo-srt" type="462c0819:PsiDirectoryNode" />
<item name="scripts" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="asrDemo_srt" type="b2602c69:ProjectViewProjectNode" />
<item name="asrDemo-srt" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../asrDel" />
<property name="settings.editor.selected.configurable" value="preferences.keymap" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/scripts" />
<recent name="$PROJECT_DIR$/data" />
<recent name="$PROJECT_DIR$/lib-src" />
<recent name="$PROJECT_DIR$" />
<recent name="$PROJECT_DIR$/include" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/data/video" />
<recent name="$PROJECT_DIR$/include/asr" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager" selected="Application.asrDemo_srt">
<configuration name="Build All" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="asrDemo_srt" RUN_TARGET_NAME="asrDemo_srt" EXPLICIT_BUILD_TARGET_NAME="all" />
<configuration name="asrDemo_srt" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="asrDemo_srt" TARGET_NAME="asrDemo_srt" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="asrDemo_srt" RUN_TARGET_NAME="asrDemo_srt" />
<list>
<item itemvalue="Application.Build All" />
<item itemvalue="Application.asrDemo_srt" />
</list>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="05b03179-2043-4d08-b60a-10a98acab567" name="Default" comment="" />
<created>1521256837740</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1521256837740</updated>
<workItem from="1521256839183" duration="21022000" />
<workItem from="1521337067588" duration="2967000" />
<workItem from="1521382560407" duration="16026000" />
<workItem from="1522110433794" duration="9000" />
<workItem from="1522237067969" duration="5433000" />
<workItem from="1522397180377" duration="22000" />
<workItem from="1523165787080" duration="742000" />
<workItem from="1523166818846" duration="11876000" />
<workItem from="1523251318540" duration="9913000" />
<workItem from="1523269952071" duration="1579000" />
<workItem from="1523325976016" duration="2157000" />
<workItem from="1523331190424" duration="3696000" />
<workItem from="1523347939099" duration="3697000" />
<workItem from="1531102653299" duration="797000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="79936000" />
</component>
<component name="ToolWindowManager">
<frame x="65" y="-4" width="1855" height="1084" extended-state="6" />
<editor active="true" />
<layout>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.16484717" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="CMake" order="11" sideWeight="0.49704143" visible="true" weight="0.32795697" />
<window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.5049127" side_tool="true" weight="0.32939914" />
<window_info anchor="bottom" id="Version Control" order="10" show_stripe_button="false" />
<window_info anchor="bottom" id="Run" order="2" weight="0.328" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Terminal" order="8" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.39866668" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="right" id="Commander" order="0" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32939914" />
<window_info anchor="bottom" id="Messages" order="7" sideWeight="0.49508733" weight="0.33066666" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/src/recognizer.cpp</url>
<line>39</line>
<option name="timeStamp" value="27" />
</line-breakpoint>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/src/recognizer.cpp</url>
<line>16</line>
<option name="timeStamp" value="28" />
</line-breakpoint>
</breakpoints>
<option name="time" value="29" />
</breakpoint-manager>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/common.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="114">
<caret line="6" selection-start-line="6" selection-end-line="6" />
<folding>
<element signature="e#95#114#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="247">
<caret line="13" column="71" selection-start-line="13" selection-start-column="71" selection-end-line="13" selection-end-column="71" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/srt_file_listener.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1805">
<caret line="95" column="69" selection-start-line="95" selection-start-column="69" selection-end-line="95" selection-end-column="69" />
<folding>
<element signature="e#36#54#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/recognizer.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1273">
<caret line="67" column="36" selection-start-line="67" selection-start-column="36" selection-end-line="67" selection-end-column="36" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/recognizer.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1083">
<caret line="57" column="37" selection-start-line="57" selection-start-column="37" selection-end-line="57" selection-end-column="37" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/include/asrdemo/ResultListener.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="306">
<caret line="17" column="6" selection-start-line="17" selection-start-column="6" selection-end-line="17" selection-end-column="6" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1692">
<caret line="94" column="13" lean-forward="true" selection-start-line="94" selection-start-column="13" selection-end-line="94" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/recognizer.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="648">
<caret line="36" column="32" selection-start-line="36" selection-start-column="32" selection-end-line="36" selection-end-column="32" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/srt_file_listener.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="576">
<caret line="32" column="60" selection-start-line="32" selection-start-column="60" selection-end-line="32" selection-end-column="60" />
<folding>
<element signature="e#36#54#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1620">
<caret line="90" selection-start-line="90" selection-end-line="90" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/recognizer.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="918">
<caret line="51" column="35" selection-start-line="51" selection-start-column="17" selection-end-line="51" selection-end-column="35" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/srt_file_listener.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="414">
<caret line="23" column="1" selection-start-line="23" selection-start-column="1" selection-end-line="23" selection-end-column="1" />
<folding>
<element signature="e#36#54#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/include/asr/ASR/bds_asr_key_definitions.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="4572">
<caret line="254" column="53" selection-start-line="254" selection-start-column="29" selection-end-line="254" selection-end-column="53" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/recognizer.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="774">
<caret line="43" selection-start-line="43" selection-end-line="43" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/srt_file_listener.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="414">
<caret line="23" column="1" selection-start-line="23" selection-start-column="1" selection-end-line="23" selection-end-column="1" />
<folding>
<element signature="e#36#54#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/include/asr/ASR/bds_asr_key_definitions.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="4572">
<caret line="254" column="53" selection-start-line="254" selection-start-column="29" selection-end-line="254" selection-end-column="53" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../asrDemo2/src/asrdemo/AsrdemoController.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="972">
<caret line="54" selection-start-line="54" selection-end-line="54" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/recognizer.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="612">
<caret line="34" column="38" selection-start-line="34" selection-start-column="17" selection-end-line="34" selection-end-column="38" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="198">
<caret line="11" column="27" selection-start-line="11" selection-start-column="27" selection-end-line="11" selection-end-column="27" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.cpp" />
<entry file="file://$PROJECT_DIR$/yours_main.cpp" />
<entry file="file://$PROJECT_DIR$/../../include/BDSSDKMessage.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-112">
<caret line="25" column="10" selection-start-line="25" selection-start-column="10" selection-end-line="25" selection-end-column="10" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/yours_main.cpp.bak" />
<entry file="file://$PROJECT_DIR$/include/asr/ASR/bds_ASRDefines.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-3623">
<caret line="14" column="15" selection-start-line="14" selection-start-column="15" selection-end-line="14" selection-end-column="15" />
</state>
</provider>
</entry>
<entry file="file:///usr/include/c++/4.8/iosfwd" />
<entry file="file://$PROJECT_DIR$/src/main.cpp.bak" />
<entry file="file:///usr/include/c++/4.8/bits/basic_ios.h" />
<entry file="file://$PROJECT_DIR$/include/asr/ASR/bds_asr_key_definitions.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="528">
<caret line="254" column="53" selection-start-line="254" selection-start-column="29" selection-end-line="254" selection-end-column="53" />
</state>
</provider>
</entry>
<entry file="file:///usr/include/c++/4.8/bits/stl_vector.h" />
<entry file="file:///usr/include/c++/4.8/bits/atomic_base.h" />
<entry file="file:///usr/include/c++/4.8/condition_variable" />
<entry file="file://$PROJECT_DIR$/include/asrdemo/StatusListener.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="234">
<caret line="14" column="44" selection-start-line="14" selection-start-column="30" selection-end-line="14" selection-end-column="44" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/include/asrdemo/ResultListener.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="306">
<caret line="17" column="6" selection-start-line="17" selection-start-column="6" selection-end-line="17" selection-end-column="6" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cmake-build-debug/log/asrDemo_srt.ubuntu.fu.log.INFO.20180328-195659.68660" />
<entry file="file://$PROJECT_DIR$/build-env.sh" />
<entry file="file://$PROJECT_DIR$/include/extern/glog/logging.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1754">
<caret line="361" column="23" selection-start-line="361" selection-start-column="23" selection-end-line="361" selection-end-column="23" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/include/asrdemo/Util.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="28" column="20" selection-start-line="28" selection-start-column="20" selection-end-line="28" selection-end-column="20" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/data/long6.srt" />
<entry file="file://$PROJECT_DIR$/scripts/valgrind.sh">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="19">
<caret line="1" column="31" selection-start-line="1" selection-start-column="31" selection-end-line="1" selection-end-column="31" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scripts/srt.supp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="209">
<caret line="11" column="68" selection-start-line="11" selection-start-column="68" selection-end-line="11" selection-end-column="68" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/common.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="114">
<caret line="6" selection-start-line="6" selection-end-line="6" />
<folding>
<element signature="e#95#114#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/common.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="190">
<caret line="10" selection-start-line="10" selection-end-line="10" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="247">
<caret line="13" column="33" selection-start-line="13" selection-start-column="33" selection-end-line="13" selection-end-column="33" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../asrDemo2/src/asrdemo/AsrdemoController.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="54">
<caret line="40" column="5" lean-forward="true" selection-start-line="40" selection-start-column="5" selection-end-line="40" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/include/asrdemo/AsrdemoController.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="222">
<caret line="50" column="9" selection-start-line="50" selection-start-column="9" selection-end-line="50" selection-end-column="9" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/srt_file_listener.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="247">
<caret line="17" column="20" selection-start-line="17" selection-start-column="20" selection-end-line="17" selection-end-column="20" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/recognizer.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="219">
<caret line="63" column="30" selection-start-line="63" selection-start-column="30" selection-end-line="63" selection-end-column="30" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/recognizer.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="491">
<caret line="43" column="55" selection-start-line="43" selection-start-column="55" selection-end-line="43" selection-end-column="55" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-342">
<caret line="23" selection-start-line="23" selection-end-line="23" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/srt_file_listener.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="456">
<caret line="84" column="35" lean-forward="true" selection-start-line="84" selection-start-column="35" selection-end-line="84" selection-end-column="35" />
<folding>
<element signature="e#36#54#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.1)
set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_BUILD_TYPE DEBUG)
project(asrDemo_srt)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/log)
set(CMAKE_CXX_STANDARD 11)
include_directories(include/asr/ASR include/asr/ include include/extern)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -O0 -fPIC -Wno-unknown-pragmas -D_GLIBCXX_USE_CXX11_ABI=0")
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)
file(GLOB SOURCE_FILES src/*.c* src/*.h*)
add_executable(asrDemo_srt ${SOURCE_FILES})
target_link_libraries(asrDemo_srt asrdemoall jsoncpp glog rt dl pthread)

@ -0,0 +1,55 @@
# ASR demo srt
一个完整的视频文件添加识别出的字幕示例
### 依赖
请先测试运行asrdemo2的脚本 本示例依赖asrdemo2的结果
cmake 3.1 及以上版本安装
```bash
centos
yum install cmake3
alias cmake=cmake3
ubuntu:
apt-get install cmake
```
ffmpeg 安装
```bash
centos
yum install ffmpeg
ubuntu:
apt-get install ffmpeg
```
或者参照这篇的安装方式:
https://ai.baidu.com/docs#/ASR-Tool-convert/top
## 视频文件示例
测试视频文件请下载至data/video目录
链接https://pan.baidu.com/s/1YYtHZ1OqYMyvfcaUHkFs2Q 密码if7h
## 运行
sh build_and_run.sh

@ -0,0 +1,54 @@
vec 26
1.485246e+01
1.579741e+01
1.663629e+01
1.698390e+01
1.708107e+01
1.745045e+01
1.752832e+01
1.758490e+01
1.746364e+01
1.743286e+01
1.744198e+01
1.735617e+01
1.735499e+01
1.730315e+01
1.726894e+01
1.729055e+01
1.728198e+01
1.718504e+01
1.712417e+01
1.710584e+01
1.715915e+01
1.723995e+01
1.730050e+01
1.728485e+01
1.728487e+01
1.729697e+01
vec 26
2.764144e-01
2.703758e-01
2.584008e-01
2.514187e-01
2.496835e-01
2.436650e-01
2.391809e-01
2.393867e-01
2.416821e-01
2.443231e-01
2.473226e-01
2.507182e-01
2.540205e-01
2.566869e-01
2.590701e-01
2.611003e-01
2.630226e-01
2.658522e-01
2.699072e-01
2.724641e-01
2.723619e-01
2.699174e-01
2.670183e-01
2.660550e-01
2.658852e-01
2.637595e-01

@ -0,0 +1,26 @@
#!/bin/sh
#依赖:
#ffmpeg
#cmake 3.1 以上
cd scripts
#编译依赖库。运行成功一次后,该脚本可以删除。
sh build-env.sh && \
\
#提取视频内的音频文件。运行成功一次后,该脚本可以删除。
sh convert-audio.sh wmv && \
\
cd ..
\
echo " begin to build " && \
rm -rf run/* && \
mkdir -p run && \
sleep 2 && \
cd run && \
cmake .. && make -j4 && \
echo "build success, begin to run " && \
sleep 2 && \
./asrDemo_srt

@ -0,0 +1,702 @@
## CMake configuration file of gflags project
##
## This CMakeLists.txt defines some gflags specific configuration variables
## using the "gflags_define" utility macro. The default values of these variables
## can be overridden either on the CMake command-line using the -D option of
## the cmake command or in a super-project which includes the gflags source
## tree by setting the GFLAGS_<varname> CMake variables before adding the
## gflags source directory via CMake's "add_subdirectory" command. Only when
## the non-cached variable GFLAGS_IS_SUBPROJECT has a value equivalent to FALSE,
## these configuration variables are added to the CMake cache so they can be
## edited in the CMake GUI. By default, GFLAGS_IS_SUBPROJECT is set to TRUE when
## the CMAKE_SOURCE_DIR is not identical to the directory of this CMakeLists.txt
## file, i.e., the top-level directory of the gflags project source tree.
##
## When this project is a subproject (GFLAGS_IS_SUBPROJECT is TRUE), the default
## settings are such that only the static single-threaded library is built without
## installation of the gflags files. The "gflags" target is in this case an ALIAS
## library target for the "gflags_nothreads_static" library target. Targets which
## depend on the gflags library should link to the "gflags" library target.
##
## Example CMakeLists.txt of user project which requires separate gflags installation:
## cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
##
## project(Foo)
##
## find_package(gflags REQUIRED)
##
## add_executable(foo src/foo.cc)
## target_link_libraries(foo gflags)
##
## Example CMakeLists.txt of user project which requires separate single-threaded static gflags installation:
## cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
##
## project(Foo)
##
## find_package(gflags COMPONENTS nothreads_static)
##
## add_executable(foo src/foo.cc)
## target_link_libraries(foo gflags)
##
## Example CMakeLists.txt of super-project which contains gflags source tree:
## cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
##
## project(Foo)
##
## add_subdirectory(gflags)
##
## add_executable(foo src/foo.cc)
## target_link_libraries(foo gflags)
##
## Variables to configure the source files:
## - GFLAGS_IS_A_DLL
## - GFLAGS_NAMESPACE
## - GFLAGS_ATTRIBUTE_UNUSED
## - GFLAGS_INTTYPES_FORMAT
##
## Variables to configure the build:
## - GFLAGS_SOVERSION
## - GFLAGS_BUILD_SHARED_LIBS
## - GFLAGS_BUILD_STATIC_LIBS
## - GFLAGS_BUILD_gflags_LIB
## - GFLAGS_BUILD_gflags_nothreads_LIB
## - GFLAGS_BUILD_TESTING
## - GFLAGS_BUILD_PACKAGING
##
## Variables to configure the installation:
## - GFLAGS_INCLUDE_DIR
## - GFLAGS_LIBRARY_INSTALL_DIR or LIB_INSTALL_DIR or LIB_SUFFIX
## - GFLAGS_INSTALL_HEADERS
## - GFLAGS_INSTALL_SHARED_LIBS
## - GFLAGS_INSTALL_STATIC_LIBS
cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
if (POLICY CMP0042)
cmake_policy (SET CMP0042 NEW)
endif ()
# ----------------------------------------------------------------------------
# includes
include ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils.cmake")
# ----------------------------------------------------------------------------
# package information
set (PACKAGE_NAME "gflags")
set (PACKAGE_VERSION "2.2.1")
set (PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set (PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}")
set (PACKAGE_BUGREPORT "https://github.com/gflags/gflags/issues")
set (PACKAGE_DESCRIPTION "A commandline flags library that allows for distributed flags.")
set (PACKAGE_URL "http://gflags.github.io/gflags")
project (${PACKAGE_NAME} CXX)
if (CMAKE_VERSION VERSION_LESS 3.4)
# C language still needed because the following required CMake modules
# (or their dependencies, respectively) are not correctly handling
# the case where only CXX is enabled
# - CheckTypeSize.cmake (fixed in CMake 3.1, cf. https://cmake.org/Bug/view.php?id=14056)
# - FindThreads.cmake (fixed in CMake 3.4, cf. https://cmake.org/Bug/view.php?id=14905)
enable_language (C)
endif ()
version_numbers (
${PACKAGE_VERSION}
PACKAGE_VERSION_MAJOR
PACKAGE_VERSION_MINOR
PACKAGE_VERSION_PATCH
)
# shared library ABI version number, can be overridden by package maintainers
# using -DGFLAGS_SOVERSION=XXX on the command-line
if (GFLAGS_SOVERSION)
set (PACKAGE_SOVERSION "${GFLAGS_SOVERSION}")
else ()
# TODO: Change default SOVERSION back to PACKAGE_VERSION_MAJOR with the
# next increase of major version number (i.e., 3.0.0 -> SOVERSION 3)
# The <major>.<minor> SOVERSION should be used for the 2.x releases
# versions only which temporarily broke the API by changing the default
# namespace from "google" to "gflags".
set (PACKAGE_SOVERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")
endif ()
# when gflags is included as subproject (e.g., as Git submodule/subtree) in the source
# tree of a project that uses it, no variables should be added to the CMake cache;
# users may set the non-cached variable GFLAGS_IS_SUBPROJECT before add_subdirectory(gflags)
if (NOT DEFINED GFLAGS_IS_SUBPROJECT)
if ("^${CMAKE_SOURCE_DIR}$" STREQUAL "^${PROJECT_SOURCE_DIR}$")
set (GFLAGS_IS_SUBPROJECT FALSE)
else ()
set (GFLAGS_IS_SUBPROJECT TRUE)
endif ()
endif ()
# prefix for package variables in CMake configuration file
string (TOUPPER "${PACKAGE_NAME}" PACKAGE_PREFIX)
# convert file path on Windows with back slashes to path with forward slashes
# otherwise this causes an issue with the cmake_install.cmake script
file (TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX)
# ----------------------------------------------------------------------------
# options
# maintain binary backwards compatibility with gflags library version <= 2.0,
# but at the same time enable the use of the preferred new "gflags" namespace
gflags_define (STRING NAMESPACE "Name(s) of library namespace (separate multiple options by semicolon)" "google;${PACKAGE_NAME}" "${PACKAGE_NAME}")
gflags_property (NAMESPACE ADVANCED TRUE)
set (GFLAGS_NAMESPACE_SECONDARY "${NAMESPACE}")
list (REMOVE_DUPLICATES GFLAGS_NAMESPACE_SECONDARY)
if (NOT GFLAGS_NAMESPACE_SECONDARY)
message (FATAL_ERROR "GFLAGS_NAMESPACE must be set to one (or more) valid C++ namespace identifier(s separated by semicolon \";\").")
endif ()
foreach (ns IN LISTS GFLAGS_NAMESPACE_SECONDARY)
if (NOT ns MATCHES "^[a-zA-Z][a-zA-Z0-9_]*$")
message (FATAL_ERROR "GFLAGS_NAMESPACE contains invalid namespace identifier: ${ns}")
endif ()
endforeach ()
list (GET GFLAGS_NAMESPACE_SECONDARY 0 GFLAGS_NAMESPACE)
list (REMOVE_AT GFLAGS_NAMESPACE_SECONDARY 0)
# cached build options when gflags is not a subproject, otherwise non-cached CMake variables
# usage: gflags_define(BOOL <name> <doc> <default> [<subproject default>])
gflags_define (BOOL BUILD_SHARED_LIBS "Request build of shared libraries." ON ON)
gflags_define (BOOL BUILD_STATIC_LIBS "Request build of static libraries (default if BUILD_SHARED_LIBS is OFF)." OFF ON)
gflags_define (BOOL BUILD_gflags_LIB "Request build of the multi-threaded gflags library." ON OFF)
gflags_define (BOOL BUILD_gflags_nothreads_LIB "Request build of the single-threaded gflags library." ON ON)
gflags_define (BOOL BUILD_PACKAGING "Enable build of distribution packages using CPack." OFF OFF)
gflags_define (BOOL BUILD_TESTING "Enable build of the unit tests and their execution using CTest." OFF OFF)
gflags_define (BOOL INSTALL_HEADERS "Request installation of headers and other development files." ON OFF)
gflags_define (BOOL INSTALL_SHARED_LIBS "Request installation of shared libraries." ON ON)
gflags_define (BOOL INSTALL_STATIC_LIBS "Request installation of static libraries." ON OFF)
gflags_define (BOOL REGISTER_BUILD_DIR "Request entry of build directory in CMake's package registry." OFF OFF)
gflags_define (BOOL REGISTER_INSTALL_PREFIX "Request entry of installed package in CMake's package registry." ON OFF)
gflags_property (BUILD_STATIC_LIBS ADVANCED TRUE)
gflags_property (INSTALL_HEADERS ADVANCED TRUE)
gflags_property (INSTALL_SHARED_LIBS ADVANCED TRUE)
gflags_property (INSTALL_STATIC_LIBS ADVANCED TRUE)
if (NOT GFLAGS_IS_SUBPROJECT)
foreach (varname IN ITEMS CMAKE_INSTALL_PREFIX)
gflags_property (${varname} ADVANCED FALSE)
endforeach ()
foreach (varname IN ITEMS CMAKE_CONFIGURATION_TYPES CMAKE_OSX_ARCHITECTURES CMAKE_OSX_DEPLOYMENT_TARGET CMAKE_OSX_SYSROOT)
gflags_property (${varname} ADVANCED TRUE)
endforeach ()
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS)
gflags_set (CMAKE_BUILD_TYPE Release)
endif ()
if (CMAKE_CONFIGURATION_TYPES)
gflags_property (CMAKE_BUILD_TYPE STRINGS "${CMAKE_CONFIGURATION_TYPES}")
endif ()
endif () # NOT GFLAGS_IS_SUBPROJECT
if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
set (BUILD_STATIC_LIBS ON)
endif ()
if (NOT BUILD_gflags_LIB AND NOT BUILD_gflags_nothreads_LIB)
message (FATAL_ERROR "At least one of [GFLAGS_]BUILD_gflags_LIB and [GFLAGS_]BUILD_gflags_nothreads_LIB must be ON.")
endif ()
gflags_define (STRING INCLUDE_DIR "Name of include directory of installed header files relative to CMAKE_INSTALL_PREFIX/include/" "${PACKAGE_NAME}")
gflags_property (INCLUDE_DIR ADVANCED TRUE)
file (TO_CMAKE_PATH "${INCLUDE_DIR}" INCLUDE_DIR)
if (IS_ABSOLUTE INCLUDE_DIR)
message (FATAL_ERROR "[GFLAGS_]INCLUDE_DIR must be a path relative to CMAKE_INSTALL_PREFIX/include/")
endif ()
if (INCLUDE_DIR MATCHES "^\\.\\.[/\\]")
message (FATAL_ERROR "[GFLAGS_]INCLUDE_DIR must not start with parent directory reference (../)")
endif ()
set (GFLAGS_INCLUDE_DIR "${INCLUDE_DIR}")
# ----------------------------------------------------------------------------
# system checks
include (CheckTypeSize)
include (CheckIncludeFileCXX)
include (CheckCXXSymbolExists)
if (WIN32 AND NOT CYGWIN)
set (OS_WINDOWS 1)
else ()
set (OS_WINDOWS 0)
endif ()
if (MSVC)
set (HAVE_SYS_TYPES_H 1)
set (HAVE_STDDEF_H 1) # used by CheckTypeSize module
set (HAVE_UNISTD_H 0)
set (HAVE_SYS_STAT_H 1)
set (HAVE_SHLWAPI_H 1)
if (MSVC_VERSION VERSION_LESS 1600)
check_include_file_cxx ("stdint.h" HAVE_STDINT_H)
bool_to_int (HAVE_STDINT_H) # used in #if directive
else ()
set (HAVE_STDINT_H 1)
endif ()
if (MSVC_VERSION VERSION_LESS 1800)
check_include_file_cxx ("inttypes.h" HAVE_INTTYPES_H)
bool_to_int (HAVE_INTTYPES_H) # used in #if directive
else ()
set (HAVE_INTTYPES_H 1)
endif ()
else ()
foreach (fname IN ITEMS unistd stdint inttypes sys/types sys/stat fnmatch)
string (TOUPPER "${fname}" FNAME)
string (REPLACE "/" "_" FNAME "${FNAME}")
if (NOT HAVE_${FNAME}_H)
check_include_file_cxx ("${fname}.h" HAVE_${FNAME}_H)
endif ()
endforeach ()
if (NOT HAVE_FNMATCH_H AND OS_WINDOWS)
check_include_file_cxx ("shlwapi.h" HAVE_SHLWAPI_H)
endif ()
# the following are used in #if directives not #ifdef
bool_to_int (HAVE_STDINT_H)
bool_to_int (HAVE_SYS_TYPES_H)
bool_to_int (HAVE_INTTYPES_H)
endif ()
gflags_define (STRING INTTYPES_FORMAT "Format of integer types: \"C99\" (uint32_t), \"BSD\" (u_int32_t), \"VC7\" (__int32)" "")
gflags_property (INTTYPES_FORMAT STRINGS "C99;BSD;VC7")
gflags_property (INTTYPES_FORMAT ADVANCED TRUE)
if (NOT INTTYPES_FORMAT)
set (TYPES uint32_t u_int32_t)
if (MSVC)
list (INSERT TYPES 0 __int32)
endif ()
foreach (type IN LISTS TYPES)
check_type_size (${type} ${type} LANGUAGE CXX)
if (HAVE_${type})
break ()
endif ()
endforeach ()
if (HAVE_uint32_t)
gflags_set (INTTYPES_FORMAT C99)
elseif (HAVE_u_int32_t)
gflags_set (INTTYPES_FORMAT BSD)
elseif (HAVE___int32)
gflags_set (INTTYPES_FORMAT VC7)
else ()
gflags_property (INTTYPES_FORMAT ADVANCED FALSE)
message (FATAL_ERROR "Do not know how to define a 32-bit integer quantity on your system!"
" Neither uint32_t, u_int32_t, nor __int32 seem to be available."
" Set [GFLAGS_]INTTYPES_FORMAT to either C99, BSD, or VC7 and try again.")
endif ()
endif ()
# use of special characters in strings to circumvent bug #0008226
if ("^${INTTYPES_FORMAT}$" STREQUAL "^WIN$")
gflags_set (INTTYPES_FORMAT VC7)
endif ()
if (NOT INTTYPES_FORMAT MATCHES "^(C99|BSD|VC7)$")
message (FATAL_ERROR "Invalid value for [GFLAGS_]INTTYPES_FORMAT! Choose one of \"C99\", \"BSD\", or \"VC7\"")
endif ()
set (GFLAGS_INTTYPES_FORMAT "${INTTYPES_FORMAT}")
set (GFLAGS_INTTYPES_FORMAT_C99 0)
set (GFLAGS_INTTYPES_FORMAT_BSD 0)
set (GFLAGS_INTTYPES_FORMAT_VC7 0)
set ("GFLAGS_INTTYPES_FORMAT_${INTTYPES_FORMAT}" 1)
if (MSVC)
set (HAVE_strtoll 0)
set (HAVE_strtoq 0)
else ()
check_cxx_symbol_exists (strtoll stdlib.h HAVE_STRTOLL)
if (NOT HAVE_STRTOLL)
check_cxx_symbol_exists (strtoq stdlib.h HAVE_STRTOQ)
endif ()
endif ()
if (BUILD_gflags_LIB)
set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package (Threads)
if (Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
set (HAVE_PTHREAD 1)
check_type_size (pthread_rwlock_t RWLOCK LANGUAGE CXX)
else ()
set (HAVE_PTHREAD 0)
endif ()
if (UNIX AND NOT HAVE_PTHREAD)
if (CMAKE_HAVE_PTHREAD_H)
set (what "library")
else ()
set (what ".h file")
endif ()
message (FATAL_ERROR "Could not find pthread${what}. Check the log file"
"\n\t${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
"\nor disable the build of the multi-threaded gflags library (BUILD_gflags_LIB=OFF).")
endif ()
else ()
set (HAVE_PTHREAD 0)
endif ()
# ----------------------------------------------------------------------------
# source files - excluding root subdirectory and/or .in suffix
set (PUBLIC_HDRS
"gflags.h"
"gflags_declare.h"
"gflags_completions.h"
)
if (GFLAGS_NAMESPACE_SECONDARY)
set (INCLUDE_GFLAGS_NS_H "// Import gflags library symbols into alternative/deprecated namespace(s)")
foreach (ns IN LISTS GFLAGS_NAMESPACE_SECONDARY)
string (TOUPPER "${ns}" NS)
set (gflags_ns_h "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/gflags_${ns}.h")
configure_file ("${PROJECT_SOURCE_DIR}/src/gflags_ns.h.in" "${gflags_ns_h}" @ONLY)
list (APPEND PUBLIC_HDRS "${gflags_ns_h}")
set (INCLUDE_GFLAGS_NS_H "${INCLUDE_GFLAGS_NS_H}\n#include \"gflags_${ns}.h\"")
endforeach ()
else ()
set (INCLUDE_GFLAGS_NS_H)
endif ()
set (PRIVATE_HDRS
"config.h"
"util.h"
"mutex.h"
)
set (GFLAGS_SRCS
"gflags.cc"
"gflags_reporting.cc"
"gflags_completions.cc"
)
if (OS_WINDOWS)
list (APPEND PRIVATE_HDRS "windows_port.h")
list (APPEND GFLAGS_SRCS "windows_port.cc")
endif ()
# ----------------------------------------------------------------------------
# configure source files
if (NOT DEFINED GFLAGS_ATTRIBUTE_UNUSED)
if (CMAKE_COMPILER_IS_GNUCXX)
set (GFLAGS_ATTRIBUTE_UNUSED "__attribute((unused))")
else ()
set (GFLAGS_ATTRIBUTE_UNUSED)
endif ()
endif ()
# whenever we build a shared library (DLL on Windows), configure the public
# headers of the API for use of this shared library rather than the optionally
# also build statically linked library; users can override GFLAGS_DLL_DECL
# in particular, this done by setting the INTERFACE_COMPILE_DEFINITIONS of
# static libraries to include an empty definition for GFLAGS_DLL_DECL
if (NOT DEFINED GFLAGS_IS_A_DLL)
if (BUILD_SHARED_LIBS)
set (GFLAGS_IS_A_DLL 1)
else ()
set (GFLAGS_IS_A_DLL 0)
endif ()
endif ()
configure_headers (PUBLIC_HDRS ${PUBLIC_HDRS})
configure_sources (PRIVATE_HDRS ${PRIVATE_HDRS})
configure_sources (GFLAGS_SRCS ${GFLAGS_SRCS})
# ----------------------------------------------------------------------------
# output directories
if (NOT GFLAGS_IS_SUBPROJECT)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin")
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib")
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "lib")
endif ()
# ----------------------------------------------------------------------------
# installation directories
if (OS_WINDOWS)
set (RUNTIME_INSTALL_DIR "bin")
set (LIBRARY_INSTALL_DIR "lib")
set (INCLUDE_INSTALL_DIR "include")
set (CONFIG_INSTALL_DIR "lib/cmake/${PACKAGE_NAME}")
set (PKGCONFIG_INSTALL_DIR)
else ()
set (RUNTIME_INSTALL_DIR bin)
# The LIB_INSTALL_DIR and LIB_SUFFIX variables are used by the Fedora
# package maintainers. Also package maintainers of other distribution
# packages need to be able to specify the name of the library directory.
if (NOT GFLAGS_LIBRARY_INSTALL_DIR AND LIB_INSTALL_DIR)
set (GFLAGS_LIBRARY_INSTALL_DIR "${LIB_INSTALL_DIR}")
endif ()
gflags_define (PATH LIBRARY_INSTALL_DIR "Directory of installed libraries, e.g., \"lib64\"" "lib${LIB_SUFFIX}")
gflags_property (LIBRARY_INSTALL_DIR ADVANCED TRUE)
set (INCLUDE_INSTALL_DIR include)
set (CONFIG_INSTALL_DIR ${LIBRARY_INSTALL_DIR}/cmake/${PACKAGE_NAME})
set (PKGCONFIG_INSTALL_DIR ${LIBRARY_INSTALL_DIR}/pkgconfig)
endif ()
# ----------------------------------------------------------------------------
# add library targets
set (TARGETS)
# static vs. shared
foreach (TYPE IN ITEMS STATIC SHARED)
if (BUILD_${TYPE}_LIBS)
string (TOLOWER "${TYPE}" type)
# whether or not targets are a DLL
if (OS_WINDOWS AND "^${TYPE}$" STREQUAL "^SHARED$")
set (GFLAGS_IS_A_DLL 1)
else ()
set (GFLAGS_IS_A_DLL 0)
endif ()
# filename suffix for static libraries on Windows
if (OS_WINDOWS AND "^${TYPE}$" STREQUAL "^STATIC$")
set (type_suffix "_${type}")
else ()
set (type_suffix "")
endif ()
# multi-threaded vs. single-threaded
foreach (opts IN ITEMS "" _nothreads)
if (BUILD_gflags${opts}_LIB)
set (target_name "gflags${opts}_${type}")
add_library (${target_name} ${TYPE} ${GFLAGS_SRCS} ${PRIVATE_HDRS} ${PUBLIC_HDRS})
set_target_properties (${target_name} PROPERTIES
OUTPUT_NAME "gflags${opts}${type_suffix}"
VERSION "${PACKAGE_VERSION}"
SOVERSION "${PACKAGE_SOVERSION}"
)
set (include_dirs "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>")
if (INSTALL_HEADERS)
list (APPEND include_dirs "$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>")
endif ()
target_include_directories (${target_name}
PUBLIC "${include_dirs}"
PRIVATE "${PROJECT_SOURCE_DIR}/src;${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}"
)
target_compile_definitions (${target_name} PUBLIC GFLAGS_IS_A_DLL=${GFLAGS_IS_A_DLL})
if (opts MATCHES "nothreads")
target_compile_definitions (${target_name} PRIVATE NO_THREADS)
elseif (CMAKE_USE_PTHREADS_INIT)
target_link_libraries (${target_name} ${CMAKE_THREAD_LIBS_INIT})
endif ()
if (HAVE_SHLWAPI_H)
target_link_libraries (${target_name} shlwapi.lib)
endif ()
list (APPEND TARGETS ${target_name})
# add convenience make target for build of both shared and static libraries
if (NOT GFLAGS_IS_SUBPROJECT)
if (NOT TARGET gflags${opts})
add_custom_target (gflags${opts})
endif ()
add_dependencies (gflags${opts} ${target_name})
endif ()
endif ()
endforeach ()
endif ()
endforeach ()
# add ALIAS target for use in super-project, prefer static over shared, single-threaded over multi-threaded
if (GFLAGS_IS_SUBPROJECT)
foreach (type IN ITEMS static shared)
foreach (opts IN ITEMS "_nothreads" "")
if (TARGET gflags${opts}_${type})
add_library (gflags ALIAS gflags${opts}_${type})
break ()
endif ()
endforeach ()
if (TARGET gflags)
break ()
endif ()
endforeach ()
endif ()
# ----------------------------------------------------------------------------
# installation rules
set (EXPORT_NAME ${PACKAGE_NAME}-targets)
file (RELATIVE_PATH INSTALL_PREFIX_REL2CONFIG_DIR "${CMAKE_INSTALL_PREFIX}/${CONFIG_INSTALL_DIR}" "${CMAKE_INSTALL_PREFIX}")
configure_file (cmake/config.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-install.cmake" @ONLY)
configure_file (cmake/version.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake" @ONLY)
if (BUILD_SHARED_LIBS AND INSTALL_SHARED_LIBS)
foreach (opts IN ITEMS "" _nothreads)
if (BUILD_gflags${opts}_LIB)
install (TARGETS gflags${opts}_shared
EXPORT ${EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR})
endif ()
endforeach ()
endif ()
if (BUILD_STATIC_LIBS AND INSTALL_STATIC_LIBS)
foreach (opts IN ITEMS "" _nothreads)
if (BUILD_gflags${opts}_LIB)
install (TARGETS gflags${opts}_static
EXPORT ${EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR})
endif ()
endforeach ()
endif ()
if (INSTALL_HEADERS)
install (FILES ${PUBLIC_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/${GFLAGS_INCLUDE_DIR})
install (
FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-install.cmake"
RENAME ${PACKAGE_NAME}-config.cmake
DESTINATION ${CONFIG_INSTALL_DIR}
)
install (
FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake"
DESTINATION ${CONFIG_INSTALL_DIR}
)
install (EXPORT ${EXPORT_NAME} DESTINATION ${CONFIG_INSTALL_DIR})
if (UNIX)
install (PROGRAMS src/gflags_completions.sh DESTINATION ${RUNTIME_INSTALL_DIR})
endif ()
endif ()
if (PKGCONFIG_INSTALL_DIR)
configure_file ("cmake/package.pc.in" "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}.pc" @ONLY)
install (FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}.pc" DESTINATION "${PKGCONFIG_INSTALL_DIR}")
endif ()
# ----------------------------------------------------------------------------
# support direct use of build tree
set (INSTALL_PREFIX_REL2CONFIG_DIR .)
export (TARGETS ${TARGETS} FILE "${PROJECT_BINARY_DIR}/${EXPORT_NAME}.cmake")
if (REGISTER_BUILD_DIR)
export (PACKAGE ${PACKAGE_NAME})
endif ()
if (REGISTER_INSTALL_PREFIX)
register_gflags_package(${CONFIG_INSTALL_DIR})
endif ()
configure_file (cmake/config.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake" @ONLY)
# ----------------------------------------------------------------------------
# testing - MUST follow the generation of the build tree config file
if (BUILD_TESTING)
include (CTest)
enable_testing ()
add_subdirectory (test)
endif ()
# ----------------------------------------------------------------------------
# packaging
if (BUILD_PACKAGING)
if (NOT BUILD_SHARED_LIBS AND NOT INSTALL_HEADERS)
message (WARNING "Package will contain static libraries without headers!"
"\nRecommended options for generation of runtime package:"
"\n BUILD_SHARED_LIBS=ON"
"\n BUILD_STATIC_LIBS=OFF"
"\n INSTALL_HEADERS=OFF"
"\n INSTALL_SHARED_LIBS=ON"
"\nRecommended options for generation of development package:"
"\n BUILD_SHARED_LIBS=ON"
"\n BUILD_STATIC_LIBS=ON"
"\n INSTALL_HEADERS=ON"
"\n INSTALL_SHARED_LIBS=ON"
"\n INSTALL_STATIC_LIBS=ON")
endif ()
# default package generators
if (APPLE)
set (PACKAGE_GENERATOR "PackageMaker")
set (PACKAGE_SOURCE_GENERATOR "TGZ;ZIP")
elseif (UNIX)
set (PACKAGE_GENERATOR "DEB;RPM")
set (PACKAGE_SOURCE_GENERATOR "TGZ;ZIP")
else ()
set (PACKAGE_GENERATOR "ZIP")
set (PACKAGE_SOURCE_GENERATOR "ZIP")
endif ()
# used package generators
set (CPACK_GENERATOR "${PACKAGE_GENERATOR}" CACHE STRING "List of binary package generators (CPack).")
set (CPACK_SOURCE_GENERATOR "${PACKAGE_SOURCE_GENERATOR}" CACHE STRING "List of source package generators (CPack).")
mark_as_advanced (CPACK_GENERATOR CPACK_SOURCE_GENERATOR)
# some package generators (e.g., PackageMaker) do not allow .md extension
configure_file ("${CMAKE_CURRENT_LIST_DIR}/README.md" "${CMAKE_CURRENT_BINARY_DIR}/README.txt" COPYONLY)
# common package information
set (CPACK_PACKAGE_VENDOR "Andreas Schuh")
set (CPACK_PACKAGE_CONTACT "google-gflags@googlegroups.com")
set (CPACK_PACKAGE_NAME "${PACKAGE_NAME}")
set (CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}")
set (CPACK_PACKAGE_VERSION_MAJOR "${PACKAGE_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${PACKAGE_VERSION_MINOR}")
set (CPACK_PACKAGE_VERSION_PATCH "${PACKAGE_VERSION_PATCH}")
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE_DESCRIPTION}")
set (CPACK_RESOURCE_FILE_WELCOME "${CMAKE_CURRENT_BINARY_DIR}/README.txt")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_LIST_DIR}/COPYING.txt")
set (CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_BINARY_DIR}/README.txt")
set (CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
set (CPACK_OUTPUT_FILE_PREFIX packages)
set (CPACK_PACKAGE_RELOCATABLE TRUE)
set (CPACK_MONOLITHIC_INSTALL TRUE)
# RPM package information -- used in cmake/package.cmake.in also for DEB
set (CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
set (CPACK_RPM_PACKAGE_LICENSE "BSD")
set (CPACK_RPM_PACKAGE_URL "${PACKAGE_URL}")
set (CPACK_RPM_CHANGELOG_FILE "${CMAKE_CURRENT_LIST_DIR}/ChangeLog.txt")
if (INSTALL_HEADERS)
set (CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_LIST_DIR}/doc/index.html")
else ()
set (CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_LIST_DIR}/cmake/README_runtime.txt")
endif ()
# system/architecture
if (WINDOWS)
if (CMAKE_CL_64)
set (CPACK_SYSTEM_NAME "win64")
else ()
set (CPACK_SYSTEM_NAME "win32")
endif ()
set (CPACK_PACKAGE_ARCHITECTURE)
elseif (APPLE)
set (CPACK_PACKAGE_ARCHITECTURE darwin)
else ()
string (TOLOWER "${CMAKE_SYSTEM_NAME}" CPACK_SYSTEM_NAME)
if (CMAKE_CXX_FLAGS MATCHES "-m32")
set (CPACK_PACKAGE_ARCHITECTURE i386)
else ()
execute_process (
COMMAND dpkg --print-architecture
RESULT_VARIABLE RV
OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE
)
if (RV EQUAL 0)
string (STRIP "${CPACK_PACKAGE_ARCHITECTURE}" CPACK_PACKAGE_ARCHITECTURE)
else ()
execute_process (COMMAND uname -m OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE)
if (CPACK_PACKAGE_ARCHITECTURE MATCHES "x86_64")
set (CPACK_PACKAGE_ARCHITECTURE amd64)
else ()
set (CPACK_PACKAGE_ARCHITECTURE i386)
endif ()
endif ()
endif ()
endif ()
# source package settings
set (CPACK_SOURCE_TOPLEVEL_TAG "source")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git/;\\\\.swp$;\\\\.#;/#;\\\\.*~;cscope\\\\.*;/[Bb]uild[.+-_a-zA-Z0-9]*/")
# default binary package settings
set (CPACK_INCLUDE_TOPLEVEL_DIRECTORY TRUE)
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
if (CPACK_PACKAGE_ARCHITECTURE)
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CPACK_PACKAGE_ARCHITECTURE}")
endif ()
# generator specific configuration file
#
# allow package maintainers to use their own configuration file
# $ cmake -DCPACK_PROJECT_CONFIG_FILE:FILE=/path/to/package/config
if (NOT CPACK_PROJECT_CONFIG_FILE)
configure_file (
"${CMAKE_CURRENT_LIST_DIR}/cmake/package.cmake.in"
"${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-package.cmake" @ONLY
)
set (CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-package.cmake")
endif ()
include (CPack)
endif () # BUILD_PACKAGING

@ -0,0 +1,587 @@
cmake_minimum_required (VERSION 3.0)
set(BUILD_SHARED_LIBS 1)
if (POLICY CMP0042)
cmake_policy (SET CMP0042 NEW)
endif (POLICY CMP0042)
if (POLICY CMP0063)
cmake_policy (SET CMP0063 NEW)
endif (POLICY CMP0063)
project (google-glog)
enable_testing ()
set (GLOG_MAJOR_VERSION 0)
set (GLOG_MINOR_VERSION 3)
set (GLOG_PATCH_VERSION 5)
set (GLOG_VERSION
${GLOG_MAJOR_VERSION}.${GLOG_MINOR_VERSION}.${GLOG_PATCH_VERSION})
set (CPACK_PACKAGE_NAME glog)
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "")
set (CPACK_PACKAGE_VERSION_MAJOR ${GLOG_MAJOR_VERSION})
set (CPACK_PACKAGE_VERSION_MINOR ${GLOG_MINOR_VERSION})
set (CPACK_PACKAGE_VERSION_PATCH ${GLOG_PATCH_VERSION})
set (CPACK_PACKAGE_VERSION ${GLOG_VERSION})
option (WITH_GFLAGS "Use gflags" ON)
option (WITH_THREADS "Enable multithreading support" ON)
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include (CheckCSourceCompiles)
include (CheckCXXCompilerFlag)
include (CheckCXXSourceCompiles)
include (CheckFunctionExists)
include (CheckIncludeFile)
include (CheckIncludeFileCXX)
include (CheckLibraryExists)
include (CheckStructHasMember)
include (CheckSymbolExists)
include (CheckTypeSize)
include (CMakePackageConfigHelpers)
include (CPack)
include (CTest)
include (DetermineGflagsNamespace)
set (CMAKE_THREAD_PREFER_PTHREAD 1)
if (WITH_GFLAGS)
find_package (gflags)
if (gflags_FOUND)
set (HAVE_LIB_GFLAGS 1)
determine_gflags_namespace (gflags_NAMESPACE)
endif (gflags_FOUND)
endif (WITH_GFLAGS)
if (WITH_THREADS)
find_package (Threads)
endif (WITH_THREADS)
check_include_file (dlfcn.h HAVE_DLFCN_H)
check_include_file (execinfo.h HAVE_EXECINFO_H)
check_include_file (glob.h HAVE_GLOB_H)
check_include_file (inttypes.h HAVE_INTTYPES_H)
check_include_file (libunwind.h HAVE_LIBUNWIND_H)
check_include_file (memory.h HAVE_MEMORY_H)
check_include_file (pwd.h HAVE_PWD_H)
check_include_file (stdint.h HAVE_STDINT_H)
check_include_file (stdlib.h HAVE_STDLIB_H)
check_include_file (string.h HAVE_STRING_H)
check_include_file (strings.h HAVE_STRINGS_H)
check_include_file (sys/stat.h HAVE_SYS_STAT_H)
check_include_file (sys/syscall.h HAVE_SYS_SYSCALL_H)
check_include_file (sys/time.h HAVE_SYS_TIME_H)
check_include_file (sys/types.h HAVE_SYS_TYPES_H)
check_include_file (sys/utsname.h HAVE_SYS_UTSNAME_H)
check_include_file (syscall.h HAVE_SYSCALL_H)
check_include_file (syslog.h HAVE_SYSLOG_H)
check_include_file (ucontext.h HAVE_UCONTEXT_H)
check_include_file (unistd.h HAVE_UNISTD_H)
check_include_file (unwind.h HAVE_UNWIND_H)
check_include_file_cxx ("ext/hash_map" HAVE_EXT_HASH_MAP)
check_include_file_cxx ("ext/hash_set" HAVE_EXT_HASH_SET)
check_include_file_cxx ("ext/slist" HAVE_EXT_SLIST)
check_include_file_cxx ("tr1/unordered_map" HAVE_TR1_UNORDERED_MAP)
check_include_file_cxx ("tr1/unordered_set" HAVE_TR1_UNORDERED_SET)
check_include_file_cxx ("unordered_map" HAVE_UNORDERED_MAP)
check_include_file_cxx ("unordered_set" HAVE_UNORDERED_SET)
check_type_size ("unsigned __int16" HAVE___UINT16)
check_type_size (u_int16_t HAVE_U_INT16_T)
check_type_size (uint16_t HAVE_UINT16_T)
check_function_exists (dladdr HAVE_DLADDR)
check_function_exists (fcntl HAVE_FCNTL)
check_function_exists (pread HAVE_PREAD)
check_function_exists (pwrite HAVE_PWRITE)
check_function_exists (sigaction HAVE_SIGACTION)
check_function_exists (sigaltstack HAVE_SIGALSTACK)
# NOTE gcc does not fail if you pass a non-existent -Wno-* option as an
# argument. However, it will happily fail if you pass the corresponding -W*
# option. So, we check whether options that disable warnings exist by testing
# the availability of the corresponding option that enables the warning. This
# eliminates the need to check for compiler for several (mainly Clang) options.
check_cxx_compiler_flag (-Wdeprecated HAVE_NO_DEPRECATED)
check_cxx_compiler_flag (-Wunnamed-type-template-args
HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS)
# NOTE: Cannot use check_function_exists here since >=vc-14.0 can define
# snprintf as an inline function
check_symbol_exists (snprintf stdio.h HAVE_SNPRINTF)
check_library_exists (unwind get_static_proc_name "" HAVE_LIB_UNWIND)
find_library (UNWIND_LIBRARY NAMES unwind DOC "unwind library")
mark_as_advanced (UNWIND_LIBRARY)
check_c_source_compiles ("
#include <stdlib.h>
static void foo(void) __attribute__ ((unused));
int main(void) { return 0; }
" HAVE___ATTRIBUTE__)
check_c_source_compiles ("
#include <stdlib.h>
static void foo(void) __attribute__ ((visibility(\"default\")));
int main(void) { return 0; }
" HAVE___ATTRIBUTE__VISIBILITY_DEFAULT)
check_c_source_compiles ("
#include <stdlib.h>
static void foo(void) __attribute__ ((visibility(\"hidden\")));
int main(void) { return 0; }
" HAVE___ATTRIBUTE__VISIBILITY_HIDDEN)
check_c_source_compiles ("
int main(void) { if (__builtin_expect(0, 0)) return 1; return 0; }
" HAVE___BUILTIN_EXPECT)
check_c_source_compiles ("
int main(void)
{
int a; if (__sync_val_compare_and_swap(&a, 0, 1)) return 1; return 0;
}
" HAVE___SYNC_VAL_COMPARE_AND_SWAP)
check_c_source_compiles ("
#define _XOPEN_SOURCE 500
#include <pthread.h>
int main(void)
{
pthread_rwlock_t l;
pthread_rwlock_init(&l, NULL);
pthread_rwlock_rdlock(&l);
return 0;
}
" HAVE_RWLOCK)
check_c_source_compiles ("
__declspec(selectany) int a;
int main(void) { return 0; }
" HAVE___DECLSPEC)
check_cxx_source_compiles ("
#include <vector>
vector<int> t; int main() { }
" STL_NO_NAMESPACE)
check_cxx_source_compiles ("
#include <vector>
std::vector<int> t; int main() { }
" STL_STD_NAMESPACE)
check_cxx_source_compiles ("
#include <iostream>
std::ostream& operator<<(std::ostream&, struct s);
using ::operator<<;
int main() { }
" HAVE_USING_OPERATOR)
check_cxx_source_compiles ("
namespace Outer { namespace Inner { int i = 0; }}
using namespace Outer::Inner;;
int main() { return i; }
" HAVE_NAMESPACES)
set (_PC_FIELDS
"gregs[REG_PC]"
"gregs[REG_EIP]"
"gregs[REG_RIP]"
"sc_ip"
"uc_regs->gregs[PT_NIP]"
"gregs[R15]"
"arm_pc"
"mc_eip"
"mc_rip"
"__gregs[REG_EIP]"
"__gregs[REG_RIP]"
"ss.eip"
"__ss.__eip"
"ss.rip"
"__ss.__rip"
"ss.srr0"
"__ss.__srr0"
)
set (_PC_HEADERS ucontext.h signal.h)
if (HAVE_UCONTEXT_H AND NOT PC_FROM_UCONTEXT)
foreach (_PC_FIELD ${_PC_FIELDS})
foreach (_PC_HEADER ${_PC_HEADERS})
set (_TMP
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/uctfield.c)
file (WRITE ${_TMP} "
#define _GNU_SOURCE 1
#include <${_PC_HEADER}>
int main(void)
{
ucontext_t u;
return u.${_PC_FIELD} == 0;
}
")
try_compile (HAVE_PC_FROM_UCONTEXT ${CMAKE_CURRENT_BINARY_DIR} ${_TMP}
COMPILE_DEFINITIONS _GNU_SOURCE=1)
if (HAVE_PC_FROM_UCONTEXT)
set (PC_FROM_UCONTEXT ${_PC_FIELD} CACHE)
endif (HAVE_PC_FROM_UCONTEXT)
endforeach (_PC_HEADER)
endforeach (_PC_FIELD)
endif (HAVE_UCONTEXT_H AND NOT PC_FROM_UCONTEXT)
if (STL_STD_NAMESPACE)
set (STL_NAMESPACE std)
else (STL_STD_NAMESPACE)
set (STL_NAMESPACE "")
endif (STL_STD_NAMESPACE)
set (GOOGLE_NAMESPACE google)
set (_START_GOOGLE_NAMESPACE_ "namespace ${GOOGLE_NAMESPACE} {")
set (_END_GOOGLE_NAMESPACE_ "}")
if (HAVE___UINT16)
set (ac_cv_have___uint16 1)
else (HAVE___UINT16)
set (ac_cv_have___uint16 0)
endif (HAVE___UINT16)
if (HAVE_INTTYPES_H)
set (ac_cv_have_inttypes_h 1)
else (HAVE_INTTYPES_H)
set (ac_cv_have_inttypes_h 0)
endif (HAVE_INTTYPES_H)
if (HAVE_LIB_GFLAGS)
set (ac_cv_have_libgflags 1)
else (HAVE_LIB_GFLAGS)
set (ac_cv_have_libgflags 0)
endif (HAVE_LIB_GFLAGS)
if (HAVE_STDINT_H)
set (ac_cv_have_stdint_h 1)
else (HAVE_STDINT_H)
set (ac_cv_have_stdint_h 0)
endif (HAVE_STDINT_H)
if (HAVE_SYS_TYPES_H)
set (ac_cv_have_systypes_h 1)
else (HAVE_SYS_TYPES_H)
set (ac_cv_have_systypes_h 0)
endif (HAVE_SYS_TYPES_H)
if (HAVE_U_INT16_T)
set (ac_cv_have_u_int16_t 1)
else (HAVE_U_INT16_T)
set (ac_cv_have_u_int16_t 0)
endif (HAVE_U_INT16_T)
if (HAVE_UINT16_T)
set (ac_cv_have_uint16_t 1)
else (HAVE_UINT16_T)
set (ac_cv_have_uint16_t 0)
endif (HAVE_UINT16_T)
if (HAVE_UNISTD_H)
set (ac_cv_have_unistd_h 1)
else (HAVE_UNISTD_H)
set (ac_cv_have_unistd_h 0)
endif (HAVE_UNISTD_H)
set (ac_google_namespace ${GOOGLE_NAMESPACE})
set (ac_google_end_namespace ${_END_GOOGLE_NAMESPACE_})
set (ac_google_start_namespace ${_START_GOOGLE_NAMESPACE_})
if (HAVE___ATTRIBUTE__)
set (ac_cv___attribute___noreturn "__attribute__((noreturn))")
set (ac_cv___attribute___noinline "__attribute__((noinline))")
elseif (HAVE___DECLSPEC)
set (ac_cv___attribute___noreturn "__declspec(noreturn)")
#set (ac_cv___attribute___noinline "__declspec(noinline)")
endif (HAVE___ATTRIBUTE__)
if (HAVE___BUILTIN_EXPECT)
set (ac_cv_have___builtin_expect 1)
else (HAVE___BUILTIN_EXPECT)
set (ac_cv_have___builtin_expect 0)
endif (HAVE___BUILTIN_EXPECT)
if (HAVE_USING_OPERATOR)
set (ac_cv_cxx_using_operator 1)
else (HAVE_USING_OPERATOR)
set (ac_cv_cxx_using_operator 0)
endif (HAVE_USING_OPERATOR)
set (SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
if (WITH_THREADS AND Threads_FOUND)
if (CMAKE_USE_PTHREADS_INIT)
set (HAVE_PTHREAD 1)
endif (CMAKE_USE_PTHREADS_INIT)
else (WITH_THREADS AND Threads_FOUND)
set (NO_THREADS 1)
endif (WITH_THREADS AND Threads_FOUND)
set (TEST_SRC_DIR \"${CMAKE_CURRENT_SOURCE_DIR}\")
configure_file (src/config.h.cmake.in config.h)
configure_file (src/glog/logging.h.in glog/logging.h @ONLY)
configure_file (src/glog/raw_logging.h.in glog/raw_logging.h @ONLY)
configure_file (src/glog/stl_logging.h.in glog/stl_logging.h @ONLY)
configure_file (src/glog/vlog_is_on.h.in glog/vlog_is_on.h @ONLY)
set (CMAKE_CXX_VISIBILITY_PRESET default)
set (CMAKE_VISIBILITY_INLINES_HIDDEN 1)
set (GLOG_PUBLIC_H
${CMAKE_CURRENT_BINARY_DIR}/config.h
${CMAKE_CURRENT_BINARY_DIR}/glog/logging.h
${CMAKE_CURRENT_BINARY_DIR}/glog/raw_logging.h
${CMAKE_CURRENT_BINARY_DIR}/glog/stl_logging.h
${CMAKE_CURRENT_BINARY_DIR}/glog/vlog_is_on.h
src/glog/log_severity.h
)
set (GLOG_SRCS
${GLOG_PUBLIC_H}
src/base/commandlineflags.h
src/base/googleinit.h
src/base/mutex.h
src/demangle.cc
src/demangle.h
src/logging.cc
src/raw_logging.cc
src/symbolize.cc
src/symbolize.h
src/utilities.cc
src/utilities.h
src/vlog_is_on.cc
)
if (HAVE_PTHREAD)
list (APPEND GLOG_SRCS src/signalhandler.cc)
endif (HAVE_PTHREAD)
if (WIN32)
list (APPEND GLOG_SRCS
src/windows/port.cc
src/windows/port.h
)
endif (WIN32)
add_compile_options ($<$<BOOL:${HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS}>:-Wno-unnamed-type-template-args>)
add_library (glog
${GLOG_SRCS}
)
set_target_properties (glog PROPERTIES POSITION_INDEPENDENT_CODE ON)
if (UNWIND_LIBRARY)
target_link_libraries (glog PUBLIC ${UNWIND_LIBRARY})
endif (UNWIND_LIBRARY)
if (HAVE_PTHREAD)
target_link_libraries (glog PUBLIC ${CMAKE_THREAD_LIBS_INIT})
endif (HAVE_PTHREAD)
if (WIN32 AND HAVE_SNPRINTF)
set_property (SOURCE src/windows/port.cc APPEND PROPERTY COMPILE_DEFINITIONS
HAVE_SNPRINTF)
endif (WIN32 AND HAVE_SNPRINTF)
if (gflags_FOUND)
target_include_directories (glog PUBLIC $<BUILD_INTERFACE:${gflags_INCLUDE_DIR}>)
target_link_libraries (glog PUBLIC ${gflags_LIBRARIES})
if (NOT BUILD_SHARED_LIBS)
# Don't use __declspec(dllexport|dllimport) if this is a static build
targeT_compile_definitions (glog PUBLIC GFLAGS_DLL_DECLARE_FLAG= GFLAGS_DLL_DEFINE_FLAG=)
endif (NOT BUILD_SHARED_LIBS)
endif (gflags_FOUND)
set_target_properties (glog PROPERTIES VERSION ${GLOG_MAJOR_VERSION})
set_target_properties (glog PROPERTIES SOVERSION ${GLOG_VERSION})
if (WIN32)
target_compile_definitions (glog PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES)
endif (WIN32)
set_target_properties (glog PROPERTIES PUBLIC_HEADER "${GLOG_PUBLIC_H}")
target_include_directories (glog BEFORE PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
"$<INSTALL_INTERFACE:include>"
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
if (WIN32)
target_include_directories (glog PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/windows>"
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/windows)
endif (WIN32)
set_target_properties (glog PROPERTIES DEFINE_SYMBOL LIBGLOG_EXPORTS)
if (NOT BUILD_SHARED_LIBS)
target_compile_definitions (glog PUBLIC GOOGLE_GLOG_DLL_DECL=)
else (NOT BUILD_SHARED_LIBS)
target_compile_definitions (glog PRIVATE GOOGLE_GLOG_IS_A_DLL=1)
if (HAVE___ATTRIBUTE__VISIBILITY_DEFAULT)
set (_EXPORT "__attribute__((visibility(\"default\")))")
set (_IMPORT "")
elseif (HAVE___DECLSPEC)
set (_EXPORT "__declspec(dllexport)")
set (_IMPORT "__declspec(dllimport)")
endif (HAVE___ATTRIBUTE__VISIBILITY_DEFAULT)
target_compile_definitions (glog PRIVATE
"GOOGLE_GLOG_DLL_DECL=${_EXPORT}")
target_compile_definitions (glog INTERFACE
"GOOGLE_GLOG_DLL_DECL=${_IMPORT}")
target_compile_definitions (glog INTERFACE
"GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS=${_IMPORT}")
endif (NOT BUILD_SHARED_LIBS)
if (HAVE_EXECINFO_H)
set (HAVE_STACKTRACE 1)
endif (HAVE_EXECINFO_H)
if (UNIX OR (APPLE AND HAVE_DLADDR))
set (HAVE_SYMBOLIZE 1)
endif (UNIX OR (APPLE AND HAVE_DLADDR))
# Unit testing
if (BUILD_TESTING)
add_executable (logging_unittest
src/logging_unittest.cc
)
target_link_libraries (logging_unittest PRIVATE glog)
add_executable (stl_logging_unittest
src/stl_logging_unittest.cc
)
target_link_libraries (stl_logging_unittest PRIVATE glog)
if (HAVE_NO_DEPRECATED)
set_property (TARGET stl_logging_unittest APPEND PROPERTY COMPILE_OPTIONS
-Wno-deprecated)
endif (HAVE_NO_DEPRECATED)
if (HAVE_UNORDERED_MAP AND HAVE_UNORDERED_SET)
target_compile_definitions (stl_logging_unittest PRIVATE
GLOG_STL_LOGGING_FOR_UNORDERED)
endif (HAVE_UNORDERED_MAP AND HAVE_UNORDERED_SET)
if (HAVE_TR1_UNORDERED_MAP AND HAVE_TR1_UNORDERED_SET)
target_compile_definitions (stl_logging_unittest PRIVATE
GLOG_STL_LOGGING_FOR_TR1_UNORDERED)
endif (HAVE_TR1_UNORDERED_MAP AND HAVE_TR1_UNORDERED_SET)
if (HAVE_EXT_HASH_MAP AND HAVE_EXT_HASH_SET)
target_compile_definitions (stl_logging_unittest PRIVATE
GLOG_STL_LOGGING_FOR_EXT_HASH)
endif (HAVE_EXT_HASH_MAP AND HAVE_EXT_HASH_SET)
if (HAVE_EXT_SLIST)
target_compile_definitions (stl_logging_unittest PRIVATE
GLOG_STL_LOGGING_FOR_EXT_SLIST)
endif (HAVE_EXT_SLIST)
if (HAVE_SYMBOLIZE)
add_executable (symbolize_unittest
src/symbolize_unittest.cc
)
target_link_libraries (symbolize_unittest PRIVATE glog)
endif (HAVE_SYMBOLIZE)
add_executable (demangle_unittest
src/demangle_unittest.cc
)
target_link_libraries (demangle_unittest PRIVATE glog)
if (HAVE_STACKTRACE)
add_executable (stacktrace_unittest
src/stacktrace_unittest.cc
)
target_link_libraries (stacktrace_unittest PRIVATE glog)
endif (HAVE_STACKTRACE)
add_executable (utilities_unittest
src/utilities_unittest.cc
)
target_link_libraries (utilities_unittest PRIVATE glog)
if (HAVE_STACKTRACE AND HAVE_SYMBOLIZE)
add_executable (signalhandler_unittest
src/signalhandler_unittest.cc
)
target_link_libraries (signalhandler_unittest PRIVATE glog)
endif (HAVE_STACKTRACE AND HAVE_SYMBOLIZE)
add_test (NAME demangle COMMAND demangle_unittest)
add_test (NAME logging COMMAND logging_unittest)
if (TARGET signalhandler_unittest)
add_test (NAME signalhandler COMMAND signalhandler_unittest)
endif (TARGET signalhandler_unittest)
if (TARGET stacktrace_unittest)
add_test (NAME stacktrace COMMAND stacktrace_unittest)
endif (TARGET stacktrace_unittest)
add_test (NAME stl_logging COMMAND stl_logging_unittest)
if (TARGET symbolize_unittest)
add_test (NAME symbolize COMMAND symbolize_unittest)
endif (TARGET symbolize_unittest)
endif (BUILD_TESTING)
install (TARGETS glog
EXPORT glog-targets
RUNTIME DESTINATION bin
PUBLIC_HEADER DESTINATION include/glog
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
if (gflags_FOUND)
set (gflags_DEPENDENCY "find_dependency (gflags ${gflags_VERSION})")
endif (gflags_FOUND)
configure_package_config_file (glog-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/glog-config.cmake
INSTALL_DESTINATION lib/cmake/glog
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file (glog-config-version.cmake VERSION
${GLOG_VERSION} COMPATIBILITY SameMajorVersion)
export (TARGETS glog NAMESPACE glog:: FILE glog-targets.cmake)
export (PACKAGE glog)
install (FILES
${CMAKE_CURRENT_BINARY_DIR}/glog-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/glog-config-version.cmake
DESTINATION lib/cmake/glog)
install (EXPORT glog-targets NAMESPACE glog:: DESTINATION lib/cmake/glog)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")

@ -0,0 +1,161 @@
# vim: et ts=4 sts=4 sw=4 tw=0
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
PROJECT(jsoncpp)
ENABLE_TESTING()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
OPTION(JSONCPP_WITH_TESTS "Compile and (for jsoncpp_check) run JsonCpp test executables" ON)
OPTION(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" ON)
OPTION(JSONCPP_WITH_WARNING_AS_ERROR "Force compilation to fail if a warning occurs" OFF)
OPTION(JSONCPP_WITH_STRICT_ISO "Issue all the warnings demanded by strict ISO C and ISO C++" ON)
OPTION(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON)
OPTION(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" OFF)
OPTION(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." ON)
OPTION(BUILD_STATIC_LIBS "Build jsoncpp_lib static library." ON)
# Ensures that CMAKE_BUILD_TYPE is visible in cmake-gui on Unix
IF(NOT WIN32)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage."
FORCE)
ENDIF()
ENDIF()
# Enable runtime search path support for dynamic libraries on OSX
IF(APPLE)
SET(CMAKE_MACOSX_RPATH 1)
ENDIF()
# Adhere to GNU filesystem layout conventions
INCLUDE(GNUInstallDirs)
SET(DEBUG_LIBNAME_SUFFIX "" CACHE STRING "Optional suffix to append to the library name for a debug build")
# Set variable named ${VAR_NAME} to value ${VALUE}
FUNCTION(set_using_dynamic_name VAR_NAME VALUE)
SET( "${VAR_NAME}" "${VALUE}" PARENT_SCOPE)
ENDFUNCTION()
# Extract major, minor, patch from version text
# Parse a version string "X.Y.Z" and outputs
# version parts in ${OUPUT_PREFIX}_MAJOR, _MINOR, _PATCH.
# If parse succeeds then ${OUPUT_PREFIX}_FOUND is TRUE.
MACRO(jsoncpp_parse_version VERSION_TEXT OUPUT_PREFIX)
SET(VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+(-[a-zA-Z0-9_]+)?")
IF( ${VERSION_TEXT} MATCHES ${VERSION_REGEX} )
STRING(REGEX MATCHALL "[0-9]+|-([A-Za-z0-9_]+)" VERSION_PARTS ${VERSION_TEXT})
LIST(GET VERSION_PARTS 0 ${OUPUT_PREFIX}_MAJOR)
LIST(GET VERSION_PARTS 1 ${OUPUT_PREFIX}_MINOR)
LIST(GET VERSION_PARTS 2 ${OUPUT_PREFIX}_PATCH)
set_using_dynamic_name( "${OUPUT_PREFIX}_FOUND" TRUE )
ELSE( ${VERSION_TEXT} MATCHES ${VERSION_REGEX} )
set_using_dynamic_name( "${OUPUT_PREFIX}_FOUND" FALSE )
ENDIF()
ENDMACRO()
# Read out version from "version" file
#FILE(STRINGS "version" JSONCPP_VERSION)
#SET( JSONCPP_VERSION_MAJOR X )
#SET( JSONCPP_VERSION_MINOR Y )
#SET( JSONCPP_VERSION_PATCH Z )
SET( JSONCPP_VERSION 1.8.4 )
jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION )
#IF(NOT JSONCPP_VERSION_FOUND)
# MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z")
#ENDIF(NOT JSONCPP_VERSION_FOUND)
SET( JSONCPP_SOVERSION 19 )
SET( JSONCPP_USE_SECURE_MEMORY "0" CACHE STRING "-D...=1 to use memory-wiping allocator for STL" )
MESSAGE(STATUS "JsonCpp Version: ${JSONCPP_VERSION_MAJOR}.${JSONCPP_VERSION_MINOR}.${JSONCPP_VERSION_PATCH}")
# File version.h is only regenerated on CMake configure step
CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/src/lib_json/version.h.in"
"${PROJECT_SOURCE_DIR}/include/json/version.h"
NEWLINE_STYLE UNIX )
CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/version.in"
"${PROJECT_SOURCE_DIR}/version"
NEWLINE_STYLE UNIX )
MACRO(UseCompilationWarningAsError)
IF(MSVC)
# Only enabled in debug because some old versions of VS STL generate
# warnings when compiled in release configuration.
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX ")
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
IF(JSONCPP_WITH_STRICT_ISO)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")
ENDIF()
ENDIF()
ENDMACRO()
# Include our configuration header
INCLUDE_DIRECTORIES( ${jsoncpp_SOURCE_DIR}/include )
IF(MSVC)
# Only enabled in debug because some old versions of VS STL generate
# unreachable code warning when compiled in release configuration.
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ")
ENDIF()
# Require C++11 support, prefer ISO C++ over GNU variants,
# as relying solely on ISO C++ is more portable.
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_EXTENSIONS OFF)
IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# using regular Clang or AppleClang
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare")
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Wextra")
# not yet ready for -Wsign-conversion
IF(JSONCPP_WITH_STRICT_ISO)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
ENDIF()
IF(JSONCPP_WITH_WARNING_AS_ERROR)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=conversion")
ENDIF()
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# using Intel compiler
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Wextra -Werror=conversion")
IF(JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
ENDIF()
ENDIF()
FIND_PROGRAM(CCACHE_FOUND ccache)
IF(CCACHE_FOUND)
SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
ENDIF(CCACHE_FOUND)
IF(JSONCPP_WITH_WARNING_AS_ERROR)
UseCompilationWarningAsError()
ENDIF()
IF(JSONCPP_WITH_PKGCONFIG_SUPPORT)
CONFIGURE_FILE(
"pkg-config/jsoncpp.pc.in"
"pkg-config/jsoncpp.pc"
@ONLY)
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkg-config/jsoncpp.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
ENDIF()
IF(JSONCPP_WITH_CMAKE_PACKAGE)
INSTALL(EXPORT jsoncpp
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp
FILE jsoncppConfig.cmake)
ENDIF()
# Build the different applications
ADD_SUBDIRECTORY( src )
#install the includes
ADD_SUBDIRECTORY( include )

@ -0,0 +1 @@
26927a27b9e74d48a2567ba6e3424b16

@ -0,0 +1,43 @@
#!/bin/sh
cd .. && \
SO_DIR=`pwd`/../asrDemo2/run && \
rm -rf lib include asr_resource && \
mkdir -p lib include/extern include/asr include/asrdemo asr_resource && \
\
echo "begin to build libasrdemoall.so" && echo "" && \
sleep 3 && \
cd $SO_DIR && \
make clean && make lib/libasrdemoall.so && \
cd - && \
ln -s $SO_DIR/lib/libasrdemoall.so lib/libasrdemoall.so && \
cp -r $SO_DIR/include/asrdemo/* include/asrdemo && \
cp -r ../../include/* include/asr && \
cp -r ../../extern/include/* include/extern && \
cp -r ../../resources/asr_resource/* asr_resource && \
\
echo "begin to build glog" && \
sleep 3 && \
cd lib-src && rm -rf glog-0.3.5 && tar xzf glog-0.3.5.tar.gz && \
cp glogCMakeLists.txt glog-0.3.5/CMakeLists.txt &&\
cd glog-0.3.5 && cmake . && make -j4 && \
pwd && cp -d -f *.so* ../../lib && \
cp -r -d -f ./glog ../../include/extern && \
cp -r -d -f ./src/glog/*.h ../../include/extern/glog && \
cd ../.. && \
echo "" && \
\
echo "begin to build jsoncpp" && \
sleep 3 && \
cd lib-src && rm -rf jsoncpp-1.8.4 && tar xzf jsoncpp-1.8.4.tar.gz && \
cp jsoncppCMakeLists.txt jsoncpp-1.8.4/CMakeLists.txt && cd jsoncpp-1.8.4 && \
cmake . && make -j4 && \
cp -d src/lib_json/*.so* ../../lib && \
cp -r -d include/json ../../include/extern && \
cd ../.. && \
echo "" && \
echo "build env finished"

@ -0,0 +1,11 @@
#!/bin/sh
EXT=$1
#ffmpeg -y -i 16k.wav -acodec pcm_s16le -f s16le -ac 1 -ar 16000 16k.pcm
cd .. && \
cd data/video && \
for file in $(ls *.$EXT);
do
name=`echo $file|cut -d . -f 1`
ffmpeg -y -i $file -acodec pcm_s16le -f s16le -ac 1 -ar 16000 $name.pcm
done

@ -0,0 +1,3 @@
#!/bin/sh
valgrind --gen-suppressions=all --leak-check=full --show-reachable=yes --suppressions=../scripts/srt.supp ../run/asrDemo_srt

@ -0,0 +1,26 @@
//
// Created by fu on 3/28/18.
//
#include "common.h"
namespace asr_srt {
void init_log(int argc,char* argv[]) {
google::InitGoogleLogging(argv[0]);
FLAGS_log_dir = "../log";
FLAGS_max_log_size = 4; // 4 MB
google::SetStderrLogging(google::INFO); // 同时输出到屏幕
FLAGS_colorlogtostderr=true;
FLAGS_stop_logging_if_full_disk = true;
FLAGS_logbufsecs =0; //缓冲日志输出默认为30秒此处改为立即输出
google::InstallFailureSignalHandler();
}
void release_log(){
google::ShutdownGoogleLogging();
}
}

@ -0,0 +1,19 @@
//
// Created by fu on 3/17/18.
//
#ifndef ASRDEMO_SRT_COMMON_H
#define ASRDEMO_SRT_COMMON_H
#include <iostream>
#include <asrdemo/Util.hpp>
#include <glog/logging.h>
// #define _LOG_COMMON "[" << asrdemo::Util::get_gmt_time() << "][" << __FILE__ << ":" << __LINE__ << "] "
#define ALOG LOG(INFO)
#define ELOG LOG(ERROR)
namespace asr_srt {
void init_log(int argc, char* argv[]);
void release_log();
}
#endif //ASRDEMO_SRT_COMMON_H

@ -0,0 +1,139 @@
#include <string>
#include <BDSSDKMessage.hpp>
#include <bds_asr_key_definitions.hpp>
#include <bds_ASRDefines.hpp>
#include <bits/unique_ptr.h>
#include <thread>
#include <asrdemo/Util.hpp>
#include "recognizer.hpp"
#include "common.h"
using namespace asr_srt;
const int MAX_NUM_RECOG = 6; //并发数
const int MAX_NUM_FILES = 20; // 一共需要识别多少个文件
// %d 从1开始到 MAX_NUM_FILES
const char TEMPLATE[] = "../data/video/fasheng%02d.pcm";
// "../data/video/fasheng%02d.pcm"
// "../data/16k-%d.pcm"
std::atomic_int g_count = ATOMIC_VAR_INIT(0);
static void set_config(bds::BDSSDKMessage &cfg_params) {
// app_id app_key app_secret 请测试成功后替换为您在网页上申请的appId appKey和appSecret
cfg_params.set_parameter(bds::ASR_PARAM_KEY_APP_ID, "10455099");
cfg_params.set_parameter(bds::ASR_PARAM_KEY_CHUNK_KEY, "rKCHBLmYiFPuCQTS0HttLbUD");
cfg_params.set_parameter(bds::ASR_PARAM_KEY_SECRET_KEY, "037dc446820ec143d1628c20146b9d34");
// 普通话搜索模型(没有逗号))1536普通话搜索模型+语义理解 15361, 普通话输入法模型(有逗号) 1537
cfg_params.set_parameter(bds::ASR_PARAM_KEY_PRODUCT_ID, "1537");
cfg_params.set_parameter(bds::COMMON_PARAM_KEY_DEBUG_LOG_LEVEL, bds::EVRDebugLogLevelOff); //关闭debug日志 ,上线时请注释此行
cfg_params.set_parameter(bds::ASR_PARAM_KEY_COMPRESSION_TYPE, bds::EVR_AUDIO_COMPRESSION_PCM);
// float vad_pause_time_ms = 700.0; //设置vad语句静音切分门限, ms。 即原始语音静音 700ms后SDK认为一句话结束
// cfg_params.set_parameter(bds::ASR_PARAM_KEY_MAX_SPEECH_PAUSE, vad_pause_time_ms);
//以下是不常用的参数
// cfg_params.set_parameter(bds::ASR_PARAM_KEY_COMPRESSION_TYPE, bds::EVR_AUDIO_COMPRESSION_BV32); // 有损压缩
// cfg_params.set_parameter(bds::ASR_PARAM_KEY_SAVE_AUDIO_ENABLE, 1); //是否存识别的音频
// cfg_params.set_parameter(bds::ASR_PARAM_KEY_SAVE_AUDIO_PATH, "sdk_save_audio.d"); //存音频的路径
// cfg_params.set_parameter(bds::ASR_PARAM_KEY_DISABLE_PUNCTUATION, 0); // 输出时没有逗号 搜索模型有效
}
static std::unique_ptr<asr_srt::Recognizer> create_recognizer(int num);
static void run();
static int run_one(int num);
int main(int argc, char *argv[]) {
init_log(argc, argv);
asrdemo::AsrdemoController::open_log_file("asrdemo-srt.log", 25);
std::thread threads[MAX_NUM_RECOG];
for(int i=0; i<MAX_NUM_RECOG; i++){
threads[i] = std::thread(run);
}
for(int i=0; i<MAX_NUM_RECOG; i++){
if (threads[i].joinable()){
threads[i].join();
}
}
asrdemo::AsrdemoController::close_log_file(); // 程序退出时或者不需要再写日志 固定用法, 引擎空闲时调用
asrdemo::AsrdemoController::do_cleanup(); // 程序退出时或者不需要asr服务时 固定用法, 引擎空闲时调用
release_log();
return 0;
}
void run() {
bool will_stop = false;
while (!will_stop) {
int count = g_count.fetch_add(1) + 1;
if (count > MAX_NUM_FILES) {
will_stop = true;
} else {
run_one(count);
}
}
}
static int run_one(int num) {
std::string error_msg;
std::unique_ptr<asr_srt::Recognizer> recognizer = create_recognizer(num);
bool will_read_file = true;
bool has_error = false;
while (will_read_file) {
RETURN_PROCESS_STATUS status = recognizer->process_one_frame(error_msg);
//ALOG << "status : " << status;
switch (status) {
case RETURN_ERROR:
fprintf(stderr, "%s, ERROR %s\n",recognizer->get_filename().c_str(), error_msg.c_str());
has_error = true;
break;
case RETURN_SKIP:
case RETURN_PROCESSING: {
uint64_t time = recognizer->get_next_process_time();
uint64_t sleepMs = time - asrdemo::Util::current_timestamp();
// ALOG << recognizer->get_filename() << " : begin to sleep ms :" << sleepMs;
std::this_thread::sleep_for(std::chrono::milliseconds(sleepMs));
break;
}
case RETURN_FILE_END:
will_read_file = false;
break;
default:
ALOG << "other status : " << status << std::endl;
break;
}
if (has_error){
break;
}
}
if (!has_error) {
has_error = !recognizer->try_waiting_finish(error_msg);
if (has_error) {
fprintf(stderr, "ERROR END %s\n", error_msg.c_str());
}
}
return 0;
}
static std::unique_ptr<asr_srt::Recognizer> create_recognizer(int num) {
char filename[100];
snprintf(filename, sizeof(filename), TEMPLATE, num);
bds::BDSSDKMessage cfg_params;
set_config(cfg_params);
asr_srt::Recognizer *recog = new asr_srt::Recognizer(filename);
std::string error_msg;
recog->config(cfg_params,error_msg ); // 此步不处理错误
return std::unique_ptr<asr_srt::Recognizer>(recog);
}

@ -0,0 +1,108 @@
//
// Created by fu on 3/17/18.
//
#include "recognizer.hpp"
#include "common.h"
#define CHECK_HAS_ERROR() if (_has_error){\
error_msg = _error_msg;\
ELOG << _error_msg;\
return RETURN_ERROR;\
}
namespace asr_srt {
Recognizer::Recognizer(
const std::string &filename
) : _filename(filename), _is(filename, std::ios_base::in | std::ios_base::binary),
_listener(get_srt_filename(filename)), _controller(APP_NAME, "../asr_resource/", _listener) {
ALOG << _filename << " :Recognizer inited";
_error_msg = "";
if (!_is || !_is.is_open()) {
_has_error = true;
_error_msg = "file open failed :" + filename;
ELOG << _error_msg;
}
}
Recognizer::~Recognizer() {
if (_is.is_open()) {
_is.close();
}
}
RETURN_PROCESS_STATUS Recognizer::config(bds::BDSSDKMessage &config, std::string &error_msg){
CHECK_HAS_ERROR();
if (!_controller.config(config,_error_msg)){
_has_error = true;
}
CHECK_HAS_ERROR();
return RETURN_OK;
}
bool Recognizer::try_waiting_finish(std::string &error_msg) {
return _listener.try_waiting_finish(error_msg);
}
RETURN_PROCESS_STATUS Recognizer::process_one_frame(std::string &error_msg) {
CHECK_HAS_ERROR();
if (_next_process_time > 0 && _next_process_time > asrdemo::Util::current_timestamp()) {
return RETURN_SKIP;
}
if (_is_file_end) {
return RETURN_WAITING_SDK_END;
}
RETURN_PROCESS_STATUS status = check_file_status();
if (status == RETURN_FILE_END) {
_has_error = !_controller.post_data_finish_and_stop(error_msg);
}
CHECK_HAS_ERROR();
if (status != RETURN_OK) {
return status;
}
return read_one_frame(error_msg);
}
RETURN_PROCESS_STATUS Recognizer::read_one_frame(std::string &error_msg) {
char audio_buf[FRAME_SIZE];
int readed_len = 0;
_is.read(audio_buf, FRAME_SIZE);
readed_len = _is.gcount();
if (readed_len == 0) {
// ELOG << "read file with length = 0 : " << _filename << std::endl;
return RETURN_SKIP;
}
_has_error = !_controller.post_audio_data(audio_buf, readed_len, _error_msg);
CHECK_HAS_ERROR();
int duration = asrdemo::Util::cal_speech_16k_duration_ms(readed_len); //下次调用需要sleep的时间
_next_process_time = asrdemo::Util::current_timestamp() + duration - 1; // 忽略运行1ms
return RETURN_PROCESSING;
}
RETURN_PROCESS_STATUS Recognizer::check_file_status() {
if (_has_error) {
return RETURN_ERROR;
}
if (_is.bad()) {
_has_error = true;
_error_msg = "file meets error, _is.fail(): " + _filename;
ELOG << _error_msg << ":" << _is.bad() << _is.fail();
return RETURN_ERROR;
}
if (_is.eof()) {
_is.close();
_is_file_end = true;
_next_process_time = 0;
return RETURN_FILE_END;
}
return RETURN_OK;
}
std::string Recognizer::get_srt_filename(const std::string &filename) const {
return filename.substr(0, filename.size() - 3) + "srt";
}
}

@ -0,0 +1,69 @@
//
// Created by fu on 3/17/18.
//
#ifndef ASRDEMO_SRT_RECOGNIZER_HPP
#define ASRDEMO_SRT_RECOGNIZER_HPP
#include <BDSSDKMessage.hpp>
#include <asrdemo/AsrdemoController.hpp>
#include <iostream>
#include <fstream>
#include "srt_file_listener.hpp"
namespace asr_srt {
enum RETURN_PROCESS_STATUS {
RETURN_OK = 0,
RETURN_SKIP = 1,
RETURN_PROCESSING = 2,
RETURN_FILE_END = 3,
RETURN_WAITING_SDK_END = 4,
RETURN_ERROR = -10
};
class Recognizer {
public:
Recognizer(const std::string &filename);
virtual ~Recognizer();
RETURN_PROCESS_STATUS process_one_frame(std::string &error_msg);
RETURN_PROCESS_STATUS config(bds::BDSSDKMessage &config, std::string &error_msg);
uint64_t get_next_process_time() const{
return _next_process_time;
}
bool try_waiting_finish(std::string &message);
std::string get_filename() const{
return _filename;
}
private:
const std::string APP_NAME = "asr_str";
const int FRAME_SIZE = 320; // 10ms
bool _has_error = false;
std::string _error_msg = "";
std::string _filename;
std::ifstream _is;
SrtFileListener _listener;
asrdemo::AsrdemoController _controller;
bool _is_file_end = false;
uint64_t _next_process_time = 0;
std::string get_srt_filename(const std::string &filename) const;
RETURN_PROCESS_STATUS check_file_status();
RETURN_PROCESS_STATUS read_one_frame(std::string &error_msg);
};
}
#endif //ASRDEMO_SRT_RECOGNIZER_HPP

@ -0,0 +1,142 @@
//
// Created by fu on 3/17/18.
//
#include <sstream>
#include <memory>
#include "srt_file_listener.hpp"
#include "common.h"
namespace asr_srt {
SrtFileListener::SrtFileListener(const std::string &srt_filename) : _filename(srt_filename) {
}
SrtFileListener::~SrtFileListener() {
if (_fp) {
fclose(_fp);
_fp = NULL;
}
}
bool SrtFileListener::try_waiting_finish(std::string &error_msg) {
ALOG << _filename << " : try_waiting_finish call";
if (_has_error) {
std::lock_guard<std::mutex> lk(_error_mutex);
error_msg = _error_msg;
return false;
}
{
std::unique_lock<std::mutex> lck(_waiting_mutex);
if (_is_finished) {
return true;
}
_cond.wait_for(lck, std::chrono::seconds(TIMEOUT), [this]() { return _is_finished.load(); });
ALOG << _filename << " : try_waiting_finish free";
if (_has_error) {
error_msg = _error_msg;
return false;
}
}
if (!_is_finished) {
error_msg = "sdk not finished";
return false;
} else {
return true;
}
}
void SrtFileListener::on_last_status(int status) {
ALOG << _filename << " : on_last_status call" << std::endl;
_is_finished = true;
fclose(_fp);
_fp = nullptr;
_cond.notify_all();
}
void SrtFileListener::on_start_working() {
_fp = fopen(_filename.c_str(), "w");
if (_fp == NULL) {
write_error("file does not exist");
}
if (ferror(_fp) != 0) {
write_error("ferror(_fp)");
}
const char bom[] = "\xef\xbb\xbf";
if (fwrite(bom, 1, strlen(bom), _fp)!= strlen(bom)) {
write_error("write file error");
}
}
void SrtFileListener::on_finish(const std::string &json) {
if (_has_error) {
return;
}
ALOG << _filename << " : " << json;
Json::Value value;
std::string error_msg = "";
bool is_success;
is_success = parse_json(json, value, error_msg);
if (is_success) {
if (!value.isMember("sn_start_time") || !value.isMember("sn_end_time") ||
!value.isMember("results_recognition")) {
is_success = false;
} else {
std::string start_time = value["sn_start_time"].asString();
format_srt_time(start_time);
std::string end_time = value["sn_end_time"].asString();
format_srt_time(end_time);
std::string word = "";
if (value["results_recognition"].size() > 0) {
word = value["results_recognition"][0].asString();
}
int count = _count.fetch_add(1);
count++;
std::ostringstream oss;
oss << count << "\r\n";
oss << start_time << " --> " << end_time << "\r\n\r\n";
oss << word << "\r\n";
std::string str = oss.str();
if (fwrite(str.c_str(), 1, str.size(), _fp) != str.size()) {
write_error("write file error");
}
}
}
if (!is_success){
write_error("json parse error: " + json);
}
}
void SrtFileListener::on_error(int err_domain, int err_code, const std::string &err_desc,
const std::string &sn) {
std::ostringstream os;
os << err_domain << "," << err_code << "," << err_desc << "," << sn;
write_error(os.str());
}
void SrtFileListener::write_error(const std::string &error_msg) {
std::string msg = "[" + _filename + "]" + error_msg;
_has_error = true;
_is_finished = true;
ELOG << _filename << " , " << msg;
std::lock_guard<std::mutex> lk(_error_mutex);
_error_msg = msg;
}
bool SrtFileListener::parse_json(const std::string &json, Json::Value &root, std::string &error_msg) {
Json::CharReaderBuilder rbuilder;
const std::unique_ptr<Json::CharReader> reader(rbuilder.newCharReader());
const char *str = json.c_str();
return reader->parse(str, str + json.size(), &root, &error_msg);
}
void SrtFileListener::format_srt_time(std::string &time) {
size_t pos = time.find(".");
time = time.replace(pos, 1, 1, ',');
if (pos == 5) {
time.insert(0, "00:");
}
}
}

@ -0,0 +1,54 @@
//
// Created by fu on 3/17/18.
//
#ifndef ASRDEMO_SRT_SRT_FILE_LISTENER_HPP
#define ASRDEMO_SRT_SRT_FILE_LISTENER_HPP
#include <fstream>
#include <asrdemo/StatusListener.hpp>
#include <mutex>
#include <condition_variable>
#include <json/json.h>
namespace asr_srt {
class SrtFileListener : public asrdemo::ResultListener {
public:
SrtFileListener(const std::string &srt_filename);
virtual ~SrtFileListener();
bool try_waiting_finish(std::string &error_msg);
protected:
virtual void on_start_working();
virtual void on_finish(const std::string &json);
virtual void on_error(int err_domain, int err_code, const std::string &err_desc, const std::string &sn);
virtual void on_last_status(int status);
private:
const int TIMEOUT = 3; // 3s内结束
FILE *_fp = nullptr;
std::string _filename;
std::atomic_bool _has_error = ATOMIC_VAR_INIT(false);
std::string _error_msg;
std::mutex _error_mutex;
std::mutex _waiting_mutex;
std::condition_variable _cond;
std::atomic_bool _is_finished = ATOMIC_VAR_INIT(false);
std::atomic_int _count = ATOMIC_VAR_INIT(0);
void write_error(const std::string &error_msg);
bool parse_json(const std::string &json, Json::Value &root, std::string &error_msg);
void format_srt_time(std::string &time);
};
}
#endif //ASRDEMO_SRT_SRT_FILE_LISTENER_HPP

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />

@ -0,0 +1,29 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (2)" />
</state>
</component>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/asrDemo2.iml" filepath="$PROJECT_DIR$/.idea/asrDemo2.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -0,0 +1,356 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true" buildAllGenerated="true">
<generated>
<config projectName="asrDemo2" targetName="asrDemo2" />
</generated>
</component>
<component name="CMakeSettings" AUTO_RELOAD="true">
<configurations>
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="7da795b6-b8f9-4d6c-a6f8-da234294f8fa" name="Default" comment="" />
<ignored path="$PROJECT_DIR$/cmake-build-debug/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="CMakeBuildProfile:Debug" />
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="AsrdemoController.hpp" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/asrdemo/AsrdemoController.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2128">
<caret line="112" column="28" selection-start-line="112" selection-start-column="15" selection-end-line="112" selection-end-column="28" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="AsrdemoController.cpp" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/asrdemo/AsrdemoController.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="305">
<caret line="138" column="25" selection-start-line="138" selection-start-column="25" selection-end-line="138" selection-end-column="25" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="BDSpeechSDK.hpp" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/../../include/BDSpeechSDK.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="741">
<caret line="39" column="42" selection-start-line="39" selection-start-column="27" selection-end-line="39" selection-end-column="42" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="ResultListener.cpp" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/asrdemo/ResultListener.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2337">
<caret line="123" selection-start-line="123" selection-end-line="123" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="yours_main.cpp" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/yours_main.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="133">
<caret line="107" column="20" selection-start-line="107" selection-start-column="15" selection-end-line="107" selection-end-column="20" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>SECRET</find>
<find>get_sdk_version</find>
<find>_post_data</find>
<find>output_callback</find>
</findStrings>
<dirStrings>
<dir>$PROJECT_DIR$</dir>
</dirStrings>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../.." />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/asrdemo/asrdemo_BdSpeechControl.hpp" />
<option value="$PROJECT_DIR$/src/asrdemo/BdSpeechControl.hpp" />
<option value="$PROJECT_DIR$/src/asrdemo/asrdemo.hpp" />
<option value="$PROJECT_DIR$/src/asrdemo/BdSpeechControlImpl.hpp" />
<option value="$PROJECT_DIR$/src/asrdemo/BdSpeechControlImpl.cpp" />
<option value="$PROJECT_DIR$/src/asrdemo/bd_speech_control_impl.cpp" />
<option value="$PROJECT_DIR$/src/asrdemo/util.cpp" />
<option value="$PROJECT_DIR$/src/asrdemo/result_listener.cpp" />
<option value="$PROJECT_DIR$/src/asrdemo/bd_speech_control_impl.hpp" />
<option value="$PROJECT_DIR$/src/asrdemo/controller.cpp" />
<option value="$PROJECT_DIR$/src/asrdemo/controller.hpp" />
<option value="$PROJECT_DIR$/src/asrdemo/asrdemo_controller.cpp" />
<option value="$PROJECT_DIR$/src/asrdemo/status_listener.cpp" />
<option value="$PROJECT_DIR$/src/asrdemo/status_listener.hpp" />
<option value="$PROJECT_DIR$/src/asrdemo/result_listener.hpp" />
<option value="$PROJECT_DIR$/src/yours_PrintResultListener.hpp" />
<option value="$PROJECT_DIR$/src/yours_PrintResultListener.cpp" />
<option value="$PROJECT_DIR$/run/build_and_run.sh" />
<option value="$PROJECT_DIR$/src/asrdemo/Util.cpp" />
<option value="$PROJECT_DIR$/src/asrdemo/Util.hpp" />
<option value="$PROJECT_DIR$/CMakeLists.txt" />
<option value="$PROJECT_DIR$/src/asrdemo/StatusListener.hpp" />
<option value="$PROJECT_DIR$/src/asrdemo/StatusListener.cpp" />
<option value="$PROJECT_DIR$/src/asrdemo/ResultListener.hpp" />
<option value="$PROJECT_DIR$/src/asrdemo/ResultListener.cpp" />
<option value="$PROJECT_DIR$/run/Makefile" />
<option value="$PROJECT_DIR$/src/asrdemo/AsrdemoController.hpp" />
<option value="$PROJECT_DIR$/src/asrdemo/AsrdemoController.cpp" />
<option value="$PROJECT_DIR$/src/yours_main.cpp" />
</list>
</option>
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="OCFindUsagesOptions" text="true" ivars="false" properties="true" derivedClasses="false" />
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="98" />
<option name="y" value="24" />
<option name="width" value="1067" />
<option name="height" value="796" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="1" id="Add" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="asrDemo2" type="b2602c69:ProjectViewProjectNode" />
<item name="asrDemo2" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="asrDemo2" type="b2602c69:ProjectViewProjectNode" />
<item name="asrDemo2" type="462c0819:PsiDirectoryNode" />
<item name="pcm" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="asrDemo2" type="b2602c69:ProjectViewProjectNode" />
<item name="asrDemo2" type="462c0819:PsiDirectoryNode" />
<item name="run" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="asrDemo2" type="b2602c69:ProjectViewProjectNode" />
<item name="asrDemo2" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="asrDemo2" type="b2602c69:ProjectViewProjectNode" />
<item name="asrDemo2" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="asrdemo" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="settings.editor.selected.configurable" value="settings.github" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/pcm" />
<recent name="$PROJECT_DIR$" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src/asrdemo" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager" selected="Application.asrDemo2">
<configuration name="Build All" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="asrDemo2" RUN_TARGET_NAME="asrDemo2" EXPLICIT_BUILD_TARGET_NAME="all" />
<configuration name="asrDemo2" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="asrDemo2" TARGET_NAME="asrDemo2" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="asrDemo2" RUN_TARGET_NAME="asrDemo2" />
<list>
<item itemvalue="Application.Build All" />
<item itemvalue="Application.asrDemo2" />
</list>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="7da795b6-b8f9-4d6c-a6f8-da234294f8fa" name="Default" comment="" />
<created>1520928319000</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1520928319000</updated>
<workItem from="1520928321546" duration="6077000" />
<workItem from="1520934509741" duration="2342000" />
<workItem from="1520936886802" duration="650000" />
<workItem from="1520995759290" duration="256000" />
<workItem from="1521005592224" duration="5501000" />
<workItem from="1521077152299" duration="4597000" />
<workItem from="1521105819004" duration="2049000" />
<workItem from="1521252966168" duration="2325000" />
<workItem from="1521257210479" duration="9565000" />
<workItem from="1521337066938" duration="601000" />
<workItem from="1521382560784" duration="4535000" />
<workItem from="1522110434147" duration="9000" />
<workItem from="1522223877455" duration="1821000" />
<workItem from="1522236798376" duration="266000" />
<workItem from="1523169342299" duration="1166000" />
<workItem from="1523257990397" duration="208000" />
<workItem from="1523330047332" duration="4857000" />
<workItem from="1523347938485" duration="2643000" />
<workItem from="1526364997321" duration="754000" />
<workItem from="1526369050148" duration="111000" />
<workItem from="1530869054050" duration="830000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="51163000" />
</component>
<component name="ToolWindowManager">
<frame x="65" y="-4" width="1855" height="1084" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.22925764" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Messages" order="7" weight="0.4090909" />
<window_info anchor="bottom" id="CMake" order="7" weight="0.3275401" />
<window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
<window_info anchor="bottom" id="Run" order="2" weight="0.3265086" />
<window_info anchor="bottom" id="Version Control" order="7" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Terminal" order="7" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.39973262" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="right" id="Commander" order="0" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32903227" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<option name="time" value="4" />
</breakpoint-manager>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/asrdemo/AsrdemoController.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2128">
<caret line="112" column="28" selection-start-line="112" selection-start-column="15" selection-end-line="112" selection-end-column="28" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../include/BDSpeechSDK.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="741">
<caret line="39" column="42" selection-start-line="39" selection-start-column="27" selection-end-line="39" selection-end-column="42" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/asrdemo/ResultListener.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2337">
<caret line="123" selection-start-line="123" selection-end-line="123" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/yours_main.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="4978">
<caret line="262" column="12" selection-start-line="262" selection-start-column="12" selection-end-line="262" selection-end-column="12" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/asrdemo/AsrdemoController.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2983">
<caret line="157" column="21" lean-forward="true" selection-start-line="157" selection-start-column="21" selection-end-line="159" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/asrdemo/AsrdemoController.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2128">
<caret line="112" column="28" selection-start-line="112" selection-start-column="15" selection-end-line="112" selection-end-column="28" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../include/BDSpeechSDK.hpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="741">
<caret line="39" column="42" selection-start-line="39" selection-start-column="27" selection-end-line="39" selection-end-column="42" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/asrdemo/ResultListener.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2337">
<caret line="123" selection-start-line="123" selection-end-line="123" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/asrdemo/AsrdemoController.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="305">
<caret line="138" column="25" selection-start-line="138" selection-start-column="25" selection-end-line="138" selection-end-column="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/yours_main.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="133">
<caret line="107" column="20" selection-start-line="107" selection-start-column="15" selection-end-line="107" selection-end-column="20" />
</state>
</provider>
</entry>
</component>
</project>

@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 2.8)
set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_BUILD_TYPE DEBUG)
project(asrDemo2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -O0 -fPIC -D__LINUX__ -Wno-unknown-pragmas -D_GLIBCXX_USE_CXX11_ABI=0 -Wno-unused-function")
file(GLOB SOURCE_FILES "src/*.c*" "src/*/*.cpp")
include_directories(../../extern/include ../../include ../../include/ASR)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../lib ${CMAKE_CURRENT_SOURCE_DIR}/../../extern/lib)
add_executable(asrDemo2 ${SOURCE_FILES})
target_link_libraries(asrDemo2 BDSpeechSDK curl iconv z ssl crypto uuid rt dl pthread)

@ -0,0 +1,5 @@
# ASR demo 2
对sdk做出封装示例
测试成功后,可以修改 yours_main.cpp 内static void set_config(bds::BDSSDKMessage &cfg_params)内的设置参数

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save