var clientChatHtml = '' var serviceChatHtml = '' var objVoice ={ agent_id:'8000', timestamp:new Date().getTime(), data:'' } //VoiceCommAPI.setConfigureServer("http://配置服务器 URL"); //var agent = VoiceCommAPI.createAgentControl(); //agent.login(objVoice); //agent.setDetectSpeechEventListener(objVoice,function(data){}) //agent.on('setDetectSpeechEventListener',function(data){}) setTimeout(function(){ for(var i = 0; i < voiceToTextContextAway.length; i++) { if (voiceToTextContextAway[i].type=="clientChat") { $('
'+ voiceToTextContextAway[i].clientChat+'
').appendTo($(".voiceToTextContext")); } else if(voiceToTextContextAway[i].type=="serviceChat"){ $('
'+ voiceToTextContextAway[i].serviceChat+'
').appendTo($(".voiceToTextContext")); } } scrollTopFn("scrollVoice") },2000) $("#clickElementVoice").click(function(){ var elThis = $(this) voiceTextToggle(elThis,1000) $(".voiceToText").toggle(1000) }) function voiceTextToggle(elThis,timeToggle){ if (elThis.text() === '隐藏') { elThis.text( '展开') elThis.css({ "right":"0px", "top":"70%" }) }else if(elThis.text() === '展开'){ elThis.text( '隐藏') elThis.css({ "right":"348px", "top":"50%" }) } showFn(elThis,timeToggle) } function scrollTopFn(el){ scrollVoice = document.getElementById(el) scrollVoice.scrollTop = scrollVoice.scrollHeight } function showFn(el,timeToggle){ var timeoutShow= null el.hide() clearTimeout(timeoutShow) timeoutShow = setTimeout(function(){ el.show() scrollTopFn("scrollVoice") timeoutShow= null },timeToggle) } var voiceToTextContextAway = [ { type:"clientChat", clientChat:'你知道2020年我最宝贵的是什么吗' }, { type:"serviceChat", serviceChat:'什么哟' }, { type:"clientChat", clientChat:'我刚说的那句话的第一个字' }, { type:"clientChat", clientChat:'啊 我的心好痛' }, { type:"serviceChat", serviceChat:'怎么了' }, { type:"clientChat", clientChat:'你卡在我心上了' }, { type:"clientChat", clientChat:'我第一次见到你我就发烧了' }, { type:"serviceChat", serviceChat:'为什么' }, { type:"clientChat", clientChat:'因为一见钟情的体温是38°6啊' }, { type:"clientChat", clientChat:'你知道我现在最想喝什么吗?' }, { type:"serviceChat", serviceChat:'喝什么?' }, { type:"clientChat", clientChat:'呵护你。' }, { type:"clientChat", clientChat:'我觉得我好像见过你' }, { type:"serviceChat", serviceChat:'在哪?' }, { type:"clientChat", clientChat:'在我的结婚证上' }, { type:"clientChat", clientChat:'你喜欢吃糖吗' }, { type:"serviceChat", serviceChat:'不喜欢' }, { type:"clientChat", clientChat:'那为什么你还这么甜' }, { type:"clientChat", clientChat:'你跑的快吗?' }, { type:"serviceChat", serviceChat:'不太快。' }, { type:"clientChat", clientChat:'那太好了,我一定能追到你。' }, { type:"clientChat", clientChat:'有一个很美的故事' }, { type:"serviceChat", serviceChat:'什么故事' }, { type:"clientChat", clientChat:'就是你遇见我的事' }, ]