Accept audio at 16khz , 16bit via USB.

Status
Not open for further replies.

maharshioza

New member
I am working on some voice recognition based projects and my machine learning model only accepting 16khz sample rate data(Model limitations).

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>


// GUItool: begin automatically generated code
AudioInputAnalog         adc1;           //xy=133,142
AudioEffectBitcrusher    bitcrusher1;    //xy=354,165
AudioOutputUSB           usb1;           //xy=605,218
AudioConnection          patchCord1(adc1, bitcrusher1);
AudioConnection          patchCord2(bitcrusher1, 0, usb1, 1);
AudioConnection          patchCord3(bitcrusher1, 0, usb1, 0);
// GUItool: end automatically generated code
int current_CrushBits = 16; //this defaults to passthrough.
int current_SampleRate = 16000; // this defaults to passthrough.

void setup() {
  delay(1000);
  Serial.begin(9600);
  AudioMemory(8);
  bitcrusher1.bits(current_SampleRate);
  bitcrusher1.sampleRate(current_SampleRate);

}

void loop() {

}

This code is to send audio from analog pin to USB and it is working perfectly.

Now the query is, whenever I change Sample rate frequency from 44100 to 16000 according to this thread
streaming of sound stopped working.

So can someone help to find a solution for transmitting sound from analog pin to USB at the 16khz sample rate?

Thank you for your support.
 
Up to now USB audio is 16bit 44.1kHz only.
If using a Windows computer, this will connect to Microsoft Soundmapper, which does resampling if necessary. An app connecting to the Teensy needs to use Soundmapper if different than default samplerate is required.
WASAPI and ASIO will not work due to the way Teensy USB audio is made.
 
Dear Deleted User, Thank you for your quick replay.

My voice recognition-based app is dynamic. It can run on raspberry pi and Ubuntu, So can you explain possible options for Linux systems?
 
16kHz is every 3rd sample from 48kSPS, which is a standard rate supported by all I2S hardware, although not
supported out of the box for Audio library. Don't see why simple resampling can't be done in your front end?
Low pass filter and decimate by 3 ought to work even with 44.1kSPS as the absolute pitch of speech isn't critical?
 
Dear MarkT, Thank you for your quick replay.

I also developed python code using PyAudio and Sample rate library, but the problem is a delay. My python code not able to work in real-time. In that scenario, teensy works perfectly for me and I don't want to run my resampling code on one processor(raspberry pi), due to less processing power availability. So I am just using two different processors for two different work.
 
Status
Not open for further replies.
Back
Top