TalknType
Jump to navigation
Jump to search
This will eventually be an Activity based on the 1970s toy, [Speak&Spell].
Initial Activity Idea
- User opens the activity, and is presented with a skill level (1 to 4).
- The activity speaks, using the eSpeak Speech Synthesis software
- The activity asks the user to spell a word from the dictionary (one of four, based on the skill level).
- As the user types each letter, the activity reads the letters out loud.
- When the user presses Enter, the activity reads the entered letters as a word.
- The activity compares the entered letters with the real word, and informs the user whether the word was spelt correctly or not.
- Another random word is offered for the user, etc, etc.
Installing
The code at the bottom of this page isn't ready for general use yet - it doesn't use the Sugar user interface, and only uses the terminal within sugar.
- You will need to save the code at the bottom of the page as talkntype.py in a directory.
- You will need a copy of the sugar-speechd speech server.
- You will need three audio files for the correct.wav incorrect.wav and begin.wav.
- Make sure your loudspeaker volume is turned up, using the keyboard keys.
- Open a copy of the Terminal activity. Change to root user:
su -
- Then run the sugar-speechd speech server:
./sugar-speechd
- The terminal will appear frozen, but this is ok. It means the server is running. Go back to the desktop (Home), and open another Terminal activity.
- As user OLPC, go to the directory that talkntype.py is stored in, and make it executable by typing:
chmod a+x talkntype.py
- Then run it by typing:
python talkntype.py
- You will need to type quite slowly.
- There is no Backspace key
- To exit the program, press 1 instead of entering a word.
To do
- Sugarise the idea into something usable by normal people! I have no real programming knowledge, so all help would be greatly appreciated! Please contact me via my userpage.
- Make an icon
- Include collaborative elements - spelling against a friend?
- Upload the code somewhere (but I don't know how git and dev.laptop really operate...)
- Upload the 3 audio files called in the code below.
Code
Below is the code for the talkntype.py program.
#!/bin/env python import sys import os import dbus import random import time wordlist = [ "above","angel","answer","calf","does","earth","echo","extra","for","four","guess","half","health","iron","learn","ocean","once","one","oven","pint","pull","range","says","ski","sure","swap","talk","to","touch","two","view","warm","was","wash","word" ] bus = dbus.SessionBus() APLAY = "/usr/bin/aplay" size = len(wordlist) index = random.randint(0, size-1) elem = wordlist[index] espeak_object = bus.get_object('org.laptop.Speech','/org/laptop/Speech') answer = "" clearit = "" # Because I couldn't null a string # My class for key detection class _Getch: """Gets a single character from standard input. Does not echo to the screen.""" def __init__(self): try: self.impl = _GetchWindows() except ImportError: self.impl = _GetchUnix() def __call__(self): return self.impl() class _GetchUnix: def __init__(self): import tty, sys def __call__(self): import sys, tty, termios fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) try: tty.setraw(sys.stdin.fileno()) ch = sys.stdin.read(1) finally: termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) return ch class _GetchWindows: def __init__(self): import msvcrt def __call__(self): import msvcrt return msvcrt.getch() getch = _Getch() # MAIN LOOP os.popen("aplay --quiet begin.wav") # play sound for x in range(35): index = random.randint(0, size-1) elem = wordlist[index] answer = clearit # null the string again print "Spell..." espeak_object.SayText("Spell " + elem) # get an answer print 'Type your answer, or press the spacebar to repeat the word, or 1 to quit' for longestinput in range(15): inkey = _Getch() import sys for i in xrange(sys.maxint): k=inkey() if k<>:break print k, espeak_object.SayText(k) answer = answer + k if k == " ": # if the user wants the word repeated espeak_object.SayText(elem) answer = clearit + k # because I don't know how to null a string print if k == "1": espeak_object.SayText("goodbye") sys.exit() # quit the program if k == "\r":break # say the answer answer = answer.strip() # remove any whitespace from the user's answer print # because I don't know how to do linebreaks print "You typed", answer espeak_object.SayText("You typed " + answer) # check for correct if answer == elem: os.popen("aplay --quiet correct.wav") # play sound print "Correct!" espeak_object.SayText("Correct") answer = clearit # null the string again # check for incorrect else: os.popen("aplay --quiet incorrect.wav") # play sound print "Incorrect answer." espeak_object.SayText("Incorrect answer...") print "The correct spelling of " + elem + " is " espeak_object.SayText("The correct spelling of " + elem + "... is ") def shout(string): for character in string: print character + " " espeak_object.SayText(character) shout(elem) time.sleep(0.5) print elem espeak_object.SayText(elem) # say the word again in full with some pauses at each end time.sleep(0.5) print answer = clearit # null the string again
Dictionaries
The code above only uses the simplest (level 1) dictionary, and doesn't have any of the vocabulary refinements of the original toy (ie doesn't say "spell FOR, as in for me", or "spell FOUR, as in number four".
The original dictionaries are presented below, as comma separated variable sets:
Dictionary Level 1:
"above","angel","answer","calf","does","earth","echo","extra","for","four","guess","half","health","iron","learn","ocean","once","one","oven","pint","pull","range","says","ski","sure","swap","talk","to","touch","two","view","warm","was","wash","word"
Dictionary Level 2:
"another","beauty","beige","blood","bullet","carry","chalk","child","danger","early","eight","eight","flood","floor","front","guide","haste","heaven","linger","mirror","other","priest","ready","rural","school","squad","squat","sugar","today","union","watch","water","yield"
Dictionary Level 3:
"already","believe","built","bushel","comfort","coming","couple","cousin","enough","finger","guard","healthy","heavy","instead","laugh","measure","mother","niece","outdoor","period","plague","police","promise","quiet","ranger","relief","remove","search","shield","should","shovel","someone","source","statue","terror","trouble","welcome","wolves","woman","wonder","worth"
Dictionary Level 4:
"abscess","ancient","anything","brother","bureau","butcher","caravan","circuit","corsage","couldn't","courage","discover","dungeon","earnest","feather","freight","greater","jealous","journey","language","laughter","leisure","lettuce","machine","minute","pierce","pleasure","plunger","poultry","quotient","reindeer","rhythm","schedule","scissors","serious","shoulder","stomach","stranger","surgeon","tomorrow","treasure","workman","yacht"
Interface Words:
"a","as in","b","c","correct","d","e","eight","f","five","four","g","h","here is your score","i","i win","is","j","k","l","m","n","next spell","nine","now spell","now try","o","one","p","perfect score","q","r","s","say it","seven","six","spell","t","ten","that is correct","that is incorrect","that is right","three","try","two","u","v","w","wrong","wrong try again","x","y","you are correct","you are right","you win","z","zero"
Other links
- Screen_Reader Another OLPC activity using the eSpeak modules.
- Speech_synthesis Speech Synthesis on the OLPC.
- [[1]] Flash version of the Speak & Spell
- [[2]] Another Speak & Spell emulator
- [Speak&Spell Wikipedia article]