Ошибка при запуске кода распознавания голоса при обработке - PullRequest
0 голосов
/ 13 февраля 2020

Я пытаюсь управлять своим arduino с помощью обработки и использовал какой-то API распознавания голоса от Google. Я наткнулся на этот сайт, и я сделал все, что он сказал, но у меня возникает ошибка при запуске.

Вот ссылка на сайте https://florianschulz.info/stt/

и вот код, который я поместил в обработку

import websockets.*;

WebsocketServer socket;

void setup() {
  socket = new WebsocketServer(this, 1337, "/p5websocket");
}

void draw() {
  background(0);
}

void webSocketServerEvent(String msg){
 println(msg);
}

, а вот код для html / js file

<!DOCTYPE HTML>
<html>
<head>
    <script type="text/javascript">

        // We need to check if the browser supports WebSockets

        if ("WebSocket" in window) {

            // Before we can connect to the WebSocket, we need to start it in Processing.

            var ws = new WebSocket("ws://localhost:1337/p5websocket");
        } else {

            // The browser doesn't support WebSocket

            alert("WebSocket NOT supported by your Browser!");
        }

        // Now we can start the speech recognition
        // Supported only in Chrome
        // Once started, you need to allow Chrome to use the microphone

        var recognition = new webkitSpeechRecognition();

        // Be default, Chrome will only return a single result.
        // By enabling "continuous", Chrome will keep the microphone active.

        recognition.continuous = true;

        recognition.onresult = function(event) {

            // Get the current result from the results object
            var transcript = event.results[event.results.length-1][0].transcript;

            // Send the result string via WebSocket to the running Processing Sketch
            ws.send(transcript);
        }

        // Start the recognition
        recognition.start();

        // Restart the recognition on timeout
        recognition.onend = function(){
            recognition.start();
        }

</script>
</head>
<body>
</body>
</html>

и здесь ошибка Я получаю enter image description here

...