Interactive Talking Robot Issues

Hello, after some time of working on the wave shield and vrbot module, I got the two working together. The only thing keeping it from being a good design is the software right now. After several voice commands it says too many files open, couldnt open file. The thing is, it only says this for one set of voice commands. I am aware that u need to close the file after playback and i believe ive done that. Anyways, Im at a bit of a loss and would greatly appreciate someone pointing me in the right direction. Thank you

#include <NewSoftSerial.h>
#include <AF_Wave.h>
#include <avr/pgmspace.h>
#include "util.h"
#include "wave.h"


NewSoftSerial BS2 = NewSoftSerial(0, 255);   // receive only 
int bs2data = BS2.read(); 

AF_Wave card;
File f;
Wavefile wave;      // only one!

#define redled 9

int wasplaying = 0;

void setup() {
  Serial.begin(9600);
  BS2.begin(9600);  
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Wave test!");

  pinMode(2, OUTPUT); 
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(redled, OUTPUT);
  
  if (!card.init_card()) {
    putstring_nl("Card init. failed!"); return;
  }
  if (!card.open_partition()) {
    putstring_nl("No partition!"); return;
  }
  if (!card.open_filesys()) {
    putstring_nl("Couldn't open filesys"); return;
  }
  if (!card.open_rootdir()) {
    putstring_nl("Couldn't open dir"); return;
  }

  ls();

}

void loop() { 
  
if(BS2.available() > 0) {        
   bs2data = BS2.read();
   Serial.print("Received from BS2: ");
   Serial.println(bs2data);                

    char *TWOBIT = "TWOBIT3.WAV";
    char *SING = "SONG.WAV";
    char *HELLO = "HELLO.WAV";
    char *DIDU = "DIDU.WAV";
    char *JOKE = "JOKE2.WAV";
    char *NO = "NOREPLY1.WAV";
    char *YUP = "YES.WAV";
    char *YES1 = "YESRESPONSE.WAV";
    
    char *toplay;
    
   if (bs2data == 'H') {
       toplay = JOKE;
     
     }
     
     
     else if (bs2data == 'K') {
       toplay = TWOBIT;
       
    }
    
    else if (bs2data == 'F') {
       toplay = YES1;
    
    }
    
     else if (bs2data == 'B') {
       toplay = SING;
    
     }
     
     else if (bs2data == 'E') {
       toplay = NO;
    
     }
     
     
      else if (bs2data == 'I') {
       toplay = YUP;
    
     }
     
     
     else if (bs2data == 'C') {
       toplay = HELLO;
     } else  {

     return;
     }
     
     if (wave.isplaying) {// already playing something, so stop it!
         wave.stop(); // stop it
         card.close_file(f);
     }
     playfile(toplay);
   }

   if (wave.isplaying && !wasplaying) {
     digitalWrite(redled, HIGH);
   } else if (!wave.isplaying && wasplaying) {
     digitalWrite(redled, LOW);
   }
   wasplaying = wave.isplaying;
}


void ls() {
  char name[13];
  card.reset_dir();
  putstring_nl("Files found:");
  while (1) {
    if (!card.get_next_name_in_dir(name)) {
       card.reset_dir();
       return;
    }
    Serial.println(name);
  }
}

void playfile(char *name) {
   f = card.open_file(name);
   if (!f) {
      putstring_nl("Couldn't open file"); return;
   }
   if (!wave.create(f)) {
     putstring_nl("Not a valid WAV"); return;
   }
   // ok time to play!
   wave.play();
}/code]
void setup() {
 Serial.begin(9600);
 BS2.begin(9600);  
 Serial.begin(9600);

I don't think you need more than one Serial.begin statement.

NewSoftSerial BS2 = NewSoftSerial(0, 255);

I don't think you should be using software serial on the hardware serial pin.

   char *TWOBIT = "TWOBIT3.WAV";
   char *SING = "SONG.WAV";
   char *HELLO = "HELLO.WAV";
   char *DIDU = "DIDU.WAV";
   char *JOKE = "JOKE2.WAV";
   char *NO = "NOREPLY1.WAV";
   char *YUP = "YES.WAV";
   char *YES1 = "YESRESPONSE.WAV";

These should all be moved before setup, rather than being in loop.

    if (wave.isplaying) {// already playing something, so stop it!
        wave.stop(); // stop it
        card.close_file(f);
    }

This is the only place where you close a file. If the wav file finishes playing before the next serial data is received, wave.isplaying should be false, so you don't close the file. Every call to playfile should close any open file before opening a new one.