After setting up the project, while specking I am getting error(VoiceOverlay-Demo[640:138261] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Speaker (type: Speaker)) #19
I setup the demo project & giving all permission as you had mentioned in Redme section. But while testing application is not able to Listen anything & every time I am getting one error which was mentioned below :
VoiceOverlay-Demo[640:138261] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Speaker (type: Speaker)
@objc func buttonTapped() {
// First way to listen to recording through callbacks
voiceOverlayController.start(on: self, textHandler: { (text, final, extraInfo) in
print("callback: getting (String(describing: text))")
print("callback: is it final? (String(describing: final))")
if final {
let string = "Hello, World!"
let utterance = AVSpeechUtterance(string: string)
utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
let synth = AVSpeechSynthesizer()
synth.speak(utterance)
// here can process the result to post in a result screen
Timer.scheduledTimer(withTimeInterval: 1.5, repeats: false, block: { (_) in
let myString = text
let myAttribute = [ NSAttributedString.Key.foregroundColor: UIColor.red ]
let myAttrString = NSAttributedString(string: myString, attributes: myAttribute)
self.voiceOverlayController.settings.resultScreenText = myAttrString
self.voiceOverlayController.settings.layout.resultScreen.titleProcessed = "BLA BLA"
})
}
}, errorHandler: { (error) in
print("callback: error \(String(describing: error))")
}, resultScreenHandler: { (text) in
print("Result Screen: \(text)")
}
)
}
// Second way to listen to recording through delegate
func recording(text: String?, final: Bool?, error: Error?) {
if let error = error {
print("delegate: error (error)")
}
if error == nil {
label.text = text
}
}
}
You can check this StackOverflow thread which explains this error. It doesn't seem related to the this library if I understand correctly, so I'm closing this for now
Hello,
I setup the demo project & giving all permission as you had mentioned in Redme section. But while testing application is not able to Listen anything & every time I am getting one error which was mentioned below :
VoiceOverlay-Demo[640:138261] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Speaker (type: Speaker)
My ViewController file :
// // ViewController.swift // VoiceOverlay-Demo // // Created by Guy Daher on 25/06/2018. // Copyright © 2018 Algolia. All rights reserved. //
import UIKit import InstantSearchVoiceOverlay import Speech
class ViewController: UIViewController, VoiceOverlayDelegate {
let voiceOverlayController = VoiceOverlayController() let button = UIButton() let label = UILabel()
override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib.
}
@objc func buttonTapped() { // First way to listen to recording through callbacks voiceOverlayController.start(on: self, textHandler: { (text, final, extraInfo) in print("callback: getting (String(describing: text))") print("callback: is it final? (String(describing: final))")
} // Second way to listen to recording through delegate func recording(text: String?, final: Bool?, error: Error?) { if let error = error { print("delegate: error (error)") } if error == nil { label.text = text } } }
Regards, Sandeep