Sunday, April 26th, 2020...20:39

COVID-19 pyttsx3 Chilblains

Jump to Comments

Unless one has been living on Antarctica for the last few months, life has probably been affected by COVID-19 in some way, shape or form. It has been almost 7 weeks since the company I work for issued a recommended work from home (WFH) notice and I have not been into the office since. The communications went from voluntary WFH to recommended to strongly recommended to mandatory over a 16 day period.

At the very beginning, it seemed a little odd that I had stopped going into work while my daughter was still going to kindergarten. I tried to rationalize and explain to her that riding public transit and sharing an office space with thousands of other people who were possibly travelling all over the world, when it wasn’t really necessary, was more likely to spread the disease and endanger society as a whole as compare to her spending time with a few hundred kids and some adults at school. In other words, it wasn’t that it was more important for me not to get sick than her, but that if I were sick and didn’t know it, I might be exposing many more people, more quickly, than she would if she were sick. Based on this photo I happened to take 2 weeks earlier on my morning commute, there might be some truth to that. She does go to a public school, but the classrooms are not quite this overcrowded.

February 25, 2020 morning BART commute.

Nevertheless it felt bad and not 100% correct to try and explain this to her; and while we are fortunate enough to be in a position where we could have just taken her out of school without penalty, she wanted to go to school. Also part of the reason we live where we do is the belief that people in charge of the school district, health services, city and county government are knowledgeable and rational people who will “do the right thing”. So it was somewhat of a relief when 3 days after I started WFH the school district announced that Friday would be the last day of school for the next 3 weeks (one of which was spring break).

The first week was pretty rough, she already had a distaste for video chats even before the pandemic; so getting her to participate and deal with the technical difficulties of everyone trying to get setup with distance learning lead to quite a few more meltdowns than normal. We tried to emulate some of her school day to provide a semblance of normalcy e.g. she wrote out her standard Tuesday schedule.

I was probably only reaching about 60-80% of usual productivity on work matters; and that included staying up late to catch up on things while everyone else was asleep. There were plenty of other stressors e.g. attempting to get groceries delivered and then having to clean/sanitize them etc. None of this is unique nor is it comparable to the hardships that many other people are going through but life had certainly changed abruptly in significant (to us) ways.

Week two was better and then things changed for week 3. Since it was technically spring break we didn’t do any of the homeschooling and she could wear footie pajamas all day (we enforced having to get dressed in the morning for “school”). I was still playing catch-up at night with work but at this point I felt like it usually brought me close to 100% normal productivity. What I didn’t realize is that I was slowly injuring myself in a strange way. It wasn’t carpal tunnel or anything like that, though my WFH setup is less than ideal.

The monitor is 13 years old, my in-laws gave it to me several years ago after they got a new computer because they weren’t sure how to properly dispose of it. I had procrastinated taking it to the computer recycling center, so lucky me. The laptop is company owned. As someone who at varying points over the last 25 years has had as many as 5 different physical computers running in their apartment/loft/house at any given time and also ran their own firewall, nat, web, dns, mail, ftp, raid-5 etc. servers, it’s somewhat surprising that the only computer I own (not counting phones or an old chromebook I got from work) turned 8 years old a month ago. To be fair, I purposely configured it on the high end as a desktop replacement when I purchased it, planning for it to last at least 4 years e.g. Intel Quad Core i7 2.2GHz CPU w/6MB L3 cache, 4GB 1333Mhz DDR3 RAM, 16.4in 1080p screen, HDMI, Blu-Ray/DVD+RW, NVidia GeForce 520M w/512MB dedicated video RAM etc. And towards the end of 2018 I did upgrade to a SSD hard drive, but even with that and the end of Moore’s Law, it feels a little ridiculous to be typing this on a laptop from 2012.

I remember during an architecture course in college that focused on 3D animation (as opposed to CAD), someone from Industrial Light and Magic came to speak to us and mentioned he didn’t even own a computer (this would have been 1999). At the time I thought that was completely absurd given my room looked like this.

