The thing is…
![]() |
| Loaf Story A Love Letter to Bread |
It us what it is. Probably.
![]() |
| Loaf Story A Love Letter to Bread |
My earlier post, about a function that could send things to the Google AIY Raspberry Pi Assistant, and supposedly prevent more than one message being spoken at a time, was errmmm, wrong. That’s a technical term, that we programmers use.
I wrote a test program for my Pi cluster, whereby each of the sixteen cores would announce its hostname and rank. It’s not all that often you get the opportunity to use the word cacophony, but…
Basically, several processes could all think the Assistant was not busy, and they all sent messages in the time it took for the first message to start being spoken.
I spent a while looking at how to program mutual exclusivity for a resource, and was impressed by how complex such an apparently simple thing can get.
I decided that what was needed was a simple program, running on the Assistant, that would watch a directory, notice when a file to be spoken arrived, and speak the text in that file. Python makes it easy to deal with more than one file in the directory. Here’s what I wrote…
#
# Program to run on PiAssistant, to watch for newly arrived text files in
# /home/pi/Messages that it should speak, and delete them once it has.
import os
import time
path = “/home/pi/Messages/”
while True:
with os.scandir(path) as entries:
for entry in entries:
f = open(entry, “r”)
content = f.read()
f.close()
command = “python ~/AIY-projects-python/src/aiy/voice/tts.py “” +
content + “” –lang en-GB –volume 10 –pitch 60 –speed 90″
os.system(command)
time.sleep(0.5)
os.remove(path+entry.name)
time.sleep(0.5)
When it spots one of more files in the Messages directory, it reads the text, and sends it out to be spoken. It can supposedly only do one file at a time, but… Still the cacophony!
#RaspberryPi #GoogleAIY #Python
I wanted scrolling text on the UnicornHatHD which has a 16×16 LED array, and could only find a program that would do it on the old UnicornHat with its 8×8 array.
https://github.com/topshed/UnicornHatScroll
If you change a couple of lines in UHScroll.py, it works on the UnicornHatHD.
Change the definition of flip to:-
flip = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
and change the start of show_letter() to:-
def show_letter(letter,colour,brightness):
UH.rotation(0)
for i in range(16):
for j in range(8):
That’s all you need to scroll text on the top 8 rows of LEDs. It should be fairly easy to use the lower 8 rows as well…
Useful?
#RaspberryPi #Pimoroni #UnicornHatHD