为什么我面临语音RSS api的一些问题

问题描述 投票:0回答:1

我正在使用Voice RSS api进行文本到语音转换,我遇到了这个api的一些问题

这是my code

当试图在麦克风中说嗨或你好时,它工作正常,但与其他句子它没有回复

 if( itsValue == 'what is your name' || itsValue == 'may I have your name' || itsValue == 'how may I address you' || itsValue == 'who are you' || itsValue == 'may I know your name' || itsValue == 'how can I call you'){
              alert('df')
              var text = encodeURIComponent("Opening...please wait");
              document.getElementById("voiceresult").setAttribute("src", audioUrl+text);
              document.getElementById("voiceresult").play();
            } 
javascript html audio text-to-speech voice-recognition
1个回答
1
投票

这就是错误发生的原因:raw.githubusercontent.com以明文形式提供JavaScript文件(text/plain而不是application/javascript)。您的浏览器启用了严格的MIME类型检查,因此它会抛出一个错误,因为它会询问一些JavaScript,但会收到看似明文的内容。

不幸的是,你对raw.githubusercontent.com没有任何控制权,所以你有两个解决方案:

  • 在浏览器上禁用严格的MIME类型检查
  • 使用raw.githubusercontent.com的替代品,如jsdelivr
© www.soinside.com 2019 - 2024. All rights reserved.