4

I am working on speech to text iOS 10 feature.

I want SFSpeechRecognitionTaskDelegate's delegate methods to be called for checking the completed results.

func speechRecognitionTask(_ task: SFSpeechRecognitionTask, didFinishRecognition recognitionResult: SFSpeechRecognitionResult);

But its any delegate method is not getting called. Also I am curious about why its .delegate property which is not available for setting delegate to self.

Any Help will be appreciated. Thanks in advance.

Edited: Also, The delegate Property set by the protocol is not found in the documentaion. i.e.

@property (nonatomic, weak) id<SFSpeechRecognitionTaskDelegate> delegate;

is not available in SFSpeechRecognitionTask.h file. Is it necessary that we need property for that?

Vin
  • 456
  • 6
  • 18
  • can you show some code? – Vatsal Shukla Oct 27 '16 at 10:47
  • Ah! Forgot to comment here again. There is explicit method for this delegate to call. recognitionTaskWithRequest:delegate: method is available for this. I found this method in SFSpeechRecognizer documentaion. Here you will get it: https://developer.apple.com/reference/speech/sfspeechrecognizer?language=objc – Vin Oct 27 '16 at 13:51

2 Answers2

2

use:

 self.speechRecognizer.recognitionTask(with:  self.recognitionRequest!, delegate: self)
masaldana2
  • 635
  • 9
  • 20
  • 1
    If I need to use the result handler method recognitionTask = speechRecognizer?.recognitionTask(with: request, resultHandler: {result, error in //code } its difficult to use both delegate and handler methods. – Rakesh iOS Dev Mar 27 '19 at 06:59
0

refer this article, It contains demo app on speechkit in swift,

https://www.appcoda.com/siri-speech-framework/

It works fine for me.

KAR
  • 3,303
  • 3
  • 27
  • 50
  • So are you using SFSpeechRecognitionTaskDelegate's delegate methods? Can you share me the code snippet of SFSpeechRecognitionTaskDelegate methods? – Vin Oct 07 '16 at 11:29
  • I am using SFSpeechRecognizerDelegate. – KAR Oct 07 '16 at 11:31
  • 1
    Ok. I want a procedure where, after certain pause in speech, the recognizer should stop working and it should give the final result of the speech recognition. I am sending this text as input to my SearchView Controller. So I need the complete sentence spoken by user – Vin Oct 07 '16 at 11:38
  • Have you refer apple's document for this? – KAR Oct 07 '16 at 11:43
  • 1
    https://forums.developer.apple.com/thread/64832 someone else is also facing the same issue. Have you tried calling the SFSpeechRecognitionTaskDelegate methods? – Vin Oct 07 '16 at 11:45
  • @KAR delegate method is not calling perfectlly, there is only two methods are calling. – Vatsal Shukla Oct 27 '16 at 10:54