12
Siriはどのように話し終えたかを判断できます。私が知りたいのは、私のアプリでAppleの音声認識APIと同様の機能を実装したいということです。これは実行可能なのか、ユーザーが話しを停止したかを知る唯一の方法はユーザー入力によるものですか?ユーザーが話し終えたときに音声認識を停止する
Siriはどのように話し終えたかを判断できます。私が知りたいのは、私のアプリでAppleの音声認識APIと同様の機能を実装したいということです。これは実行可能なのか、ユーザーが話しを停止したかを知る唯一の方法はユーザー入力によるものですか?ユーザーが話し終えたときに音声認識を停止する
タイマーを使うことができます。同じ問題がありました。優雅な方法で解決できませんでした。
fileprivate var timer:Timer?
func startRecordingTimer() {
lastString = ""
createTimerTimer(4)
}
func stopRecordingTimer() {
timer?.invalidate()
timer = nil
}
fileprivate func whileRecordingTimer() {
createTimerTimer(2)
}
fileprivate var lastString = ""
func createTimerTimer(_ interval:Double) {
OperationQueue.main.addOperation({[unowned self] in
self.timer?.invalidate()
self.timer = Timer.scheduledTimer(withTimeInterval: interval, repeats: false) { (_) in
self.timer?.invalidate()
if(self.lastString.characters.count > 0){
//DO SOMETHING
}else{
self.whileRecordingTimer()
}
}
})
}
とSFSpeechRecognitionTaskDelegate
public func speechRecognitionTask(_ task: SFSpeechRecognitionTask, didHypothesizeTranscription transcription: SFTranscription) {
let result = transcription.formattedString
lastString = result
}
に私の理解では、「利用者が話し終えると、」あなたが処理する必要がないということです。 SiriKitのガイド(https://developer.apple.com/library/content/documentation/Intents/Conceptual/SiriIntegrationGuide/ResolvingandHandlingIntents.html#//apple_ref/doc/uid/TP40016875-CH5-SW1)を参照してください。基本的にSiriKitは、ユーザーの発言から収集されたデータを「意図」にしており、目的を処理して独自の操作を実行するだけで済みます。 – volatilevar
質問はSiriKitではなく、音声認識APIについて質問しています。 – nathan
運がよろしいですか?私はこれと自分自身で苦労している – alhadhrami