flbillowes
Posts: 5
Joined: Mon Nov 11, 2019 11:50 am

Scaling Down a prototype

Mon Nov 11, 2019 12:04 pm

Hi,

I have built a prototype for a product that consists of a microphone, a raspberry pi 3B+, an arduino and several motor drivers and some motors.

I have written a script in python that listens to what is being said through the microphone, uses google API to translate the sounds into words, and then searches a file for those words. Each word has a sequence of vibrations that is associated with it - this sequence is sent to the arduino over serial which then causes the motors to vibrate in a recognisable pattern dependant on what has been said. I am now at the stage that I want to scale this down as the hardware listed above is quite bulky, and this needs to be a wearable device.

I have tried the same setup with the raspberry pi 0 w but it just crashes - the file that the python script is opening then importing to an array is quite large and the pi can't seem to handle it.

I essentially need a board that can access the internet to use google's API, store a file of 130000+ words and related sequences, run a python script and 'talk' to an arduino/motor driver setup on a small scale. Speed is quite essential as the vibrations need to happen as close to the trigger word's occurrence as possible.

I am pretty much at the limit of my knowledge so was just wondering if anyone would have any suggestions as to how to tackle this? Would this be something the Raspberry Pi Compute Module would be used for? Or is there a possibility of creating a custom board?

Any help is appreciated.

Thanks,
Freddy

User avatar
rpiMike
Posts: 1077
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: Scaling Down a prototype

Mon Nov 11, 2019 2:05 pm

Sounds like you need 1GB RAM - maybe the Compute Module 3+ https://www.raspberrypi.org/products/co ... 3plus-32gb

drgeoff
Posts: 10216
Joined: Wed Jan 25, 2012 6:39 pm

Re: Scaling Down a prototype

Mon Nov 11, 2019 3:01 pm

How quickly did you give up on the ZeroW? Were you using NOOBS with full Raspbian or only Raspbian Lite? If even the latter will not leave enough RAM have a look at piCore Linux.

hippy
Posts: 6736
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Scaling Down a prototype

Mon Nov 11, 2019 6:21 pm

flbillowes wrote:
Mon Nov 11, 2019 12:04 pm
I have tried the same setup with the raspberry pi 0 w but it just crashes - the file that the python script is opening then importing to an array is quite large and the pi can't seem to handle it.
You might not have to import it all. You could load the parts you need from disk as needed, even keep the relevant file(s) on a RAM disk which may speed things up. You could perhaps layer some word caching on top. C or any non-interpreted language would likely be faster than Python.

MarkDH102
Posts: 377
Joined: Fri Feb 13, 2015 3:18 pm

Re: Scaling Down a prototype

Tue Nov 12, 2019 7:32 am

I don't know about the Google API, but the Google AIY does NOT work on a Pi0 / 0W.
I did the same as you (I was controlling relays to switch mains) and scaled a Pi3 solution down to a Pi0W. Boxed it all up. Made a super job of it (unlike me).
Powered it on and found that the AIY stuff is compiled for a later ARM processor and just crashes on the 0.
I have since moved to an ESP8266 solution to do all the relay stuff and it is in turn controlled by the Pi3 running the AIY software and using MQTT.

flbillowes
Posts: 5
Joined: Mon Nov 11, 2019 11:50 am

Re: Scaling Down a prototype

Tue Nov 12, 2019 3:48 pm

rpiMike wrote:
Mon Nov 11, 2019 2:05 pm
Sounds like you need 1GB RAM - maybe the Compute Module 3+ https://www.raspberrypi.org/products/co ... 3plus-32gb
That's what I was thinking, but as the processes being carried out are fairly simple I was wondering if using that might be overkill?

flbillowes
Posts: 5
Joined: Mon Nov 11, 2019 11:50 am

Re: Scaling Down a prototype

Tue Nov 12, 2019 3:49 pm

MarkDH102 wrote:
Tue Nov 12, 2019 7:32 am
I don't know about the Google API, but the Google AIY does NOT work on a Pi0 / 0W.
I did the same as you (I was controlling relays to switch mains) and scaled a Pi3 solution down to a Pi0W. Boxed it all up. Made a super job of it (unlike me).
Powered it on and found that the AIY stuff is compiled for a later ARM processor and just crashes on the 0.
I have since moved to an ESP8266 solution to do all the relay stuff and it is in turn controlled by the Pi3 running the AIY software and using MQTT.
Unfortunately the pi0 fails at loading the file even without trying to request any of the API stuff. Not heard of AIY so will look into it, thanks!

flbillowes
Posts: 5
Joined: Mon Nov 11, 2019 11:50 am

Re: Scaling Down a prototype

Tue Nov 12, 2019 3:52 pm

hippy wrote:
Mon Nov 11, 2019 6:21 pm
flbillowes wrote:
Mon Nov 11, 2019 12:04 pm
I have tried the same setup with the raspberry pi 0 w but it just crashes - the file that the python script is opening then importing to an array is quite large and the pi can't seem to handle it.
You might not have to import it all. You could load the parts you need from disk as needed, even keep the relevant file(s) on a RAM disk which may speed things up. You could perhaps layer some word caching on top. C or any non-interpreted language would likely be faster than Python.
I had started coding this in C but unfortunately it got a bit convoluted as I'm not too confident in the language and found python a much easier way of approaching the task. Now I've got some more time I might give it another go. Thanks!

flbillowes
Posts: 5
Joined: Mon Nov 11, 2019 11:50 am

Re: Scaling Down a prototype

Tue Nov 12, 2019 3:55 pm

drgeoff wrote:
Mon Nov 11, 2019 3:01 pm
How quickly did you give up on the ZeroW? Were you using NOOBS with full Raspbian or only Raspbian Lite? If even the latter will not leave enough RAM have a look at piCore Linux.
Not sure which I was using, I had to hack something together with pibakery because the supplied SD wasn't working.

Do you have any suggestions on really slimming down the OS to free up more RAM?

Eirikur
Posts: 46
Joined: Sun Sep 09, 2018 9:43 pm

Re: Scaling Down a prototype

Wed Nov 13, 2019 1:44 am

If it is failing on loading that file into a Python array, don't do it that way. You could search through the file using standard Unix command line utilities launched by your Python code. You could also read through the file, using Python, setting your buffer size to something that will fit in memory, but reading line by line is very easy and works well.

User avatar
Gavinmc42
Posts: 4294
Joined: Wed Aug 28, 2013 3:31 am

Re: Scaling Down a prototype

Wed Nov 13, 2019 3:13 am

Tensorflow lite now runs on microcontrollers.

What you have made is a prototype, going to production requires much more development.
If you look inside all those google/siri boxes it is still not simple and they are the experts.

If you want to persist with PI hardware then Compute would be the next step.
Or perhaps a 3A+
Alternative hardware is out there, Kendyte K210 from Seeed Studio etc.
Perhaps ESP32 based hardware, I have seen a tiny one with display and microphone from Adafruit etc.

Not sure what you a doing with the motors.
if it is just vibration , haptic drivers and actuators should be faster and longer life.

130,000 words is a big ask.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Return to “General discussion”