Нет описания

voiceToText.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. var clientChatHtml = ''
  2. var serviceChatHtml = ''
  3. var objVoice ={
  4. agent_id:'8000',
  5. timestamp:new Date().getTime(),
  6. data:''
  7. }
  8. //VoiceCommAPI.setConfigureServer("http://配置服务器 URL");
  9. //var agent = VoiceCommAPI.createAgentControl();
  10. //agent.login(objVoice);
  11. //agent.setDetectSpeechEventListener(objVoice,function(data){})
  12. //agent.on('setDetectSpeechEventListener',function(data){})
  13. setTimeout(function(){
  14. for(var i = 0; i < voiceToTextContextAway.length; i++) {
  15. if (voiceToTextContextAway[i].type=="clientChat") {
  16. $('<div class="clientChat"><img src="img/youkeTx.png"><div class="clientChatText">'+
  17. voiceToTextContextAway[i].clientChat+'</div></div>').appendTo($(".voiceToTextContext"));
  18. } else if(voiceToTextContextAway[i].type=="serviceChat"){
  19. $('<div class="serviceChat"><img src="img/kefuTx.png"><div class="serviceChatText">'+
  20. voiceToTextContextAway[i].serviceChat+'</div></div>').appendTo($(".voiceToTextContext"));
  21. }
  22. }
  23. scrollTopFn("scrollVoice")
  24. },2000)
  25. $("#clickElementVoice").click(function(){
  26. var elThis = $(this)
  27. voiceTextToggle(elThis,1000)
  28. $(".voiceToText").toggle(1000)
  29. })
  30. function voiceTextToggle(elThis,timeToggle){
  31. if (elThis.text() === '隐藏') {
  32. elThis.text( '展开')
  33. elThis.css({
  34. "right":"0px",
  35. "top":"70%"
  36. })
  37. }else if(elThis.text() === '展开'){
  38. elThis.text( '隐藏')
  39. elThis.css({
  40. "right":"348px",
  41. "top":"50%"
  42. })
  43. }
  44. showFn(elThis,timeToggle)
  45. }
  46. function scrollTopFn(el){
  47. scrollVoice = document.getElementById(el)
  48. scrollVoice.scrollTop = scrollVoice.scrollHeight
  49. }
  50. function showFn(el,timeToggle){
  51. var timeoutShow= null
  52. el.hide()
  53. clearTimeout(timeoutShow)
  54. timeoutShow = setTimeout(function(){
  55. el.show()
  56. scrollTopFn("scrollVoice")
  57. timeoutShow= null
  58. },timeToggle)
  59. }
  60. var voiceToTextContextAway = [
  61. {
  62. type:"clientChat",
  63. clientChat:'你知道2020年我最宝贵的是什么吗'
  64. },
  65. {
  66. type:"serviceChat",
  67. serviceChat:'什么哟'
  68. },
  69. {
  70. type:"clientChat",
  71. clientChat:'我刚说的那句话的第一个字'
  72. },
  73. {
  74. type:"clientChat",
  75. clientChat:'啊 我的心好痛'
  76. },
  77. {
  78. type:"serviceChat",
  79. serviceChat:'怎么了'
  80. },
  81. {
  82. type:"clientChat",
  83. clientChat:'你卡在我心上了'
  84. },
  85. {
  86. type:"clientChat",
  87. clientChat:'我第一次见到你我就发烧了'
  88. },
  89. {
  90. type:"serviceChat",
  91. serviceChat:'为什么'
  92. },
  93. {
  94. type:"clientChat",
  95. clientChat:'因为一见钟情的体温是38°6啊'
  96. },
  97. {
  98. type:"clientChat",
  99. clientChat:'你知道我现在最想喝什么吗?'
  100. },
  101. {
  102. type:"serviceChat",
  103. serviceChat:'喝什么?'
  104. },
  105. {
  106. type:"clientChat",
  107. clientChat:'呵护你。'
  108. },
  109. {
  110. type:"clientChat",
  111. clientChat:'我觉得我好像见过你'
  112. },
  113. {
  114. type:"serviceChat",
  115. serviceChat:'在哪?'
  116. },
  117. {
  118. type:"clientChat",
  119. clientChat:'在我的结婚证上'
  120. },
  121. {
  122. type:"clientChat",
  123. clientChat:'你喜欢吃糖吗'
  124. },
  125. {
  126. type:"serviceChat",
  127. serviceChat:'不喜欢'
  128. },
  129. {
  130. type:"clientChat",
  131. clientChat:'那为什么你还这么甜'
  132. },
  133. {
  134. type:"clientChat",
  135. clientChat:'你跑的快吗?'
  136. },
  137. {
  138. type:"serviceChat",
  139. serviceChat:'不太快。'
  140. },
  141. {
  142. type:"clientChat",
  143. clientChat:'那太好了,我一定能追到你。'
  144. },
  145. {
  146. type:"clientChat",
  147. clientChat:'有一个很美的故事'
  148. },
  149. {
  150. type:"serviceChat",
  151. serviceChat:'什么故事'
  152. },
  153. {
  154. type:"clientChat",
  155. clientChat:'就是你遇见我的事'
  156. },
  157. ]