Linux?????????С???
???????????? ???????[ 2014/12/26 13:50:32 ] ????????Linux ??????? ??????
????????GrammarID???????????У?????????????????????????????????????????????????ubuntu??????????????Σ????????????????bbs????????????????????????????????????£???????16K??8KHz??????λ??16λ???????????????PCM??WAV????????????????????32λ???????????ffmpeg?????д????????ffmpeg???????£?
????ffmpeg -f alsa -i hw:0 -ar 16000 -ac 1 lib.wav
????????????????2???“????”??????????????????
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <qisr.h>
#define TRUE 1
#define FALSE 0
int run_asr(const char* asrfile);
const int BUFFER_NUM = 4096;
const int MAX_KEYWORD_LEN = 4096;
int main(int argc?? char* argv[])
{
int ret = MSP_SUCCESS;
const char* asrfile ="lib.wav";
ret = QISRInit("appid=xxxxxx");
if(ret != MSP_SUCCESS)
{
printf("QISRInit with errorCode: %d
"?? ret);
return 0;
}
ret = run_asr(asrfile);
QISRFini();
char key = getchar();
return 0;
}
int run_asr(const char* asrfile)
{
int ret = MSP_SUCCESS;
int i = 0;
FILE* fp = NULL;
char buff[BUFFER_NUM];
unsigned int len;
int status = MSP_AUDIO_SAMPLE_CONTINUE?? ep_status = -1?? rec_status = -1?? rslt_status = -1;
//const char* GrammarID="e7eb1a443ee143d5e7ac52cb794810fe";
const char *GrammarID="c66d4eecd37d4fe1c8274a2224b832d5";
const char* param = "rst=json??sub=asr??ssm=1??aue=speex??auf=audio/L16;rate=16000";//???sub=asr
const char* sess_id = QISRSessionBegin(GrammarID?? param?? &ret);
if ( MSP_SUCCESS != ret )
{
printf("QISRSessionBegin err %d
"?? ret);
return ret;
}
fp = fopen( asrfile ?? "rb");
if ( NULL == fp )
{
printf("failed to open file??please check the file.
");
QISRSessionEnd(sess_id?? "normal");
return -1;
}
printf("writing audio...
");
//
int count=0;
//
while ( !feof(fp) )
{
len = (unsigned int)fread(buff?? 1?? BUFFER_NUM?? fp);
feof(fp) ? status = MSP_AUDIO_SAMPLE_LAST : status = MSP_AUDIO_SAMPLE_CONTINUE;
if(status==MSP_AUDIO_SAMPLE_LAST)
printf("MSP_AUDIO_SAMPLE_LAST
");
if(status==MSP_AUDIO_SAMPLE_CONTINUE)
printf("MSP_AUDIO_SAMPLE_CONTINUE
");
//
ret = QISRAudioWrite(sess_id?? buff?? len?? status?? &ep_status?? &rec_status);
if ( ret != MSP_SUCCESS )
{
printf("
QISRAudioWrite err %d
"?? ret);
break;
}
//
printf("%d
"??count++);
//
if ( rec_status == MSP_REC_STATUS_SUCCESS )
{
const char* result = QISRGetResult(sess_id?? &rslt_status?? 0?? &ret);
if (ret != MSP_SUCCESS )
{
printf("error code: %d
"?? ret);
break;
}
else if( rslt_status == MSP_REC_STATUS_NO_MATCH )
printf("get result nomatch
");
else
{
if ( result != NULL )
printf("get result[%d/%d]:len:%d
%s
"?? ret?? rslt_status??strlen(result)?? result);
}
}
printf(".");
}
printf("
");
if (ret == MSP_SUCCESS)
{
printf("get reuslt~~~~~~~
");
char asr_result[1024] = "";
unsigned int pos_of_result = 0;
int loop_count = 0;
do
{
const char* result = QISRGetResult(sess_id?? &rslt_status?? 0?? &ret);
if ( ret != 0 )
{
printf("QISRGetResult err %d
"?? ret);
break;
}
if( rslt_status == MSP_REC_STATUS_NO_MATCH )
{
printf("get result nomatch
");
}
else if ( result != NULL )
{
//
FILE*f=fopen("data.txt"??"wb");
printf("~~~%d
"??strlen(result));
fwrite(result??1??strlen(result)??f);
fclose(f);
//
printf("[%d]:get result[%d/%d]: %s
"?? (loop_count)?? ret?? rslt_status?? result);
strcpy(asr_result+pos_of_result??result);
pos_of_result += (unsigned int)strlen(result);
}
else
{
printf("[%d]:get result[%d/%d]
"??(loop_count)?? ret?? rslt_status);
}
usleep(500000);
} while (rslt_status != MSP_REC_STATUS_COMPLETE && loop_count++ < 30);
if (strcmp(asr_result??"")==0)
{
printf("no result
");
}
}
QISRSessionEnd(sess_id?? NULL);
printf("QISRSessionEnd.
");
fclose(fp);
return 0;
}
|
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
Linux??????DDR????????????Linux?????????????????豸??????????linux???в???????????м??????????????????????????Linux????Linux??DNS????????????γ???????????Linux?????????????Linux????(???)????????Linux ????????????????????????????????Windows???У?Linux???????Linux????????????????Linux iommu??vfio???????Linux????ε???TCP???????Linux?????????????СLinux?·???????????Linux???Jexus?й?Asp.Net Core??ó???Linux?????????Щ??
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????