But now, I’m basically that guy who spoke to us (though I’m also likely 5-10 years older than he was at the time). I don’t have a desk at home, I spend 8-10hrs/day 5 days a week fairly intensely focused on making computers do things and while I’m still interested in continuing to educate myself about technology, I rarely practice it outside of work.

Some of that is due to a belief that we should not be exposing our daughter to too much technology too quickly and therefore want to engage her while playing with a basketball or dolls or Lego or a guitar etc. Though as part of the homeschooling, we asked our daughter to come up with electives, and I figured since she had started to have an interest in reading and doing arithmetic on her own, it might be worth trying to teach her how to code. She was open to the suggestion since she likes to type gibberish in a text editor and has seen me working from time to time asking “what are you coding now?” or “are you fixing a bug?” I had read Seymour Papert’s Mindstorms shortly after our daughter was born and read a little about a programming language geared towards kids called Scratch. I knew parents who’s kids had fun with Scratch and others who were uninterested. And there were those who’s kids liked Python and others who had rejected every language and attempt at interesting them in programming and computation. I had also reflected from time to time on my experience teaching 8-16 year olds HTML/CSSJavaScript and Macromedia Flash at a summer camp (also more than 20 years ago) as well as my own upbringing in BASIC.

In the mid-1980’s we had an Atari 800XL at home and then my middle school had TRS-80 Model III’s (10 years old at the time). I still remember this feeling like magic:

10 PRINT “HELLO JAMES!”
20 GOTO 10

Graphics seemed out of reach at the time, I could spend an hour typing in code from a magazine that I didn’t comprehend just to see an orange and green jack-o-lantern appear on screen. Another one I remember was typing in a bunch of code that rendered a green fractal fern. I learned about variables and conditionals, but not functions (that I remember) and certainly not the association coding/programming had with mathematics. It wasn’t until several years later, I taught myself a little VisualBasic (first project was writing a Celsius/Fahrenheit/Kelvin converter with a GUI) did I really start to see the power of the computer as a tool.

By the time I was teaching at a summer camp, I had more formal education under my belt and it was much easier to make visuals via code. With most kids only going to the camp for a week during the day time, and mixing in all the other camp activities, I probably had 15-20hrs of time with any given group to make an impression. So I decided to spend most of the time teaching them how to programatically draw and animate lines and shapes. There was much document.body vs document.layers in JavaScript juxtaposed with looping keyframes in Flash.

However, that still seemed like a bit too much for a 6 year old. One of the things we’ve been thankful for is that she got to have a birthday party before everything shut down. Some classmates have had to celebrate their birthdays over a video chat or having their neighbors setup a bear hunt. Her age is a big deal too e.g. when playing Monopoly, “oh I rolled a 6 because I’m 6 years old.” So I thought, maybe an age calculator would capture her attention in a similar way to how the temperature converter caught mine. But I also wanted to tap into whatever it was that made me so excited to see my “Hello James” printed repeatedly across the screen. However, given she has grown up swiping and tapping on touchscreens while talking to our Alexa and Google Mini, printing characters to a screen likely wouldn’t create the same sense of astonishment. But what if I could make the computer “speak” to her or better yet, have her instruct the computer what to “speak”?

A program that asked, “What year were you born?” and then “What month were you born?” and then if necessary, “What day were you born?” would be able to correctly state how old someone was (ignoring the detail of time of day since every birthday when I tell her she’s not N+1 years old yet due to her birth time being after her bedtime it just makes her roll her eyes). It would provide an opportunity to introduce concepts like input, output, variables, numbers, strings, conditionals, functions, errors and provide an opportunity for the computer to “speak”.

Without much trouble I could probably write this program in C, C#, C++, Java, JavaScript, Perl or Python. I ended up choosing Python because it seemed like it would be the simplest to teach. I also found the pyttsx3 library which seemed like a dirt simple way to get the computer to “speak”. My plan was to work through a bit of the program with her each day that she wanted to write code as part of her elective activities and then magically flip the “speaking” switch.

