Skip to content

Instantly share code, notes, and snippets.

@fiskurgit
Last active December 15, 2017 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fiskurgit/3f4c49249acfe60a4714fa7e7b0d33ae to your computer and use it in GitHub Desktop.
Save fiskurgit/3f4c49249acfe60a4714fa7e7b0d33ae to your computer and use it in GitHub Desktop.
Text to Speech using Processing and a BBC Micro:Bit
from microbit import *
import speech
uart.init(9600)
word = ""
while True:
word = str(uart.readline())
if word and word != "None":
uart.write("_next_")
speech.say(word)
display.show(Image.HAPPY)
word = ""
import controlP5.*;
import processing.serial.*;
Serial microbitSerial;
ControlP5 cp5;
void setup() {
size(285, 28);
printArray(Serial.list());
//For me it's: /dev/cu.usbmodem1412
microbitSerial = new Serial(this, Serial.list()[1], 9600);
cp5 = new ControlP5(this);
cp5.addTextfield("textinput")
.setPosition(5,5)
.setSize(200,19)
.setAutoClear(false);
cp5.addButton("TALK")
.setValue(0)
.setPosition(210, 5);;
}
void draw() {
background(255);
}
void TALK() {
microbitSerial.write(" " + cp5.get(Textfield.class,"textinput").getText());
cp5.get(Textfield.class,"textinput").setText("");
}
void keyPressed(){
if(keyCode == ENTER){
TALK();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment