element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
PiCasso Design Challenge
  • Challenges & Projects
  • Design Challenges
  • PiCasso Design Challenge
  • More
  • Cancel
PiCasso Design Challenge
Blog Art-a-Tronic Episode 13
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: balearicdynamics
  • Date Created: 4 May 2019 7:17 PM Date Created
  • Views 952 views
  • Likes 10 likes
  • Comments 2 comments
  • borge communication terminal
  • picasso challenge
  • microphone
  • google api
  • google service
  • artificial intelligence
  • text to speech
  • elegoo
  • 3D Printing
  • speech to text
  • seven of nine
  • raspberry pi 3b+
  • ai
  • voice recognition
  • borg
  • google cloud
  • laser cutting
  • art-a-tronic
Related
Recommended

Art-a-Tronic Episode 13

balearicdynamics
balearicdynamics
4 May 2019

  • Introduction
  • Hacking the Borg Communication Terminal
    • Construction of the Terminal
    • The PI Inside
  • Setup of the Raspberry PI
    • Sound Input
    • The Speech-to-text Google Service
    • Text-to-Speech With Google Translate
  • Previous Episodes
  • Next Episodes

Introduction

The entire meaning of this thirteen episode is contained in the Klingon sentence Heghlu'meH QaQ DaHjaj. (Today is good in order to die), and you'll see soon why (look at the video below).

image

What happens to Seven Of Nine when is not online? She is regenerating in her alcove where the Borg Access Terminal connects the drone with the rest of the Borg Collective. Just during one of these periods of regeneration, I stole her terminal and hacked it, to be able to speak with Seven Of Nine and – eventually – someone else of the Collective. Take a look to the video, and see how I was able to save the Earth from the Borg assimilation.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Hacking the Borg Communication Terminal

Or making a new one.

Definition, from the official Borg Collective Website:

 

An access terminal was a small port which was located within a Borg drones alcove, it was an integral part of early 24th century Borg technology which allowed a drone to connect to it and perform a number of different functions such as; linking the drone directly to the Hive Mind, absorption and transfer of power to and from the drone, access to vessel to the vessels database. The technology of the access node was altered to function without the drone being required to directly connect to it, instead, when the drone is inside the alcove the uplink is established remotely.

 

After hacking the original terminal it went destroyed so I decided to make a new one from scratch based on the original design; at the end of the job it worked like the original and I was able to communicate with Seven Of Nine and the Borg Collective.

 

Construction of the Terminal

Excluding the weird green light characterizing the Borg technology the members of the Collective are connected through their implants and their alcoves so no display or monitor is needed to them. As a matter of fact, a Borg Communication Terminal is a headless computer.

image

The hacker at work. The sunglasses have special colored lenses to protect the eyes from the green light.

 

The first step was building the container. Thanks to 3D printer and laser cutter it was possible to recreate an object resembling the Borg terminal

imageimage

Above: the four sides of the terminal box (laser cut) glued together. The rectangular hole is the side where I will connect cables and probes to the internal electronics.

Below: The front side glued to the frame. This side will host the Borg plate, resembling a face of the Borg Cube starship. I have 3D printed it with the Elegoo Neptune 3D printer set to a Z-axis resolution of 0.06 mm per layer for the better quality of the details of the surface.

imageimage

After assembling the essential parts of the case, the next step has been to create a box that can confuse Borgs. As shown in the images below, I have painted the assembled terminal case with metal black paint embedding nanodrones, to create a camouflage effect for the Borg sensors in case they discover where I am.

image

The back side will keep firmly the Raspberry PIRaspberry PI headless Brain Module so it can be inserted in the case and kept suspended in the middle. This is to avoid reaching too high temperatures due to the effort of the processor. The back side does not close completely the box so the green radiations – another camouflage effect – are emitted from the entire device.

imageimage

The PI Inside

The procedure to install is almost complex, at least the first time. While the board is kept in place by the back side, the connection should be inserted until the front side is open.

 

{gallery} Raspberry PI Inside

image

The Raspberry PI case suspended to the internal side of the back cover of the box

image

How the backside cover appears with the PI board inside

image

The PI is exactly centered to the middle of the box

image

The PI can be inserted to the back without the connections

image

After closing the back side, the connections and power are inserted from the side keeping the front of the box open

image

Power and audio out can't be inserted from the box side

image

After assembling the terminal all the cables are accessible from the open side.

image

The last step closing the front side with the 3D printed plate

image

The Borg Communication terminal complete. First power-on

 

Setup of the Raspberry PI

The second part of creating the Borg Access Terminal is related to the software setup. To solve all the issues I met the resulting software architecture is an almost ordered mix of bash shell commands and Python commands. To make the things as much linear and clean possible I have created very simple commands and a Python class to control the language interpretation algorithms (and some other tasks).

Sound Input

A well-known issue of the board is that the Raspberry PI does not include an audio input. It seems that the most elegant way to solve this problem – in this case, it is an essential device – is adopting the Raspberry PI USB microphone by Adafruit, as far as I see, mentioned almost everywhere. I bought it on Amazon and just connected to one of the USB ports. Then tried with the command arecord (from the ALSA audio package). As I am used, nothing went as expected and I got no recording at all.

In effect, there are some things to consider before. First of all, the USB mic, it is truly a plug-and-play device as it is immediately recognized but then you should know how the system see it else you never will use it.

 

The microphone is recognized as a USB device inside the USB thread. A good explanation on how to see the device installed on a specific Raspberry PI configuration and how to set up the arecord command for recording from the USB microphone can be found on the Soundfounder Wiki

 

