I'm implementing voice to text using speech framework in my app.
If there was already some text in the textview, how can I append it with speech recognizer?
recognitionTask = speechRecognizer.recognitionTask(with: recognitionRequest, resultHandler: { (result, error) in
var isFinal = false
if let result = result {
self.dataTextView.text = self.dataTextView.text.appending(result.bestTranscription.formattedString)
isFinal = result.isFinal
}
if error != nil || isFinal {
//stop recognising speech
self.audioEngine.stop()
inputNode.removeTap(onBus: 0)
}
})
Suppose that, I added text to textview via keyboard "Test data". now using speech recognizer I said "This is new data", I'm expecting result to be Test data This is new data". Result is as in aattchment