Trying to create a video captioning application. I am opening the video file using UIImagePickerController. Can convert the speech to text but the text is created before even said on video. I need it to be syncronized with the video.
How can I syncronize the text to the video and print it to console when it is said?
func processVideo(_ videoURL: URL) { let recognizer = SFSpeechRecognizer(locale: Locale(identifier: "en-US"))!
let request = SFSpeechURLRecognitionRequest(url: videoURL)
recognizer?.recognitionTask(with: request, resultHandler: { [weak self] (result, error) in
if let result = result {
// Update the text overlay label with the transcribed text
let transcribedText = result.bestTranscription.formattedString
DispatchQueue.main.async {
print(transcribedText)
}
} else {
print(error)
}
})
}