arecord --channels=1 -q -D plughw:1,0 -d 3 -t wav -f S16_LE -r 16000 "speechtest.wav" &>/dev/null

 

The complete command is shown below

 

#!/bin/bash
# sample a bunch of seconds from the USB mic
# to test the silence

arecord --channels=1 -q -D plughw:1,0 -d 3 -t wav -f S16_LE -r 16000 "speechtest.wav" &>/dev/null
sox "speechtest.wav" -n stat

 

Note that after recording 3 seconds on the speechtest.wav file, I use the command sox to produce statistics from the recorded sample, including the maximum sound level. If the value does not match the present the Python application won't start the voice chat with the user. This is to prevent that the system will try to communicate also when there is only loud in the environment.

The other command is used to acquire 5 seconds of voice during the AI based chat with the Borg. In fact, the approach followed by the Python engine (that uses these commands) is a sort of half duplex; if the terminal is acquiring the sentence from the user, it is not processing nor emitting sounds and vice-versa.

 

#!/bin/bash
# sample a bunch of seconds from the USB mic
# then send them to speech to text google api

# Create the voice speech file
arecord --channels=1 -q -D plughw:1,0 -d 5 -t wav -f S16_LE -r 16000 "speech.wav"
# Play interlude sound while converting
./robot_interlude.sh &>/dev/null
# And convert it to json response'
gcloud ml speech recognize speech.wav --language-code='en-US'

 

The speech recognition uses the Google service and will be explained in the next paragraph.

 

The Speech-to-text Google Service

Using the Google service to convert voice to text is not a very difficult task. The difficult part – at least for the first time – is creating a project and registering your own account on the Google console, activate the specific API service and install the related components on the Raspberry PI. The good news is that all the development kits, SDK and Linux commands do not need any recompilation; all are available with the sudo apt-get install command from Raspbian.

The bad news – at least, it was for me – is that the Internet is full of examples and tutorials but none of those I have tried are fully updated to the last Google console specifications. Then I have found the right solution reading the Google documentation and extracting just four articles that I found essential to address the API installation and examples from the command line. Below the articles links:

 

  • https://cloud.google.com/sdk/docs/#deb (refers to Ubuntu but wors also for the Raspbian Linux and probably for most of the Debian Linux distributions)
  • https://cloud.google.com/speech-to-text/docs/quickstart-protocol
  • https://cloud.google.com/speech-to-text/docs/sync-recognize#speech-sync-recognize-gcloud
  • https://cloud.google.com/sdk/gcloud/reference/ml/speech/recognize

Before doing any procedure on the Google console you should be registered as a developer and have created the API authorization keys. Google updates almost frequently its policies so it is the best practice to read the documentation just when you decide to start

The most difficult part is activating the APIs and registering as a user, as well as creating the project on the console. The speech-to-text recognition itself, as you can see in the comand reported above, is just one line of code:

 

gcloud ml speech recognize speech.wav --language-code='en-US'

 

Text-to-Speech With Google Translate

The first tries I have done were installing some local text to speech engines but none of these produced a decent output so I decided to move to the Google services again. Also, in this case, I have found a lot of very complex tutorials but none was really convincing. My intuition was that there will be the easiest way to use the free to all Google translate service, including the conversion of text to voice. I definitely found the solution with a single-command terminal program that n can be installed from the Raspbian repositories: trans

After all the failures or poor or complex results, this console command, in my opinion, is the best solution I have found until now. In addition to Google translate (the default), you can choose also other engines like Bing, Yandex, and Apertium. I have used as it has also the speak option (I am not really interested to translate sentences but to speak them).

As the real program (the translate/speech engine) is in charge to the cloud, the genial solution of trans is that it has been developed with AWK, a programming language specific for text processing and data extraction from natural language sentences. You can find more on the AWK language on Wikipedia.

Also, trans is supported by the standard Raspbian repositories so you can install it just with sudo apt-get install trans

The package is open source with a very well explained documentation on its GitHub repository https://github.com/soimort/translate-shell

In the next episode, we will see in detail how I have integrated all those things together with the natural language parser and processor. It is an AIT engine that runs locally – very fast on the Raspberry PY – that deserves a separate discussion.

Previous Episodes

  • Art-a-Tronic Episode 1
  • Art-a-Tronic Episode 2
  • Art-a-Tronic Episode 3
  • Art-a-Tronic Episode 4
  • Art-a-Tronic Episode 5
  • Art-a-Tronic Episode 6
  • Art-a-Tronic Episode 7
  • Art-a-Tronic Episode 8
  • Art-a-Tronic Episode 9
  • Art-a-Tronic Episode 10
  • Art-a-Tronic Episode 11
  • Art-a-Tronic Episode 12

Next Episodes

  • Art-a-Tronic Episode 14
  • Art-a-Tronic Episode 15
  • Art-a-Tronic Episode 16
  • Sign in to reply

Top Comments

  • three-phase
    three-phase over 6 years ago +3
    Another great update and entertaining video, to go along with the technical information. Kind regards.
  • balearicdynamics
    balearicdynamics over 6 years ago in reply to three-phase +2
    Thank you, Donald, happy you appreciate. Stay in touch for the next episode, some other surprise is coming Enrico
Parents
  • three-phase
    three-phase over 6 years ago

    Another great update and entertaining video, to go along with the technical information.

     

    Kind regards.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 6 years ago in reply to three-phase

    Thank you, Donald, happy you appreciate.

    Stay in touch for the next episode, some other surprise is coming image

     

    Enrico

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • balearicdynamics
    balearicdynamics over 6 years ago in reply to three-phase

    Thank you, Donald, happy you appreciate.

    Stay in touch for the next episode, some other surprise is coming image

     

    Enrico

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube