DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Data
  4. Using Deep Speech in Streaming Big Data Flows

Using Deep Speech in Streaming Big Data Flows

Explore using speech-to-text in streams in Big Data environments.

Tim Spann user avatar by
Tim Spann
CORE ·
Dec. 13, 18 · Tutorial
Like (6)
Save
Tweet
Share
9.50K Views

Join the DZone community and get the full member experience.

Join For Free

Deep Speech With Apache NiFi 1.8

Tools: Python 3.6, PyAudio, TensorFlow, Deep Speech, Shell, Apache NiFi

Why: Speech-to-Text

Use Case: Voice control and recognition.

Series: Holiday Use Case: Turn on Holiday Lights and Music on command.

Cool Factor: Ever want to run a query on Live Ingested Voice Commands?

Other Options: Voice Controlled with AIY Voice and NiFi

We are using Python 3.6 to write some code around PyAudio, TensorFlow, and Deep Speech to capture audio, store it in a wave file, and then process it with Deep Speech to extract some text. This example is running in OSX without a GPU on Tensorflow v1.11.

The Mozilla Github repo for their Deep Speech implementation has nice getting-started information that I used to integrate our flow with Apache NiFi.

Installation as per Deep Speech

pip3 install deepspeech
wget -O - https://github.com/mozilla/DeepSpeech/releases/download/v0.3.0/deepspeech-0.3.0-models.tar.gz | tar xvfz -

This pre-trained model is available for English. For other languages, you will need to build your own. You can use a beef HDP 3.1 cluster to train this.

Apache NiFi Flow

The flow is simple, and we call our shell script that runs Python that records audio and sends it to Deep Speech for processing.

We get back a voice_string in JSON that we turn into a record for querying and filtering in Apache NiFi.

I am handling a few voice commands for "Save," "Load," and "Move." As you can imagine, you can handle pretty much anything you want. It's a simple way to use voice to control streaming data flows or just to ingest large streams of text. Even using advanced Deep Learning text recognition is still not the strongest.

If you are going to load balance connections between nodes, you have options on compression and load balancing strategies. This can come in handy if you have a lot of servers.

Shell Script

python3.6 /Volumes/TSPANN/projects/DeepSpeech/processnifi.py /Volumes/TSPANN/projects/DeepSpeech/models/output_graph.pbmm /Volumes/TSPANN/projects/DeepSpeech/models/alphabet.txt

Schema

{
  "type" : "record",
  "name" : "voice",
  "fields" : [ {
    "name" : "systemtime",
    "type" : "string",
    "doc" : "Type inferred from '\"12/10/2018 14:53:47\"'"
  }, {
    "name" : "voice_string",
    "type" : "string",
    "doc" : "Type inferred from '\"\"'"
  } ]
}

We can add more fields as needed.

Example Run

HW13125:DeepSpeech tspann$ ./runnifi.sh
TensorFlow: v1.11.0-9-g97d851f04e
DeepSpeech: unknown
2018-12-10 14:36:43.714433: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
{"systemtime": "12/10/2018 14:36:43", "voice_string": "one two three or five six seven eight nine"}

We can run this on top of YARN 3.1 as dockerized or non-dockerized workloads.

Setting up nodes to run HDF 3.3 - Apache NiFi and friends is easy in the cloud or on-premise in OpenStack with super devops tools.

When running Apache NiFi it is easy to monitor in Ambari:

References:

  • Deep Speech Tensorflow
  • Running TensorFlow on YARN 3.1
  • Deep Search Paper
  • My Github
Big data Flow (web browser) Apache NiFi

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Top 5 Node.js REST API Frameworks
  • 5 Factors When Selecting a Database
  • OpenID Connect Flows
  • Distributed SQL: An Alternative to Database Sharding

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: