我有一个应用程序需要使用麦克风录制用户语音。我正在尝试制作一个speech to text
。检测输入音频的电平?
我的工作与SpeechKit.framework
以下是用我的代码:
-(void)starRecording{
self.voiceSearch = [[SKRecognizer alloc] initWithType:SKSearchRecognizerType
detection:SKShortEndOfSpeechDetection
language:[[USER_DEFAULT valueForKey:LANGUAGE_SPEECH_DIC] valueForKey:@"record"]
delegate:self];
}
- (void)recognizer:(SKRecognizer *)recognizer didFinishWithResults:(SKRecognition *)results {
long numOfResults = [results.results count];
if (numOfResults > 0) {
// update the text of text field with best result from SpeechKit
self.recordString = [results firstResult];
[self sendChatWithMediaType:@"messageCall" MediaUrl:@"" ContactDetail:@"{}" LocationDetail:@"{}"];
[self.voiceSearch stopRecording];
}
if (self.voiceSearch) {
[self.voiceSearch cancel];
}
[self starRecording];
}
这使得SKRecognizer
是一直开放,那件事降低应用程序的性能。
我想在麦克风检测到输入音频时启动SKRecognizer
。
我有一个方法呢?麦克风为我输入声音时调用的方法还是总是返回检测到的音频电平的方法?
谢谢!
您是否使用AvsudioRecorder类录制音频? – Jageen