PranavLal
Posts: 124
Joined: Fri Jun 28, 2013 4:49 pm

Re: Sight for the Blind for <100$

Tue Mar 11, 2014 12:02 am

Hi Mike,

Sounds good. Do give him the commandline you use to compile and build the vOICe on the pi. I can help too so just ask.

Pranav

mikey11
Posts: 354
Joined: Tue Jun 25, 2013 6:18 am
Location: canada
Contact: Website

Re: Sight for the Blind for <100$

Sat Mar 22, 2014 6:07 pm

That engineer I met just sent a non-comittal expression of interest. Who knows where that could go.

For anyone following this thread: If you improve the combined code speed such that the rate of once/second is achieved, I've got $500 with your name on it. I will verify success or failure prior to paying out to ensure that all types of video complexity are handled within the interval.

If I have any updates this forum will be the first to know.

hawk0081
Posts: 2
Joined: Sat Mar 22, 2014 5:52 pm

Re: Sight for the Blind for <100$

Sat Mar 22, 2014 6:18 pm

Hi Mike,

Steve here the Broadcom guy from the ski trip. Sorry it has taken so long to get back to you. What a great project you all have going here. I am happy to help as much as I can. I took a quick look at the C++ code for the image to sound conversion. Very interesting code. I think I could learn a lot if I understood all of it. :)

What I did see was maybe some simple things you could do to speed things up.

Peter put in a section of user definable stuff. I think you could get some speed up just playing around with those.

Code: Select all

#define FL   500   /* Lowest  frequency (Hz) in soundscape   */
#define FH  5000   /* Highest frequency (Hz)                 */
#define FS 44100   /* Sample  frequency (Hz)                 */
#define T   1.05   /* Image to sound conversion time (s)     */
#define D      1   /* Linear|Exponential=0|1 distribution    */
#define HIFI   1   /* 8-bit|16-bit=0|1 sound quality         */
#define STEREO 1   /* Mono|Stereo=0|1 sound selection        */
#define DELAY  1   /* Nodelay|Delay=0|1 model   (STEREO=1)   */
#define FADE   1   /* Relative fade No|Yes=0|1  (STEREO=1)   */
#define DIFFR  1   /* Diffraction No|Yes=0|1    (STEREO=1)   */
#define BSPL   1   /* Rectangular|B-spline=0|1 time window   */
#define BW     0   /* 16|2-level=0|1 gray format in *P[]     */
#define CAM    1   /* Use OpenCV camera input No|Yes=0|1     */
#define VIEW   1   /* Screen view for debugging No|Yes=0|1   */
The big one is FS. I think you will get the most speed up by setting this number lower. Currently he has this set to 44100. This is pretty high. This covers the full spectrum of human hearing. You can read about it, I'm sure you already have. The human ear can hear up-to around 20KHz audio signals, but this is the high end and you don't necessarily need to reach the highest end signals. For example cell phones only go upto around 3.5kHz. Above 5KHz is considered treble range. So you could probably get away with an FS of 22050. This should cut the processing time in half of the routine.

Here is some info about sampling rates to consider:
http://www.csun.edu/~lg48405/sed618/ass ... ormat.html

Also you could set HIFI to 0. This would change the 16-bit to 8-bit encoding. SInce the PI only has 11-bit audio playback quality I think 8-bit maybe good enough. I'm not sure if this would speed things up significantly, but I'm guessing this will help.

Also going from stereo to mono may help. Currently STEREO is 1 you could change it to 0 to go to mono.

Also, I noticed putc and other writing to the wav file is happening inside of the main processing loop. There is overhead when writing to the disk. You could write the wav data to a memory buffer while inside the main processing loops and then at the end write the entire wav encoding to disk in one shot. This would likely speed things up as well. Even if the file is being stored in RAM there is still overhead in making the calls into the operating system using putc compared to simply storing the data into a temporary array. You want to avoid this overhead while inside the main processing loop if at all possible.

Also, the look up tables for the sin functions are a good idea.

Sorry if all of these things have been mentioned before on the forum. I admit I haven't read through all of the information that has been posted yet. I will try to find more time to help as much as possible.