The basic premise was to have a series of print and input functions e.g

print("What is your name?")
name = input()
print(f"Hello {name}! What year were you born?")

interspersed with the various calculations. That would exercise her reading and typing and then the magic would be converting the print functions to a custom print_and_say function which would “speak” everything while also printing it to the screen as before. This worked out pretty well, though I am not sure she really grasped any of the concepts I had initially hoped to convey. Mainly she enjoyed having the computer say her name along with poop and pee at various speeds. The full program appears below.

import pyttsx3
import calendar
from datetime import date, datetime

def month_to_number(month):
  for i, m in enumerate(calendar.month_name):
    if m.startswith(month.lower()):
      return i
  raise ValueError(f"Could not convert {month} to a number.")

def print_and_say(message, speech_engine):
  print(message)
  speech_engine.say(message)
  speech_engine.runAndWait()

def main():
  speech_engine = pyttsx3.init()
  speech_engine.setProperty("rate", 165)
  speech_engine.setProperty("voice",
                            speech_engine.getProperty("voices")[1].id)

  print_and_say("helo, wut is your name?", speech_engine)
  name = input()
  print_and_say(f"nise to meet you, {name}! wut yeer wr you born?",
                speech_engine)
  year = int(input())
  now = datetime.now().date()
  years_old = int((now - date(year, 12, 31)).days / 365.2425)
  print_and_say(f"I think you are at least {years_old}. "
                f"what munth wer you born?", speech_engine)
  munth = input()
  month_number = month_to_number(munth)
  print_and_say(f"{munth} is month number {month_number}!", speech_engine)
  day = 1
  if month_number == now.month:
    #srhfhfhfhrgrgtgrhrhhvrvghfghtgrgsurfhgrhgryfhrgyhfgyygdyurgrreyutfyhfb657474656550r968767686urthfhfhfbfgfgfgfgtggtgffhftrgftrytyrrtr65tftbybrrgtvhgfhfgdbjhfhdgfygdrf
    print_and_say(f"Oh, I guess I also need to know what day you were born,"
                  f" can you please tell me?", speech_engine)
    day = int(input())
#hjudhhfhhghghgfghghghgyfhfhjgjgugfufufufugghhyghgyyughbvbhgygvtyg
  elif month_number == 12:
    pass
  else:
    month_number += 1
    
  years_old = int((now - date(year, month_number, day)).days / 365.2425)
  print_and_say(f"Ahh, now I am sure you are {years_old} years old!",
                speech_engine)
  speech_engine.stop()

if __name__ == "__main__":
  main()
#hgbtttytuybvrhutbgrghftvytyttvtytyvttytvtythttvhvbvfhfdjhnvmbkhlotpyorhejfhvbvogjghthghghgghtggghjgjghghgghhjhvtbyvhrbtvhryrghftggytr

The text-to-speech engine was actually pretty good at pronouncing her estimated words e.g. nise vs nice. I hadn’t thought to teach her what a comment was but when she was getting frustrated with having to write certain words, I showed her how she could use the # character to tell the computer to ignore it and I think that turned out to be her favorite part of programming. Upon further reflection, probably not a bad thing as most code would actually benefit from some well placed comments.

Maybe you’re wondering where the chilblains comes into play. During the first 3 weeks of WFH I was often barefoot (fully dressed otherwise) and as mentioned working late. My feet started to hurt as if I had blisters. I tried using bandaids to reduce friction but it didn’t help and it got to the point where I could not go jogging and even walking the dog was a struggle. After much reading I self-diagnosed chilblains and started wearing socks and shoes inside the house. I also applied petroleum jelly to the sensitive parts of the skin and within a couple of days there was a significant improvement, after a week I was able to go jogging again with only mild discomfort and a few days after that all the pain was gone.

Finally, about a week after that my wife came across an article about covid toes; so who knows, maybe I was infected and otherwise asymptomatic. Or maybe I just had one of the silliest self-inflicted WFH injuries.

Comments are closed.