Universal Translator

Universal Translator

/media/uploads/benglish6/_scaled_universaltranslator.jpg

The universal translator allows the user to select the language which he intends to input, type a statement, select a language for translation, and hear how his statement is pronounced in the selected language.

mbed Peripherals

  • PS2 Connector and PS2 Keyboard
    • Inputs a message and selects information
  • LCD Display
    • Displays the current message
  • Ethernet Connection
  • Serial PC Connection
    • Displays the IP address of the Ethernet along with any Ethernet error information
  • SD Card
    • Stores the .mp3 file returned from Google Text-To-Speech
  • VS1053
    • Converts the .mp3 file into an audio signal
  • Audio Out and Speaker
    • Plays the .mp3 file
  • Potentiometer
    • Adjusts speaker volume

User Instructions

1. Wait for the first LED to start blinking. Once this occurs, the mbed has connected through the Ethernet and is prepared for inputs.

2. Type in the message that you wish to translate. Below are a list of keys available.

Keys Available for Input Text All letters

  • All numbers
  • Space bar
  • Comma
  • Period
  • Forward slash
  • Back slash
  • Semicolon
  • Dash
  • Opening and closing brackets
  • Equals sign

Other Input Keys

  • Backspace
    • Deletes the previous character in the message
  • Delete
    • Clears the entire message
  • Up arrow
    • Scrolls up 1 line on the LCD display of the message
  • Down arrow
    • Scrolls down 1 line on the LCD display of the message
  • Right arrow
    • Scrolls 1 letter to the right on the LCD display of the message
  • Left arrow
    • Scrolls 1 letter to the left on the LCD display of the message
  • Enter
    • Submits the message for translation

Note!

When scrolling through the message and making changes, the program will write over old characters, as the insert button functions on a computer.

3. Once the message has been entered, press enter.

4. A screen will appear with a first line stating "SELECT SRC LANG." This screen requests that select the language of the input message, the source language. The second line of this screen will be a language.

5. Use the up and down arrow keys to change the source language.

6. When the correct source language is on the screen, press enter to select it.

7. A screen will appear with a first line stating "SELECT DEST LANG." This screen requests that the language for the message to be translated into, the destination language, be selected. The second line of the screen will be a language.

8. Use the up and down arrow keys to change the destination language.

9. When the correct destination language is on the screen, press enter.

10. The message will be translated and played through the speaker.

Demo Video

Download the Program

Import programLab3Translator

Universal Translator

Important!

Once the code is downloaded, you must open keyProcess.cpp, proceed to line 31, and insert your website. You must have a website for the program to write the message for Google Translator to translate. Line 31 currently reads:

static string httptransurl = "http://www.yoursite.com/path/to/mbed.php?src="; INSERT YOUR WEBSITE HERE!

The code WILL NOT function before this task is completed.

You can find information about setting up your Google API key here: https://www.google.com/accounts/ServiceLogin?service=devconsole&passive=1209600&continue=https://code.google.com/apis/console/?api%3Dtranslate&followup=https://code.google.com/apis/console/?api%3Dtranslate

Currently, there is a working URL that is available for use (as long as it is not abused): http://www.starboundcomputers.com/mbed.php?src= (this goes in the httptransurl variable).

Lines 23-39 of keyProcess.cpp

keyProcess.cpp