Regards,

PranavLal
Posts: 124
Joined: Fri Jun 28, 2013 4:49 pm

Re: Sight for the Blind for <100$

Sun Mar 23, 2014 3:05 am

Hi Steve,

Thanks for your message. The switch to mono is not a good idea because stereo provides the best discrimination as regards objects in the horizontal plane. However, we can reduce the sampling rate, frequency range etc and see what happens.

I am not sure how to store the data in memory. I wish we could eliminate the use of a file. Do we use a stringstream as described at
http://bytes.com/topic/c/answers/134023 ... ile-memory

If so, I can't see how to get a utility such as aplay to access it.

Pranav

mikey11
Posts: 354
Joined: Tue Jun 25, 2013 6:18 am
Location: canada
Contact: Website

Re: Sight for the Blind for <100$

Tue Mar 25, 2014 12:35 am

Hi Steve,

Although the pi outputs 11 bit sound, that is only through the audio output jack. AFAIK full quality sound can be put out through the HDMI output.

The difference between 8 and 16 bit is night and day, and I have already tried that. It did generate savings, but the quality loss is substantial. I posted a link to demonstrate the difference between the two.

If possible, it would be ideal to see if there is a way to encode as 16bit, but only calculate 11bit, and just fill the extra space with null info. The sound player will not play 11 bit files even if you can encode at 11 bit.

https://www.youtube.com/watch?v=Cmorf6JwuDg

I agree that you are right about the sampling frequency. Cutting it off at 22khz is totally doable. It's very rare when headphones or speakers can reproduce the higher frequencies.

keep the ideas coming!

I'm getting a 3D printer at the end of May, so when that arrives I am going to look into making a good headmount soultion for the camera/pi, and maybe even a battery. I will be able to do things that I couldn't do before. For instance Pranav has indicated that the best results are obtained with wide angle lenses. I will be able to build mounts that hold the camera and the lens. I'm quite looking forward to that.

hawk0081
Posts: 2
Joined: Sat Mar 22, 2014 5:52 pm

Re: Sight for the Blind for <100$

Tue Mar 25, 2014 5:13 pm

I started with Mike's code and made modifications. I don't have a raspberry pi compiler setup or any system to test it, but I think the code should compile.

Changes are:
1. FS=22050 - should speed up the processing by a factor of 2 so maybe that alone gets you to 2.5 seconds/frame.
2. Use inline functions for wi and wl.
3. Write to a temporary storage buffer inside the main loop using buf_putc instead of fputc.

Could someone with a compiler/test setup try compiling and running this code to see where we stand for throughput?

Code: Select all

/* C program for soundscape generation. (C) P.B.L. Meijer 1996 */

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

using namespace cv;

#include <math.h>
#include <stdio.h>
#include <assert.h>

const char*  FNAME="h01.wav";    /* User-defined parameters   */

const int N=64;   /* Resolution, i.e., # rows and columns   */
const int FL=500;   /* Lowest  frequency (Hz) in soundscape */
const int FH=5000;   /* Highest frequency (Hz)                 */
const int FS=22050;   /* Sample  frequency (Hz)                 */
const int MAX_BYTES_PER_SAMPLE = 4;
const double T=1.05;   /* Image to sound conversion time (s)     */

unsigned char TEMP_WAV_BUF[FS*MAX_BYTES_PER_SAMPLE]; /* Buffer for storing wav data during main loop */
int TEMP_WAV_BUF_IDX = 0;
// non-const, so they can get toggled at startup
int D=1;   /* Linear|Exponential=0|1 distribution    */
int HIFI=1;   /* 8-bit|16-bit=0|1 sound quality         */
int STEREO=1;   /* Mono|Stereo=0|1 sound selection        */
int DELAY=1;   /* Nodelay|Delay=0|1 model   (STEREO=1)   */
int FADE=1;   /* Relative fade Yes|No=0|1  (STEREO=1)   */
int DIFFR=1;   /* Diffraction Yes|No=0|1    (STEREO=1)   */
int BSPL=1;   /* Rectangular|B-spline=0|1 time window   */

const int BW=0;   /* 16|2-level=0|1 grey format in *P[]     */
#define C_ALLOC(number, type) ((type *) calloc((number),sizeof(type)) )
const double TwoPi=6.283185307179586476925287;

int playSound( char *filename ) {
    char command[256]; int status;
    /* create command to execute */
    sprintf( command, "aplay -i %s", filename ); /* play sound */ status = system( command );
    return status;
  //  return PlaySound(filename,0,SND_FILENAME);
}

FILE *fp; unsigned long ir=0L, ia=9301L, ic=49297L, im=233280L;
inline void buf_putc(int b) { TEMP_WAV_BUF[TEMP_WAV_BUF_IDX++] = (unsigned char) b; }
inline void wi(unsigned int i) { int b1,b0; b0=i%256; b1=(i-b0)/256; buf_putc(b0); buf_putc(b1); }
inline void wl(long l) { unsigned int i1,i0; i0=l%65536L; i1=(l-i0)/65536L; wi(i0); wi(i1); }

double rnd(void){ ir = (ir*ia+ic) % im; return ir / (1.0*im); }

int main(int argc, char *argv[])
{
    int cam_id = 0;  // 1st available opencv camera
    // override flags from cmdline : prog.exe [cam_id] [linear] [nodelay], etc. args can be in any order
    for ( int a=1; a<argc; a++ )
    {
        if ( ! strcmp(argv[a],"linear") )        { D = 0; }
        else if ( ! strcmp(argv[a],"nohifi") )   { HIFI = 0; }
        else if ( ! strcmp(argv[a],"nostereo") ) { STEREO = 0; }
        else if ( ! strcmp(argv[a],"nodelay") )  { DELAY = 0; }
        else if ( ! strcmp(argv[a],"nofade") )   { FADE = 0; }
        else if ( ! strcmp(argv[a],"nodiffr") )  { DIFFR = 0; }
        else if ( ! strcmp(argv[a],"nobspl") )   { BSPL = 0; }
        else cam_id = atoi(argv[a]);
    }

    //beginning of main function
    //start of opencv variables
    VideoCapture cap; //handle camera capture
    Mat gray,frame; //image matrices
   //end of opencv variables
   //variables for soundscape generation (initialization)
    int i, j, d=D, ss;
    long k=0L, l, ns=2L*(long)(0.5*FS*T), m=ns/N;
    double **A, a, t, dt=1.0/FS, *w, *phi0, s, y, yp, z, tau1, tau2, x, theta,
      scale=0.5/sqrt(double(N)), q, q2, r, sl, sr, tl, tr, yl, ypl, yr, ypr,
         zl, zr, hrtf, hrtfl, hrtfr, v=340.0, /* v = speed of sound (m/s) */
          hs=0.20;  /* hs = characteristic acoustical size of head (m) */
    w    = C_ALLOC(N, double);
    phi0 = C_ALLOC(N, double);
    A    = C_ALLOC(N, double *);

    for (i=0; i<N; i++) A[i] = C_ALLOC(N, double);  /* N x N pixel matrix */
    //end of variables for soundscape generation (initialization)
    /* Set lin|exp (0|1) frequency distribution and random initial phase */
    if (d) for (i=0; i<N; i++) w[i] = TwoPi * FL * pow(1.0* FH/FL,1.0*i/(N-1));
    else   for (i=0; i<N; i++) w[i] = TwoPi * FL + TwoPi * (FH-FL)   *i/(N-1) ;
    for (i=0; i<N; i++) phi0[i] = TwoPi * rnd();
    //end of frequency randomization
    /*start video capture and image downsampling for feeding into matrix contained in variable A*/
    // device ids
//converting to a file based capturing system
    bool ok = true;
    //create a main while loop that handles keyboard input
    while(ok)
    {//start of keyboard while loop
//take the image to sonify
/*takePiImage();*/
//read image file from disk for sonification


getframe:
frame=imread("/dev/shm/picture0001.jpg",CV_LOAD_IMAGE_UNCHANGED);
        //save image after height and width reduction to disk
        //imwrite("h01Shrunk.jpg",frame);

        if ( frame.empty() )
        {
            //fprintf(stderr,"No image.");
            usleep(50);
            goto getframe;
            return 1;
        }
        //temp overwrite frame with image for testing
        //frame=imread("lineflat.jpg",CV_LOAD_IMAGE_COLOR);
        //reduce to gray scale
        Mat tmp;
        cvtColor(frame,tmp,CV_BGR2GRAY);
        //actually resize to NxN
        if ( frame.rows != N )
            resize( tmp, gray, Size(N,N) );
        else
            gray=tmp;

        //save grayscale image to disk for debugging
    //imwrite("h01Gray.jpg",gray);
    //feed data into matrix overwriting the hard coded image
    for(int rws=0;rws<N;rws++)
    {//start of matrix population for loop for rows
        for(int cols=0;cols<N;cols++)
        {//start of matrix population for loop for columns
            double mVal=gray.at<uchar>(rws,cols)/16;
            A[rws][cols]=mVal;
        }//end of matrix population for loop for columns

    }//end of matrix population for loop for rows


    /*end video capture and image downsampling for feeding into matrix contained in variable A*/

    // moved this into the loop, so you can toggle flags
    long sso=HIFI?0L:128L, ssm=HIFI?32768L:128L;
    int HIST = (1+HIFI)*(1+STEREO);

    /* Write 8/16-bit mono/stereo .wav file, using rectangular time window */
    fp = fopen(FNAME,"wb"); fprintf(fp,"RIFF"); wl(ns*HIST+36L);
    fprintf(fp,"WAVEfmt "); wl(16L); wi(1); wi(STEREO?2:1); wl(0L+FS);
    wl(0L+FS*HIST); wi(HIST); wi(HIFI?16:8); fprintf(fp,"data"); wl(ns*HIST);
    tau1 = 0.5 / w[N-1]; tau2 = 0.25 * tau1*tau1;
    y = yl = yr = z = zl = zr = 0.0;
    /* Not optimized for speed */
    while (k < ns && !STEREO) {
        if (BSPL) { q = 1.0 * (k%m)/(m-1); q2 = 0.5*q*q; }
        j = k / m; if (j>N-1) j=N-1; s = 0.0; t = k * dt;
        if (k < ns/(5*N)) s = (2.0*rnd()-1.0) / scale;  /* "click" */
        else for (i=0; i<N; i++) {
         if (BSPL) {  /* Quadratic B-spline for smooth C1 time window */
            if (j==0) a = (1.0-q2)*A[i][j]+q2*A[i][j+1];
            else if (j==N-1) a = (q2-q+0.5)*A[i][j-1]+(0.5+q-q2)*A[i][j];
            else a = (q2-q+0.5)*A[i][j-1]+(0.5+q-q*q)*A[i][j]+q2*A[i][j+1];
         }
         else a = A[i][j];
         s += a * sin(w[i] * t + phi0[i]);
        }
        yp = y; y = tau1/dt + tau2/(dt*dt);
        y  = (s + y * yp + tau2/dt * z) / (1.0 + y); z = (y - yp) / dt;
        l  = sso + 0.5 + scale * ssm * y; /* y = 2nd order filtered s */
        if (l >= sso-1+ssm) l = sso-1+ssm; if (l < sso-ssm) l = sso-ssm;
        ss = (unsigned int) l;
        if (HIFI) wi(ss); else buf_putc(ss);
        k++;
   }
   while (k < ns && STEREO) {
      if (BSPL) { q = 1.0 * (k%m)/(m-1); q2 = 0.5*q*q; }
      j = k / m; if (j>N-1) j=N-1;
      r = 1.0 * k/(ns-1);  /* Binaural attenuation/delay parameter */
      theta = (r-0.5) * TwoPi/3; x = 0.5 * hs * (theta + sin(theta));
      tl = tr = k * dt; if (DELAY) tr += x / v; /* Time delay model */
      x  = fabs(x); sl = sr = 0.0; hrtfl = hrtfr = 1.0;
      for (i=0; i<N; i++) {
         if (DIFFR) {
            /* First order frequency-dependent azimuth diffraction model */
            if (TwoPi*v/w[i] > x) hrtf = 1.0; else hrtf = TwoPi*v/(x*w[i]);
            if (theta < 0.0) { hrtfl =  1.0; hrtfr = hrtf; }
            else             { hrtfl = hrtf; hrtfr =  1.0; }
         }
         if (FADE) {
            /* Simple frequency-independent relative fade model */
       hrtfl *= (1.0-0.7*r);
       hrtfr *= (0.3+0.7*r);
         }
         if (BSPL) {
            if (j==0) a = (1.0-q2)*A[i][j]+q2*A[i][j+1];
            else if (j==N-1) a = (q2-q+0.5)*A[i][j-1]+(0.5+q-q2)*A[i][j];
            else a = (q2-q+0.5)*A[i][j-1]+(0.5+q-q*q)*A[i][j]+q2*A[i][j+1];
         }
         else a = A[i][j];
         sl += hrtfl * a * sin(w[i] * tl + phi0[i]);
         sr += hrtfr * a * sin(w[i] * tr + phi0[i]);
      }
      if (k < ns/(5*N)) sl = (2.0*rnd()-1.0) / scale;  /* Left "click" */
      if (tl < 0.0) sl = 0.0;
      if (tr < 0.0) sr = 0.0;
      ypl = yl; yl = tau1/dt + tau2/(dt*dt);
      yl  = (sl + yl * ypl + tau2/dt * zl) / (1.0 + yl); zl = (yl - ypl) / dt;
      ypr = yr; yr = tau1/dt + tau2/(dt*dt);
      yr  = (sr + yr * ypr + tau2/dt * zr) / (1.0 + yr); zr = (yr - ypr) / dt;
      l   = sso + 0.5 + scale * ssm * yl;
      if (l >= sso-1+ssm) l = sso-1+ssm; if (l < sso-ssm) l = sso-ssm;
      ss  = (unsigned int) l;
      if (HIFI) wi(ss); else buf_putc(ss);  /* Left channel */
      l   = sso + 0.5 + scale * ssm * yr;
      if (l >= sso-1+ssm) l = sso-1+ssm; if (l < sso-ssm) l = sso-ssm;
      ss  = (unsigned int) l;
      if (HIFI) wi(ss); else buf_putc(ss);  /* Right channel */
      k++;
   }
   assert(TEMP_WAV_BUF_IDX <= sizeof(TEMP_WAV_BUF)); /* increase buffer size if this assert is hit */
   fwrite(TEMP_WAV_BUF,1,TEMP_WAV_BUF_IDX,fp);
   fclose(fp);
    //play the soundscape using aplay
    system ("sudo rm /dev/shm/*.*"); //delete files in directory to ensure latest frame the python script will rename the latest frame that is generated while the sound plays
    int pps=playSound("h01.wav");
    int rFile=remove("h01.jpg");
     rFile=remove("h01.wav");
    k=0; //reset the sample count to allow while loop to execute
}//end of keyboard while loop
printf("normal exit. \n");
 return(0);
}//end of main function

PranavLal
Posts: 124
Joined: Fri Jun 28, 2013 4:49 pm

Re: Sight for the Blind for <100$

Wed Mar 26, 2014 4:13 am

Thanks. I will test and report. I need to rebuild my raspberry pi's OS and reinstall opencv but that should be doable.

mikey11
Posts: 354
Joined: Tue Jun 25, 2013 6:18 am
Location: canada
Contact: Website

Re: Sight for the Blind for <100$

Thu Mar 27, 2014 1:41 am

I will test it this weekend. As early as friday afternoon.

If this gets to 2.5/s I will rewrite the image mode selectors to match the requirements pranav mentioned ages ago more closely. The possible settings now are too broad and include many functions which probably don't help.

mikey11
Posts: 354
Joined: Tue Jun 25, 2013 6:18 am
Location: canada
Contact: Website

Re: Sight for the Blind for <100$

Fri Mar 28, 2014 7:42 pm

Gents,

I have tried to test the code, and though it compiles, when I run it I get a segmentation fault, with no other information supplied.

Is there a way to get additional info on the seg fault?

I am compiling as follows:

Code: Select all

g++ -I /usr/include -O3 /home/pi/Desktop/soundscape.cpp -o vl02.bin -lopencv_core -lopencv_imgproc -lopencv_highgui -march=armv6 -mfpu=vfp -mfloat-abi=hard

User avatar
DougieLawson
Posts: 35116
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Sight for the Blind for <100$

Fri Mar 28, 2014 7:46 pm

mikey11 wrote: Is there a way to get additional info on the seg fault?
Run it under gdb.
http://www.yolinux.com/TUTORIALS/GDB-Commands.html
http://sourceware.org/gdb/current/onlinedocs/gdb/
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

mikey11
Posts: 354
Joined: Tue Jun 25, 2013 6:18 am
Location: canada
Contact: Website

Re: Sight for the Blind for <100$

Sat Mar 29, 2014 2:02 am

I compiled with the -g option to get debug info from gdb like this:

Code: Select all

 g++ -I /usr/include -O3 newsound.cpp -o vl02.bin -lopencv_core -lopencv_imgproc -lopencv_highgui -march=armv6 -mfpu=vfp -mfloat-abi=hard -g
Then I got this output from gdb:
vl02.bin: newsound.cpp:218: int main(int, char**): Assertion `TEMP_WAV_BUF_IDX <= sizeof(TEMP_WAV_BUF)' failed.

Program received signal SIGABRT, Aborted.
0xb6980bfc in raise () from /lib/arm-linux-gnueabihf/libc.so.6
So the code for buffering to memory (which I don't claim to understand) appears to be failing on a sizing issue.

mikey11
Posts: 354
Joined: Tue Jun 25, 2013 6:18 am
Location: canada
Contact: Website

Re: Sight for the Blind for <100$

Wed Apr 09, 2014 5:20 am

I will be unavailable for the next two weeks, but the $500 bounty still stands.

mikey11
Posts: 354
Joined: Tue Jun 25, 2013 6:18 am
Location: canada
Contact: Website

Re: Sight for the Blind for <100$

Wed Apr 30, 2014 7:30 pm

The bounty is upped to $1000.

Tell your friends.

User avatar
seeingwithsound
Posts: 165
Joined: Sun Aug 28, 2011 6:07 am
Contact: Website

Re: Sight for the Blind for <100$

Thu May 01, 2014 2:37 pm

Hi Mike,

You allocate TEMP_WAV_BUF[] only once, for one soundscape, which is fine. However, it means that you need to recycle its use by resetting its index TEMP_WAV_BUF_IDX every soundscape, setting it back to 0. Currently your TEMP_WAV_BUF_IDX keeps increasing via calls to buf_putc() until it exceeds the allocated range for TEMP_WAV_BUF[], causing an exception, most likely after the first soundscape. You can in fact just reuse the existing variable k instead of TEMP_WAV_BUF_IDX, since they serve the same purpose and k is already reset every soundscape. That should fix your problem. You can gain some speed by setting BSPL = 0 and STEREO = 0 at the expense of sound quality.

Best regards,

Peter


Seeing with Sound - The vOICe
http://www.seeingwithsound.com

mikey11
Posts: 354
Joined: Tue Jun 25, 2013 6:18 am
Location: canada
Contact: Website

Re: Sight for the Blind for <100$

Sat May 03, 2014 6:54 am

I will attempt your recommendation as soon as I have time.

In the meantime, welcome Brian. He has expressed interest in revising the python code to match pranavs specifications.

If his interest becomes serious, I have 500$ on getting the python code to implement the features desired.

The bounty for the CPP code still stands as that is the bottleneck.

Once the CPP part has been optimized, getting the vision mode features cued to the keypresses is required. If this is done ahead of time, great!

selvan90
Posts: 3
Joined: Sat May 17, 2014 8:14 pm

Re: Sight for the Blind for <100$

Sat May 17, 2014 8:23 pm

Hello..I am Thiruselvan from Malaysia....Currently I am also developing The vOICe for Raspberry Pi as my bachelor degree's final year project...The project is at final stage now...I used the exact version of Peter Meijer's source code...It does capture the image from camera but I am unable to play the sound (I got an error :682 with aplay citing "unable to find audio file"). Anybody has an idea on what's wrong with that?

mikey11
Posts: 354
Joined: Tue Jun 25, 2013 6:18 am
Location: canada
Contact: Website

Re: Sight for the Blind for <100$

Sat May 17, 2014 8:26 pm

I would say you need to check your filenames.

selvan90
Posts: 3
Joined: Sat May 17, 2014 8:14 pm

Re: Sight for the Blind for <100$

Sat May 17, 2014 8:53 pm

mikey11 wrote:I would say you need to check your filenames.
but i didn't modify the code....that shouldn't be a problem...the file name is exactly the same....:-)

mikey11
Posts: 354
Joined: Tue Jun 25, 2013 6:18 am
Location: canada
Contact: Website

Re: Sight for the Blind for <100$

Sat May 17, 2014 8:56 pm

Maybe every time a filename is used in the code put a path in as well.

Ie. If the filename is f01.wav , then enter /whatever/whatever/f01.wav

This way the program will always be referring to the same location.

PranavLal
Posts: 124
Joined: Fri Jun 28, 2013 4:49 pm

Re: Sight for the Blind for <100$

Sun May 18, 2014 3:13 am

Hi,
Mike is correct. Have a fixed location where you store the file. Overwrite the file each time you play the sound. A better approach is not to use a file on disk but a file in memory. However, I do not know how to play such a file using aplay which is why I have not tried this approach.

Pranav

theodore007
Posts: 1
Joined: Sun May 18, 2014 5:18 am
Location: Bucuresti, Romania
Contact: Website

Re: Sight for the Blind for <100$

Sun May 18, 2014 6:00 am

this is application it's amazing, i didn't knew that you can do such things with raspberry! this topic it's absolutely remarcable, i will follow the guide above!
passion for web and creation

User avatar
DougieLawson
Posts: 35116
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Sight for the Blind for <100$

Sun May 18, 2014 8:15 am

PranavLal wrote:Hi,
Mike is correct. Have a fixed location where you store the file. Overwrite the file each time you play the sound. A better approach is not to use a file on disk but a file in memory. However, I do not know how to play such a file using aplay which is why I have not tried this approach.

Pranav
Use a memory tmpfs.

Make a mount mount
sudo mkdir /music

Add a line to /etc/fstab
tmpfs /music tmpfs defaults,noatime,nosuid,mode=0755,size=100m 0 0

Reboot and /music is now a ram disk system. Write your files there as normal (up to 100MB in size). Play them as normal.

You may need to fiddle with the size of the files and the size of the ram disk to get everything to fit (it may be a bit of a juggling act with only 512MB available for everything).
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

PranavLal
Posts: 124
Joined: Fri Jun 28, 2013 4:49 pm

Re: Sight for the Blind for <100$

Sun May 18, 2014 9:28 am

Hi DougieLawson,

I had forgotten about ram disks. Yes, they are an excellent option. The file generated by the vOICe is constant in size and can be safely overwritten so a ram disk is ideal.

Pranav

selvan90
Posts: 3
Joined: Sat May 17, 2014 8:14 pm

Re: Sight for the Blind for <100$

Sat Jun 07, 2014 4:06 pm

almost successfully managed to port it into raspberry pi..i used the same peter's code but with a change of using omxplayer instead of aplay....but the soundscape is like just 1 second and has 5 second delay before the next soundscape...any1 has an idea on this problem?

mikey11
Posts: 354
Joined: Tue Jun 25, 2013 6:18 am
Location: canada
Contact: Website

Re: Sight for the Blind for <100$

Sat Jun 07, 2014 5:01 pm

The problem is the c code is not optimized.

Aaplay is optimized, the python code to grab frames is using optimized libraries.

The best targets for improvement are portions of the c code.

The proposals are to write to memory instead of files as per Stevens contribution (which I did not get to work), and to try using look up tables for the trig functions.

I already use the ram disk approach.

Return to “Assistive technology and accessibility”