Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Spracherkennung

Beispiel Spracherkennung
// Simple Speech Recognition using Google's Speech Recognition Webkit
// based on the example from Florian Schulz http://stt.getflourish.com

import muthesius.net.*;
import org.webbitserver.*;

WebSocketP5 socket;

String input = "";
color c = color(0,0,0);

void setup() 
{
  size(640, 480);
  socket = new WebSocketP5(this, 8080);
}

void draw() 
{
  background(c);
  textSize(20);
  text(input, 20, 60);
}

void stop() 
{
  socket.stop();
}

void websocketOnMessage(WebSocketConnection con, String msg) 
{
  println(msg);
  msg = trim(msg);
  
  input = msg;
  
  if (msg.equals("black") || msg.equals("schwarz"))
  {
     c = color(0,0,0);
  }
  
  if(msg.equals("red") || msg.equals("rot"))
  {
    c = color(255,0,0);
  }
}

void websocketOnOpen(WebSocketConnection con) 
{
  println("A client joined");
}

void websocketOnClosed(WebSocketConnection con) 
{
  println("A client left");
}