void checkKeys(PS2Keyboard &ps2kb,char* rowstr) {
    static int column = 0;
    static int row = 0;
    static int selected = true;
    static int source = false;
    static const char *selsrc="Select Src Lang\n";
    static const char *seldest="Select Dest Lang";
    static string httpurl = "http://translate.google.com/translate_tts?tl=";
    static string httptransurl = "http://www.yoursite.com/path/to/mbed.php?src=";//INSERT YOUR WEBSITE HERE!
    static string arg = "&q=";
    string voiceurl;
    string transurl;
    static int src=26;
    static int dest=37;
    string lang;
    string translatedText;
    static PS2Keyboard::keyboard_event_t evt_kb;

mbed.php

<?php
$key = " "; /* insert your key  */
$q = urlencode($_GET["q"]);
$src = $_GET["src"];
$dest = $_GET["dest"];
$url = "https://www.googleapis.com/language/translate/v2?key=".$key."&q=".$q."&source=".$src."&target=".$dest;
// sendRequest
// note how referer is set manually
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://www.yoursite.com/path/to/mbed.php?src=");/* Enter the URL of your site here */
$body = curl_exec($ch);
curl_close($ch);

// now, process the JSON string
$json = json_decode($body,true);
$translatedText = $json["data"]["translations"][0]["translatedText"];
echo $translatedText;
?>

Serial Communication with PC

For Ethernet debugging purposes, there is a serial display on the PC.

Information on configuring serial on Windows is found here: http://mbed.org/handbook/Windows-serial-configuration

LCD Screen

/media/uploads/benglish6/_scaled_lcd.jpg

Pin Out

Mbed PinsTextLCD Pins
GNDGND
5VVCC
GND (via 1k resistor)V0
P15RS
GNDRW
P16E
N/CD0
N/CD1
N/CD2
N/CD3
P17D4
P18D5
P19D6
P20D7

More information about the LCD Display may be found here: http://mbed.org/cookbook/Text-LCD

PS2 Keyboard

/media/uploads/benglish6/_scaled_ps2.jpg

Pin Out

Mbed PinsPS2 Connector PinsValue of Resistor the Connection is made through
5VDATA4.7K
P29DATA270
P30DATA270
GNDGNDWire
5VVCCWire
P29CLK270
P30CLK270
5VCLK4.7K

PS2KeyMap

static const unsigned char ps2KeyMap[] = {
//  0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F
  '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', '`','\0', // 00-0F
  '\0','\0','\0','\0','\0', 'Q', '1','\0','\0','\0', 'Z', 'S', 'A', 'W', '2','\0', // 10-1F
  '\0', 'C', 'X', 'D', 'E', '4', '3','\0','\0',' ', 'V', 'F', 'T', 'R', '5','\0', // 20-2F
  '\0', 'N', 'B', 'H', 'G', 'Y', '6','\0','\0', '\0', 'M', 'J', 'U', '7', '8','\0', // 30-3F
  '\0', ',', 'K', 'I', 'O', '0', '9','\0','\0', '.', '/', 'L', ';', 'P', '-','\0', // 40-4F
  '\0','\0', '\'','\0', '[', '=','\0','\0','\0','\0','\0', ']','\0','\\','\0','\0', // 50-5F
  '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // 60-6F
  '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // 70-7F
  '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // 80-8F
  '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // 90-9F
  '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // A0-AF
  '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // B0-BF
  '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // C0-CF
  '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // D0-DF
  '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // E0-EF
  '\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0', // F0-FF
};

Information about the PS2 connector can be found here: http://mbed.org/cookbook/PS2

Information about the code mouse and keyboard PS2 devices can be found here: http://mbed.org/users/shintamainjp/libraries/PS2/lg73er

VS1053

/media/uploads/benglish6/_scaled_vs1053.jpg

Pin Out

Mbed PinsVS1053 Pins
VOUTVCC
N/CMICN
P21RESET
P22DREQ
N/CGPIO0
N/CGPIO1
N/CGPIO2
N/CGPIO3
P23BSYNC
N/CTX
N/CRX
GNDGND
P11SI
P12SO
P13SCLK
P10CS
GNDGBUF
VCCLEFT

VS1053 Datasheet: http://www.vlsi.fi/fileadmin/datasheets/vlsi/vs1053.pdf

A VS1002 MP3 Decoder may be used in place of the VS1053. Software origonally designed for the VS1002 was used in the project.

Information on the VS1002 MP3 Decoder and the corresponding software may be found here: http://mbed.org/cookbook/VS1002-MP3-Decoder

Audio Out

/media/uploads/benglish6/_scaled_audioout.jpg

Pin Out

VS1052 PinsBreakout Board Pins
GNDGND
RIGHTRSH
LEFTTSH

Information on the breakout board can be found here: http://www.sparkfun.com/products/8827

Volume Controlling Potentiometer

/media/uploads/benglish6/_scaled_pot.jpg

Pin Out

Mbed PinsPotentiometer Pins
VOUTVCC
GNDGND
P15Volume Control

SD Card

/media/uploads/benglish6/_scaled_sd.jpg

Pin Out

Mbed PinsSD Card Breakout Board Pins
P8CS
P5DI
VOUTVCC
P7SCK
GNDGND
P6DO
N/CCD

Information on the SparkFun MicroSD Breakout Board can be found here: http://www.sparkfun.com/products/544

Information on SD Card interface with the mbed can be found here: http://mbed.org/cookbook/SD-Card-File-System

Ethernet

/media/uploads/benglish6/_scaled_ethernet.jpg

Pin Out

Mbed PinsEthernet Pins
TD+P1
TD-P2
RD+P7
RD-P8

Information on Ethernet may be found here: http://mbed.org/cookbook/Ethernet

Information on the RJ45 MagJack Ethernet Breakout Board may be found here: http://mbed.org/cookbook/Ethernet-RJ45


Please log in to post comments.