Community Articles

Find and share helpful community-sourced technical articles.
avatar

aka YAND; Yet Another Nifi Demo

The recording explains it all really, but see below for detailed instructions on how to duplicate it.

Recording of SAMS in action

## Background

I recently attended YASK, the Hortonworker sales kickoff, and as a part of the training we were to spend some time learning and presenting the corporate sales pitch. This is 35 slides covering the major story points of the business, and takes about 20mins to blast through if you don't stop for questions. It isn't for field use, but it's a good educational tool to get new people up to speed.

Instead of heading back to my hotel room the night before, I got distracted towards the pub by a regional SE director. After a couple of beers we got around to discussing the schedule for the next day, and I joked that it would be pretty funny to use Nifi to do the pitch a la @Jeremy Dyer. Grant (the director) uttered the immortal phrase "I'd be really disappointed if you didn't", and now we're here.

## Credits

Props to Jeremy Dyer's OCR blog which gave me the idea to do strange and unusual things with the OSX 'Say' command; to @jwitt & the Nifi team for making such a ridiculously flexible tool; to @Simon Elliston Ball for teaching me how to use it; and to @Grant Liu for inspiring this little use-case.

## Installing HDF / Nifi

Generally follow the instructions here: https://nifi.apache.org/docs/nifi-docs/html/getting-started.html

Note that on OSX you can quickly setup Nifi using Home Brew

## Guide to building it yourself

Basically what I've done is export the slides and talk-track from a powerpoint deck to a set of .jpg and .txt files with matching names; e.g. Slide01.jpg, Slide01.txt, etc. Working directly with Powerpoint would involve too much custom scripting of Office API functions.

I've then setup Nifi to read in and sequence the text files into a set of lines to be read by the Mac 'Say' command. A key phrase is recognised and used to open up each matching slide image as it's needed. Most of the effort (not a lot) is actually to ensure that the files and lines of text are in the right order, as Nifi defaults to a first-come-first-served dataflow.

### Instructions

The below image shows the general setup; from top left we have a ListFile processor feeding a FetchFile processor to get the files into Nifi; we then use an UpdateAttribute processor and a SplitText processor to generate our sequenced lines of text; we then feed them into a ExecuteStreamCommand processor to run them through the 'Say' command which also acts as our blocking process to ensure serial execution; we then route the original lines out of that TextToSpeech processor into a RouteOnContent processor to recognise the command phrase 'Next Slide' which activates another ExecuteStreamCommand processor to open the appropriate slide image. Detailed configuration parameters in the linked images below, probably a bit easier to scroll through than pausing the video.

3882-slide3.jpg

3883-slide4.jpg

Put your own directory of jpg/txt files into the Input Directory field.

Note that we use a File Filter regex to select just the text files - it's almost code!

3884-slide5.jpg

Set the line split count to 1.

Copy the 'priority' attribute without capitalising it, and use the expression here to select the number from files named like 'Slide01.txt'

3885-slide6.jpg

Here we simply use the 'Say' command in the command path.

Note that we use two prioritizers; the first uses our 'priority' attribute from the UpdateAttribute processor to put each slide in order, the FIFO then puts the lines of text within the slide in order.

3886-slide7.jpg

Finally we match the keyphrase 'NEXT SLIDE' here, and use a couple more expression statements to select the matching jpg file for the lines of slide text.

Enjoy!

Edit: I've exported the template for convenience sales-executive-simulator.xml

2,443 Views
Comments
avatar
Master Guru

Awesome. I knew something awesome would come out of YASK. Next NIFI demo has to create this article in HCC and promote in on social media.

avatar
Guru

Love this!! Already sent it to some close sales reps for a good laugh 🙂 Great job Dan!