ios 调用google api 实现语音识别
[cpp]view plaincopyprint?- (void)sendRequest:(id)sender { NSURL *URL = [NSURL URLWithString:@"http://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=zh-CN&maxresults=
·
- - (void)sendRequest:(id)sender {
- NSURL *URL = [NSURL URLWithString:@"http://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=zh-CN&maxresults=9"];
- ASIHTTPRequest *request = [[[ASIHTTPRequest alloc]initWithURL:URL] autorelease];
- [request addRequestHeader:@"User-Agent" value:@"ASIHTTPRequest"];
- [request addRequestHeader:@"Content-Type" value:@"audio/x-flac; rate=16000"];
- [request setRequestMethod:@"POST"];
- NSData *data = [NSData dataWithContentsOfFile:@"/Users/adminadmin/Desktop/hello.flac"];
- NSLog(@"date:%@",data);
- [request appendPostData:data];
- [request setDidFinishSelector:@selector(didFinishPost:)];
- [request setDidFailSelector:@selector(didFailedPost:)];
- [request setDelegate:self];
- [request startSynchronous];
- }
更多推荐
已为社区贡献1条内容
所有评论(0)