1
말하는 경우 예상하지만 사용자가 그 시간에 말하기를 중지하면 탐지를 중지하고 해당 데이터를 서버로 보내려는 것을 감지하려고합니다.어떻게 자동 정지 음성 인식에 대한 사용자 정지 내가 봇 응용 프로그램에서 일하고 여기에 내가 연설</li>에 모두 같이 노력하고 있습니다 </ul> <p>을</li> <li>텍스트를 텍스트로이 개 기능</p> <ul> <li>음성이
해당 사용자가 말하는 것을 방해 할 수있는 방법이 있습니까?
나는 음성 검출 코드 아래 사용하고 있습니다 :
// Starts an AVAudio Session
NSError *error;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];
[audioSession setActive:YES withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&error];
// Starts a recognition process, in the block it logs the input or stops the audio
// process if there's an error.
recognitionRequest = [[SFSpeechAudioBufferRecognitionRequest alloc] init];
AVAudioInputNode *inputNode = audioEngine.inputNode;
recognitionRequest.shouldReportPartialResults = YES;
recognitionTask = [speechRecognizer recognitionTaskWithRequest:recognitionRequest resultHandler:^(SFSpeechRecognitionResult * _Nullable result, NSError * _Nullable error) {
BOOL isFinal = NO;
if (result) {
// Whatever you say in the microphone after pressing the button should be being logged
// in the console.
NSLog(@"RESULT:%@",result.bestTranscription.formattedString);
self.inputToolbar.contentView.textView.text = result.bestTranscription.formattedString;
self.inputToolbar.contentView.rightBarButtonItem.enabled = YES;
isFinal = !result.isFinal;
}
if (error) {
if (audioEngine != NULL) {
[audioEngine stop];
[inputNode removeTapOnBus:0];
recognitionRequest = nil;
recognitionTask = nil;
}
}
}];
// Sets the recording format
AVAudioFormat *recordingFormat = [inputNode outputFormatForBus:0]; //[[AVAudioFormat alloc] initStandardFormatWithSampleRate:44100 channels:1];
[inputNode installTapOnBus:0 bufferSize:1024 format:recordingFormat block:^(AVAudioPCMBuffer * _Nonnull buffer, AVAudioTime * _Nonnull when) {
[recognitionRequest appendAudioPCMBuffer:buffer];
}];
// Starts the audio engine, i.e. it starts listening.
[audioEngine prepare];
[audioEngine startAndReturnError:&error];
NSLog(@"Say Something, I'm listening");
어느 한이에 대한 자세한 내용을 필요에 알려주세요.
미리 감사드립니다.
그것이 예상대로 작동하지만 난 우리가 API를 수 있도록 텍스트 음성을 사용하는대로 메모리 관리에 영향을 미칠 것이다 질문이 하나의 이미 네트워크 통화 및 녹화를 위해 더 많은 메모리와 CPU를 소비하고 있으므로 가능하다면 UR에 귀중한 의견을 전합니다. – CodeChanger
이 코드를 사용하고 있으며 응용 프로그램에서 잘 작동합니다. 당신은 레코더를 사용하여 침묵을 감지 할 수 있으므로 더 많은 메모리를 소비하지 않을 것이라고 생각합니다. 타이머와 레코더를 관리하는 데 필요한 것은 단 하나입니다. 작업이 완료되면 타이머를 무효화하고 레코더를 중지하십시오. – Pushpendra
네,이 코드를 시도해보고 라이브가 어떻게되는지 보도록하겠습니다.하지만 ur exp마다 생각하면 메모리가 더 많이 소모됩니다. 답장을 보내 주셔서 감사합니다. – CodeChanger