Last active
December 15, 2017 14:34
-
-
Save fiskurgit/3f4c49249acfe60a4714fa7e7b0d33ae to your computer and use it in GitHub Desktop.
Text to Speech using Processing and a BBC Micro:Bit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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