3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

実装

SFSpeechRecognizerのrecognitionTaskの結果を完了ハンドラ内でSCNTextにして、SCNActionで動かします。


let speechRecognizer = SFSpeechRecognizer(locale: Locale(identifier: "ja-JP"))
speechRecognizer?.delegate = self
let recognitionRequest = SFSpeechAudioBufferRecognitionRequest()

let recognitionTask = speechRecognizer?.recognitionTask(with: recognitionRequest) { result, error in        
      //認識タスク完了時に呼ばれる
      let recognizedText = result.bestTranscription.formattedString
      let text = SCNText(string: cutText, extrusionDepth: 2)
      let textNode = SCNNode(geometry: text)
      text.firstMaterial?.diffuse.contents = UIColor.randomColor
      self.sceneView.scene.rootNode.addChildNode(textNode)
      //ランダムな位置にテキストを置いて、動かす
      let random = Float.random(in: -100...100)
      let random2 = Float.random(in: -100...100)
      let random3 = Float.random(in: -200 ... -50)
      textNode.position = SCNVector3(x: 20, y: random2, z: random3)
      textNode.runAction(SCNAction.move(to: SCNVector3(x: -100, y: random, z: random3), duration: 5),completionHandler: {
      textNode.removeFromParentNode()
      })

機械学習やAR関連の技術情報を発信しています。
MLBoysだいすけ https://twitter.com/JackdeS11
MLBoysゆうじ https://twitter.com/oka_yuuji

Core MLやCreate ML、Vision、ARKitを使ったアプリを作っています。
rockyshikoku@gmail.com

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?