在帧上检测到我的声音时如何让 3D 模型头像说话 [英] How to make the 3D model avatar talking when my voice is detected on a-frame

查看:17
本文介绍了在帧上检测到我的声音时如何让 3D 模型头像说话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要的是在一个框架上,当我说话时,我的 3D 模型头像也在说话.

按照本指南,https://aframe.io/docs/1.1.0/introduction/models.html#animating-models,我用这个资源创建了 3D 模型头像,https://sketchfab.com/3d-models/bake-talking3-e715ab67be934a108d0a952d90c07210

但是这个 gltf 3D 模型一直在说话.每当我说话时,我都需要交互式 3D 模型说话.

假设我的语音检测已经实现.

有人可以回答这个吗?

解决方案

animation-mixer 组件有两个方法应该会有所帮助

  • playAction() 将播放
  • stopAction() 将停止

<块引用>

假设我的语音检测已经实现.

那么您的代码可能如下所示:

const modelEntity = document.querySelector([gltf-model]")const animationComponent = modelEntity.components[animation-mixer"]mySpeechRecognition.onpeechstart = function() {animationComponent.playAction();}mySpeechRecognition.onspeechend= function() {animationComponent.stopAction();}

类似于我在这个故障中所做的事情.绿色播放,红色停止.点击鱼查看来源.

What I want is that on a-frame, when I talk, my 3D model avatar is also being made talking.

Following this guide, https://aframe.io/docs/1.1.0/introduction/models.html#animating-models, I created 3D model avatar with this resource, https://sketchfab.com/3d-models/bake-talking3-e715ab67be934a108d0a952d90c07210

But this gltf 3D model is talking all the time. I need interactive 3D model talking whenever I talk.

Let's assume my voice detection is already implemented.

Can anyone answer this, please?

解决方案

The animation-mixer component has two methods that should help

  • playAction() which will play the
  • stopAction() which will stop the

Let's assume my voice detection is already implemented.

Then Your code could look like this:

const modelEntity = document.querySelector("[gltf-model]")
const animationComponent = modelEntity.components["animation-mixer"]
mySpeechRecognition.onspeechstart = function() {
   animationComponent.playAction();
}

mySpeechRecognition.onspeechend= function() {
   animationComponent.stopAction();
}

Something like what I did in this glitch. Green plays, red stops. Click on the fish to check out the source.

这篇关于在帧上检测到我的声音时如何让 3D 模型头像说话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