Over a million developers have joined DZone.

Using Voice-Enabled Devices With Apache MiNiFi

DZone's Guide to

Using Voice-Enabled Devices With Apache MiNiFi

Did you know it's possible to control big data flows with your voice? Learn just how easy it is to do when with MiNiFi, a Raspberry Pi 3, and the Google AIY Voice Kit.

· Big Data Zone ·
Free Resource

Hortonworks Sandbox for HDP and HDF is your chance to get started on learning, developing, testing and trying out new features. Each download comes preconfigured with interactive tutorials, sample data and developments from the Apache community.

Using a Raspberry Pi 3 with Google AIY Voice Kit is an easy way to control data flows in an organization.

The AIY Voice Kit is a good way to prototype voice ingestion. It is not perfect, but for low-end, inexpensive hardware, it is a good solution for those who speak clearly and are willing to repeat a phrase a few times for activation.

I was able to easily add a word for it to react to. I also have it waiting for someone to press the button to activate it.

Setup and Run Steps

  1. Install box

  2. Set up GCP Account

  3. As a Pi user: ~/bin/AIY-voice-kit-shell.sh src/assistant_library_demo.py 

  4. Download and unzip Apache MiNiFi

  5. Custom action: controlx 

  6. Run it: pi@raspberrypi:~/AIY-voice-kit-python/src $ ./controlx.py 

  7. Start MiNiFi.

  8. Apache MiniFi will tail the command file and look for audio files.

Code added to Google example:

elif event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED and event.args:
    print('You said:', event.args['text'])
text = event.args['text'].lower()
f = open("/opt/demo/commands.txt", "a+")
if 'process' in text:
elif 'computer' in text:
elif text == 'ip address':


ip_address = subprocess.check_output("hostname -I | cut -d' ' -f1", shell = True)
f = open("/opt/demo/commands.txt", "a+")
f.write('My IP address is %s' % ip_address.decode('utf-8'))
f.close()# aiy.audio.say('My IP address is %s' % ip_address.decode('utf-8'))# aiy.audio.say('Turning on LED')# voice_name = '/opt/demo/voices/voice_{0}.wav'.format(strftime("%Y%m%d%H%M%S", gmtime()))# aiy.audio.record_to_wave(voice_name, 5)
print('My IP address is %s' % ip_address.decode('utf-8'))

Apache NiFi ingest flow:

Flow file for a sound file:

Flow file for commands:

Apache MiNiFi ingest:

Apache NiFi overview:

Text command processing:

AIYVOICE schema in Hortonworks Schema Registry:

The source code can be found here.

An example of text deciphered from my speaking into the AIY Voice Kit:

what was the process that we could try that a different way right now when was text put it in the file

My IP address is

The recorded audio files sent:

  • ../images/voice_20171229195641.wav

  • ../images/voice_20171229202456.wav

  • ../images/voice_20171229203028.wav

Inferred schema:

{ "type" : "record", "name" : "aiyvoice", "fields" : [ { "name" : "schema", "type" : "string", "doc" : "Type inferred from '\"aiyvoice\"'" }, { "name" : "path", "type" : "string", "doc" : "Type inferred from '\"./\"'" }, { "name" : "schemaname", "type" : "string", "doc" : "Type inferred from '\"aiyvoice\"'" }, { "name" : "commands0", "type" : "string", "doc" : "Type inferred from '\"process process process process process process process process processMy IP address is\\n\"'" }, { "name" : "filename", "type" : "string", "doc" : "Type inferred from '\"commands.3088-3190.txt\"'" }, { "name" : "ssaddress", "type" : "string", "doc" : "Type inferred from '\"\"'" }, { "name" : "receivedFrom", "type" : "string", "doc" : "Type inferred from '\"AIY_GOOGLE_VOICE_PI\"'" }, { "name" : "sshost", "type" : "string", "doc" : "Type inferred from '\"\"'" }, { "name" : "mimetype", "type" : "string", "doc" : "Type inferred from '\"text/plain\"'" }, { "name" : "tailfileoriginalpath", "type" : "string", "doc" : "Type inferred from '\"/opt/demo/commands.txt\"'" }, { "name" : "uuid", "type" : "string", "doc" : "Type inferred from '\"76232a9a-baf1-4f6b-9707-6d532653bbe8\"'" }, { "name" : "RouteOnAttributeRoute", "type" : "string", "doc" : "Type inferred from '\"commands\"'" } ] }

Apache NiFi-created Apache Hive DDL:

hive.ddl CREATE EXTERNAL TABLE IF NOT EXISTS aiyvoice (path STRING, filename STRING, commands0 STRING, ssaddress STRING, receivedFrom STRING, sshost STRING, mimetype STRING, tailfileoriginalpath STRING, uuid STRING, RouteOnAttributeRoute STRING) STORED AS ORC

Here's what it looks like:

And that's it!

Hortonworks Community Connection (HCC) is an online collaboration destination for developers, DevOps, customers and partners to get answers to questions, collaborate on technical articles and share code examples from GitHub.  Join the discussion.

apache minifi ,raspberry pi ,big data ,tutorial ,data processing ,voice enablement ,google aiy ,data flows

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}