<!DOCTYPE html><html><head><title>Talking Head - minimal example</title><style>body, html { width:100%; height:100%; max-width: 800px; margin: auto; position: relative; background-color: dimgray; color: white; }#avatar { display: block; width:100%; height:100%; }#controls { display: block; position: absolute; top: 10px; left: 10px; right: 10px; height: 50px; }#text { position: absolute; width: Calc( 100% - 110px ); height: 100%; top: 0; left: 0; bottom: 0; right: 110px; font-family: Arial; font-size: 20px; }#speak { block; position: absolute; top: 0; bottom: 0; right: 0; height: 100%; width: 100px; font-family: Arial; font-size: 20px; }#loading { display: block; position: absolute; bottom: 10px; left: 10px; right: 10px; height: 50px; font-family: Arial; font-size: 20px; }</style><script type="importmap">{ "imports":{"three": "https://cdn.jsdelivr.net/npm/three@0.161.0/build/three.module.js/+esm","three/addons/": "https://cdn.jsdelivr.net/npm/three@0.161.0/examples/jsm/","talkinghead": "https://cdn.jsdelivr.net/gh/met4citizen/TalkingHead@1.2/modules/talkinghead.mjs"}}</script><script type="module">import { TalkingHead } from "talkinghead";let head;document.addEventListener('DOMContentLoaded', async function(e) {// Instantiate the class// NOTE: Never put your API key in a client-side code unless you know// that you are the only one to have access to that code!const nodeAvatar = document.getElementById('avatar');head = new TalkingHead( nodeAvatar, {ttsEndpoint: "https://eu-texttospeech.googleapis.com/v1beta1/text:synthesize",ttsApikey: "put-your-own-Google-TTS-API-key-here", // <- Change thislipsyncModules: ["en", "fi"],cameraView: "upper"});// Load and show the avatarconst nodeLoading = document.getElementById('loading');try {nodeLoading.textContent = "Loading...";await head.showAvatar( {url: 'https://models.readyplayer.me/64bfa15f0e72c63d7c3934a6.glb?morphTargets=ARKit,Oculus+Visemes,mouthOpen,mouthSmile,eyesClosed,eyesLookUp,eyesLookDown&textureSizeLimit=1024&textureFormat=png',body: 'F',avatarMood: 'neutral',ttsLang: "en-GB",ttsVoice: "en-GB-Standard-A",lipsyncLang: 'en'}, (ev) => {if ( ev.lengthComputable ) {let val = Math.min(100,Math.round(ev.loaded/ev.total * 100 ));nodeLoading.textContent = "Loading " + val + "%";}});nodeLoading.style.display = 'none';} catch (error) {console.log(error);nodeLoading.textContent = error.toString();}// Speak when clickedconst nodeSpeak = document.getElementById('speak');nodeSpeak.addEventListener('click', function () {try {const text = document.getElementById('text').value;if ( text ) {head.speakText( text );}} catch (error) {console.log(error);}});});</script></head><body><div id="avatar"></div><div id="controls"><input id="text" type="text" value="Hi there. How are you? I'm fine."><input id="speak" type="button" value="Speak"></div><div id="loading"></div></body></html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。