Connect to speech recognization API


has anyone yet connected a microphone to a Spark Core to send voice recordings to a speech recognition API? Is the hardware even capable of doing so?

Kind regards,


it sounds possible and i got a microphone breakout board with me so maybe it’s good that i try doing so :smile:

Which speech recognition API are you looking at?

I haven’t done much research yet, but there seems to be an undocumented speech to text API by Google.

1 Like

@krophi if you want to use for your own project you can do that with android phone just you need tasker app. :smile:

@Yasin I don’t want to rely on an additional standalone device.

I think you could record a small sample from a microphone and upload it to a server with the core. It might not be very fast, but I do think it could be done! :slight_smile:

1 Like

Do you know whether such a microphone + amplifier produces usable output? (in terms of sound quality etc.)

I was going to suggest this part, actually. I think it would work well enough to get you started. Eventually I think you will want a noise cancelling headset of some kind (likely the PC-kind with 1/8 plugs, not USB).

I did try the example on my Mac with the magic key from the github repo and it worked fine for me, even with http rather that https, which was encouraging!


Thanks! I just ordered the component.

The component just arrived. Any idea whether this library is Spark Core compatible?

Did some digging myself. This library requires a SD card, which I don’t want to use. Any suggestions how to create a wav file on Spark Core? The 2 MB flash memory of the Core should be sufficent in case there’s some caching required, shouldn’t it? (Low frequency is okay - I found an article stating that an Arduino can do around 8 kHz without using the DAC)

That key stopped working today.

Your client does not have permission to get URL ...


Yes, noticed that too, but there’s already a new key at the top of the readme file. (the examples haven’t been updated yet)

It would be much appreciated if somebody could give me a hint how to create a wave file of satisfying quality (the specifications of the wave/pcm file format seem to be quite simple) and how to send it to a server. I’m not a bad web and iOS developer, but working with devices like the Core is somehow not (yet) in my line.

Could it be that the Core only takes one analog sample every 5 milliseconds? (200 Hz; it took my Core 4000ms to take 800 samples) The article I linked to in a previous post says that an Arduino takes such samples every 125 microseconds. (8000 Hz) How can the sampling frequency be increased on the Core?


@BDub and I spoke about this during Maker Faire and will be adding an additional variable for users to change the frequency with analogWrite () :slight_smile:


@kennethlimcp Awesome! I guess no ETA yet, right? But at least this is not a hardware limitation :smile:

Hi @krophi

I thought you were asking about the analogRead() (not write) speed. I seem to recall that the latest software is about 40kHz sample rate but I will measure it. Are you reading it in a loop? Is there other processing in the loop? I would unroll the loop for speed if it doesn’t meet you needs.

There already is a function to set the sample time of the ADC but the range is limited by the particular mode that the Spark code uses. That function is setADCSampleTime(ts) were ts is a #defined time. Changing this is definitely an advanced maneuver. The default is 7.5 cycles and you can use 1.5 cycles or 13.5 with the dual slow interleaved mode the firmware does. There is also a 10 sample averaging filter in software, so the sample rate you see at analogRead() is a 1/10th the rate you set on the ADC.


OK, so I measured the ADC sample rate and it turns out to be around 30.5 KS/s or just short of 4 times faster than the Arduino rate. There is some minor variability (the ADC DMA is interrupt driven so you’d expect that) on the order +/- 5 us over 256 samples.

Here is how I did it. I picked 256 samples as a representative size and just used loop, capturing the value of micros() before and after and then display the time difference for 256 samples in microseconds and the rate in Samples/s.

#define NSAMPLES 256
int adcData[NSAMPLES];

void setup() {

void loop() {
    unsigned long tic = micros();
    for( int i=0;i<NSAMPLES;i++) {
        adcData[i] = analogRead(A0);
    unsigned long toc = micros();

    double Ts = (double)NSAMPLES / (double)(toc-tic) * 1000000.0;
1 Like

Okay, thanks. I did only take one measurement per each run of the loop function. (there’s no for loop in that Arduino code either) Will try it and report back later today.

A new question: Where’s the best place to cache (partial) recording data? The external flash? I need to be able to access the cache afterwards in chunks. (for sending it to the server)

1 Like