A nice book for ideas


Work document for friends
A nice book for ideas


Work document for friends
In the past i’ve converted some VHS movies speech to text, using all kinds of tools.
Lets use some opensource tools!
pip install moviepy pip install SpeechRecognition
Create a python script with the following:
(Called mine wav2txt.py)
import math, contextlib
import speech_recognition as sr
from moviepy.editor import AudioFileClip
movie_audio_file_name = "movieadiofile.wav"
with contextlib.closing(wave.open(movie_audio_file_name,'r')) as f:
frames = f.getnframes()
rate = f.getframerate()
duration = frames / float(rate)
total_duration = math.ceil(duration / 60)
r = sr.Recognizer()
for i in range(0, total_duration):
with sr.AudioFile(movie_audio_file_name) as source:
audio = r.record(source, offset=i*60, duration=60)
f = open("transcription.txt", "a")
f.write(r.recognize_google(audio, language="nl-NL"))
f.write(" ")
f.close()
Now convert a movie to wav using below.
ffmpeg -i /fileserver/path/koolhoven.mkv movieaudiofile.wav
run python3 wav2txt.py
output
(Note .. these are not timestamped for subtitles)
I only needed the things being said in the home movie recordings as text.
Ik zit hier in de film The James Dean aan de
wereld voorstelde en daarmee de tienerfilm ingeleverd introduceren zelden werden onrustige 10 asiel zo mooi blootgelegd als ik deze film van Nicolas bij en dat wordt dan meteen toevallig even de mooiste
titels ooit wel eens autocross vanavond kijken we naar de kom ik nog even veel zomer dat je voor het eerste meisje Zoem de eerste baantje
etc..
These tiny modules use a Clock and Data signal.
The rest of the pins are for 3.3V and Gnd.
There are many libraries you can choose from, i’ve tried several.
For now, i ended up with this one.
Another promising one is https://github.com/AKJ7/TM1637
Another one i’ve tested https://github.com/bxparks/AceSegment
Now i have to add Wifi and Mqtt so it can remotely controlled.
Connected like this
Code with Wifi/Mqtt
#include <Arduino.h>
#include <TM1637Display.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
const char* ssid = "MYSSID";
const char* password = "MYSSIDPASS";
const char* mqtt_server = "MQTT-SERVER-IP";
const int CLK = D6; //Set the CLK pin connection to the display
const int DIO = D5; //Set the DIO pin connection to the display
int numCounter = 0;
int mydata = 0;
// The amount of time (in milliseconds) between tests
#define TEST_DELAY 2000
const uint8_t SEG_DONE[] = {
SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, // d
SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F, // O
SEG_C | SEG_E | SEG_G, // n
SEG_A | SEG_D | SEG_E | SEG_F | SEG_G // E
};
TM1637Display display(CLK, DIO);
WiFiClient espClient;
PubSubClient client(espClient);
unsigned long lastMsg = 0;
#define MSG_BUFFER_SIZE (50)
char msg[MSG_BUFFER_SIZE];
int value = 0;
void setup()
{
display.setBrightness(0x0a); //set the diplay to maximum brightness
Serial.begin(115200);
setup_wifi();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
}
void setup_wifi() {
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
randomSeed(micros());
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void callback(char* topic, byte* payload, unsigned int length) {
char buffer[4];
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (int i = 0; i < length; i++) {
Serial.print((char)payload[i]);
buffer[i] = int(payload[i]);
}
Serial.println();
// mydata=int(payload[0])+int(payload[1]*10);
int n;
n = atoi(buffer);
display.showNumberDec(n); //Display the numCounter value;
}
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Create a random client ID
String clientId = "ESP8266Client-";
clientId += String(random(0xffff), HEX);
// Attempt to connect
if (client.connect(clientId.c_str())) {
Serial.println("connected");
// Once connected, publish an announcement...
client.publish("escape/seg1ping", "seg1alive");
// ... and resubscribe
client.subscribe("escape/seg1data");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}
void loop() {
if (!client.connected()) {
reconnect();
}
client.loop();
unsigned long now = millis();
if (now - lastMsg > 2000) {
lastMsg = now;
++value;
snprintf (msg, MSG_BUFFER_SIZE, "seg1alive #%ld", value);
Serial.print("Publish message: ");
Serial.println(msg);
client.publish("escape/seg1ping", msg);
}
}
As part of my internet based escape room.
I took the idea from the Keep-talking-and-nobody-explodes game.

When starting up, is gets the configuration from a Mqtt Topic.
So i can create a different setup over the internet.
The result is also send back via MQTT.
(example play, all players are on different locations)
I used a wire with a line. Multiple colors for jacks and sockets.
It’s also possible to connect a jack to a jack.
Loads of possibilities.
Todo:
Wifi and Mqtt part
Debounce software or hardware
In post below i posted the score for Bella Ciao
https://www.henriaanstoot.nl/2022/12/09/generating-pdfs-from-abc-files-to-include-in-tunebooks/
Here is a quick ‘n dirty recording (sound a little distorted)
Edited with Kdenlive
I’ve imported the score as an image.
Drag a transform effect on the image.
Move the image to the bottom of the screen.
Add a keyframe.
Move to the end of the movie, add another keyframe.
Adjust the Y position to 0
Set opacity to a nice position and render
I love making cocktails for the ladies. Its cold outside, so here is my take on the Chocolate Amnesia Cocktail.
(Some make this with ice, this is a heated version)
Mix and heat in a (sauce) pan .. enjoy
Lets try to make a Electronic Concertina
UPDATE:
https://www.henriaanstoot.nl/2023/01/10/arduino-concertina-poc/
https://www.henriaanstoot.nl/2023/01/17/arduino-concertina-poc-2/
So we need some pushbuttons … at least 14 .. for the most simple tunes.
A sensor for push and pull.
A buzzer or better yet .. a jack for earphones.
Arduino with enough pins to connect a keyboard matrix.
When using a keyboard matrix only single keypresses are detected.
So we cant do chords!
I’ve installed a headless Raspbian on a Pi Zero with a 2×16 Chars lcd display. As part of the Escape Room over the internet
Using the raspberry imager:
I’ve set the username/password and ssh access in this tool.
For wifi access i’ve placed below file on the SDcard in /boot
(You can do this in the tool, but i want to make this dynamic when connected at a remote site.)
file: wpa_supplicant.conf
country=NL
update_config=1
ctrl_interface=/var/run/wpa_supplicant
network={
scan_ssid=1
ssid="MYSSID"
psk="MYSSIDPASS"
}
ssh into the RPi
sudo raspi-config Interface options and enable I2C sudo apt-get install python3-smbus wget https://gist.githubusercontent.com/DenisFromHR/cc863375a6e19dce359d/raw/36b82e787450d127f5019a40e0a55b08bd43435a/RPi_I2C_driver.py and wget https://gist.githubusercontent.com/DenisFromHR/cc863375a6e19dce359d/raw/36b82e787450d127f5019a40e0a55b08bd43435a/examples.py For python3 edit the example and put at the top # requires RPi_I2C_driver.py import RPi_I2C_driver from time import * unichr = chr Run with python3 examples.py
Below is a mockup session.
Next todo:
I’ve been working on some modular gadgets which can be combined to make a complete puzzle.
I like games like Keep-talking-and-nobody-dies. (Which is a computer game, but you have to play it with multiple persons and a physical “manual” Great fun!)
https://keeptalkinggame.com/
And i like real escape rooms.
There are some puzzle “rooms” you can buy in the game store, it is okay but many are for single use only.
I’ve been following some people on youtube, i saw some great ideas but not a remote over the internet using physical knobs and switches.
This is a RFID reader with an old Amico Esp8266 Arduino. It sends RFID information to the MQTT broker
Some other tools ‘n knobs .. and stuff
I want to use Adhoc Wifi and a Mqtt/Nodered setup which uses a mqtt over the internet to get people (and their knobs) connected
I already got a lot of test schematics

Schematic for the MQTT enabled RFID module

ESP8266 <-> RC522
D8 SDA
D5 SCK
D7 MOSI
D6 MISO
GND GND
D1 RST
3V3 3V3
Code
Below will write the RFID id to “rfid/id” and resets this when you remove the tag to “rfid/id = 0”
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <PubSubClient.h>
#include <MFRC522.h>
#define SS_PIN D8
#define RST_PIN D1
MFRC522 mfrc522(SS_PIN, RST_PIN);
unsigned long cardId = 0;
WiFiClient net;
PubSubClient client(net);
const char* mqtt_server = "MQTTBROKER";
const char* ssid = "MYSSID";
const char* password = "MYWIFIPASSWD";
void setup() {
SPI.begin();
mfrc522.PCD_Init();
WiFi.mode(WIFI_AP_STA);
WiFi.begin(ssid, password);
client.setServer(mqtt_server, 1883);
}
void reconnect() {
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
WiFi.begin(ssid, password);
}
while (!client.connected()) {
String clientId = "NodeMCUClient-";
clientId += String(random(0xffff), HEX);
if (!client.connect(clientId.c_str(), "rfidclient", "...")) {
delay(5000);
}
}
}
void loop() {
reconnect();
if (!mfrc522.PICC_IsNewCardPresent()) {
return;
}
if (!mfrc522.PICC_ReadCardSerial()) {
return;
}
cardId = getCardId();
char buffer[10];
sprintf(buffer, "%lu", cardId);
client.publish("rfid/id", buffer);
uint8_t control = 0x00;
do {
control = 0;
for (int i = 0; i < 3; i++) {
if (!mfrc522.PICC_IsNewCardPresent()) {
if (mfrc522.PICC_ReadCardSerial()) {
control |= 0x16;
}
if (mfrc522.PICC_ReadCardSerial()) {
control |= 0x16;
}
control += 0x1;
}
control += 0x4;
}
delay(0);
} while (control == 13 || control == 14);
reconnect();
client.publish("rfid/id", "0");
delay(500);
mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1();
}
unsigned long getCardId() {
byte readCard[4];
for (int i = 0; i < 4; i++) {
readCard[i] = mfrc522.uid.uidByte[i];
}
return (unsigned long)readCard[0] << 24
| (unsigned long)readCard[1] << 16
| (unsigned long)readCard[2] << 8
| (unsigned long)readCard[3];
}
Schematics used for the Solenoid lock
Software is a mqtt example from the internet which toggles a PIN on the arduino.


In post https://www.henriaanstoot.nl/2022/11/25/disk-troubles-or-missing-old-skool-hardware/ i mentioned the serial connectors i’ve bought to connect the Laser XT to my Workstation to transfer files.
The null modem i’ve made is like mentioned on https://en.wikipedia.org/wiki/Null_modem
I’ve used the loopback handshaking using 3 wires. ( Only using a DB25 and a DB9 on the other end )
So i configured the Linux side as follows.
I’ve tried two usb to serial converters.
Dec 14 17:34:40 zspot kernel: [ 1082.299607] usb 1-4: pl2303 converter now attached to ttyUSB0
sudo stty -F /dev/ttyUSB0 9600
Then i start dosbox.
To enable a com port i have to enter:
serial1=directserial realport:ttyUSB0
Starting Norton Commander and selecting COM1
After a few seconds i got this ..
What else is there to check?
At least i’ve still got the Flux Engine!