Skip to content

code2k13/text_gen_circuitpython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Text generation on micro-controllers with CircuitPython and Markov Chains

This code generates random text using character level Markov Chains. It has been written for CircuitPython and should run on wide variety of boards supporting it. By default the code creates a character level Markov Chain which can be used for generating random dinosaur names. You can train a character level Markov Chain model on any type of data using this code.

Why CircuitPython and Markov Chains ?

  • C++ is hard. Setting up dev environment for TFlite and board's SDK can be challenging for newbies.
  • CircuitPython has many useful libraries available out of box.
  • Loading TFLite models is currently not supported by CircuitPython. Checkout this open source project for progress in this direction .
  • RNNs are complicated and use more memory.
  • Markov Chains are simpler and lightweight !

Steps to run

Alternatively you can skip Steps 1 and 2, and run the 'src/text-generation-on-microcontrollers.ipynb' Jupyter notebook to generate dino_chain.json. This notebook is also available on Kaggle: https://www.kaggle.com/code/finalepoch/text-generation-on-microcontrollers

Output on serial monitor

This program (src/generate_text.py) outputs data to serial port. It uses CircuitPython's 'printf' statement to write data.

Output on serial monitor

Output on OLED display

This program (src/generate_text_oled.py) requires an I2C OLED display (128x64) to be connected to the board. The example assumes Pi Pico board, so the OLED is connect to GP5(SLK) and GP4(SDA)

Pi Pico running circuit python and display random names

About

A program written for circuitpython that generates random text (dinosaur names) using Markov Chains

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published