TeCoEd (Teaching Computing Education)
  • Home
    • Freelance
    • Book
    • Downloading
  • Python
    • Learn Python >
      • Python Modules
    • PyGame Zero
    • Python Programs >
      • Higher or Lower
      • Magic Calculator
      • Password Checker
      • Python Pit
    • What's News App
    • Pixels to Cells
    • Python Mosaics
    • Python OCR
    • L-1-AM
    • Web Scraping >
      • Scraping Trains
    • Weather App
    • Snakes and Windows
    • Python Web Server >
      • Flask
    • Python Picks
  • Raspberry Pi
    • All About the Pi
    • Getting Started
    • Remote Desktop and VNC
    • Static IP Address
    • Sonic Pi >
      • 3.14
    • Twitter Feed >
      • Tweepy
    • Android & Pi >
      • Advanced Apps
      • Odds
    • A.I on the the Pi
    • CRON
    • Pick Your Own
  • Pi Hardware
    • Pi HATS >
      • Sense Hat Hacks
      • AstroPi HAT
      • Unicorn-HAT >
        • Unicorn Alphabet Disco
        • Uni Codes / Programs
      • Skywriter
      • Piano HAT
    • STS Pi
    • Pi Camera >
      • Pi-Cam, Python & Email >
        • Time Lapse
      • Pi Noir
    • Pipsta >
      • Flask, Input & Printers
    • Raspberry Pi Power >
      • Energenie IR power
    • Pibrella
    • Distance Sensor
    • LCD Screen
    • Pi-Tooth
    • Robot Arm
    • PiGlow
    • PiFM
    • Accelerometer
    • PiFace >
      • Installing PiFace >
        • Python Commands
  • Pi-Hacks
    • Drone Hacks
    • Pi Glue Gun Hack
    • Blinkt!
    • Sonic Pixels
    • R2D2
    • Get to the chopper
    • Astro Bird
    • Twitter Translator
    • Hacking a Robot
    • Nature_Box >
      • Best Nature Photos
    • Wearable Tech >
      • Project New York
      • P.N.Y Part 2 Health
      • P.N.Y Part 3 Games
      • P.N.Y Part 4 Translation
    • Dino-Tweet
    • Other Links
  • Pi-Hacks 2
    • The Joker
    • Hologram Machine
    • Google Vision: Camera Tell
    • Yoda Tweets
    • Pi Phone
    • Darth Beats
    • Twitter Keyword Finder
    • Crimbo Lights Hack
    • Xmas Elf
    • Halloween 2016
    • Halloween Hack 2015
    • Socrative Zombie
    • Voice Translation
    • The Blue-Who Finder
    • GPIO, Twitter
    • Pi Chat Bot >
      • Dictionary Definitions
    • PiGlow & Email
    • Pibrella Alarm System
    • SMS with Python >
      • Spooking a Mobile
  • Pi-Hacks 3
    • David Bowie
    • Lamp Prank >
      • TEST
    • Yoda FM
    • Retro Player
    • LED Pixel Art
    • TARDIS
    • Battleships
    • LED Board
    • Night Vision
    • Enviro+ Weather
  • Minecraft
    • Minecraft API
    • Minecraft Sweeper
    • PiGlove: Minecraft Power Up
    • Minecraft Photo-booth
    • Rendering Pixels
    • Speed Cube
    • Lucky Dip
  • Computing
    • Why Computing?
    • Can You Compute
    • micro:bit
    • Coding Resources
    • Learn to Code >
      • Coding with iPads
      • Apps Creation Tools
      • sKratchInn
      • Sound Editing
    • Cheat Sheets
    • Theory
    • HOUR OF CODING
    • BEBRAS Computing Challange
    • Computer Facts
    • Free Software and Links
  • Contact Me

What is it?


Harnessing Google Translate API and combining it with some simple Python Code and mPlayer,  you can creating a speaking Raspberry Pi.  With a few tweaks this setup can be adapted to create a simple Chat-bot or even a system that retrieves and reads out the weather forecast for you.

Getting started


The first step in creating a speaking Raspberry Pi is to update your OS software and install the mPlayer, a free open source media player.  Ensure you are connected to the Internet.

In the LX Terminal type:
sudo apt-get update

When this completes type:
sudo apt-get install mplayer

That is it! Once installed restart the Pi and you are ready to make the Pi speak. Connect the speakers via the audio port and download the simple python code below.  This code uses the Google translate API to process the text into speech, once completed it returns the 'words'.  The Python code uses a a simple function called raspberryTalk to enable the typed words to be converted and spoken.  You can change the text or add your own using raspberryTalk function.  The program only runs once so you could add a loop function to enable continuous talking?
Basic Starter Code
File Size: 0 kb
File Type: py
Download File


Pump up the Volume!


If there is no sound playing then check the speaker connection.  The volume on the Pi may also be set too low.  

In the LX Terminal type:
alsamixer

This will enable you to adjust the volume by pressing the up and down arrow keys.
Picture

Building a Chat bot


Students and many adults are fascinated by Chatbots.  Using simple loops and if, elif, else statements the code can be modified to create simple chat-bot. Challenge students to create the most realistic Chatbot they can and use the Turing Test to compare them and pick an overall  winner.

Download Chatbot Code Here


A basic modification of the previous code to get you started with a Chat-bot.
Chat-bot Code
File Size: 1 kb
File Type: py
Download File


Weather Bot: 


This simple project combines a simple Parser that pulls down weather reports from Yahoo.  Then raspberryTalk announces the weather for the location that the weather has been set to.  To get started update the Pi and install the Parser.

In the LX Terminal type:
sudo apt-get install python-feedparser

Once installed download the program below to get started.  This returns a set of weather data for London.    
Weather-Bot Code
File Size: 2 kb
File Type: py
Download File

The original Raspberry Pi weather project is available here.  It shows you how to change the location of the weather report and how to customise what weather data is returned and reported.


The Twitter Bot: click here


Copyright 2020 TeCoEd @dan_aldred