#!/usr/bin/perl # # Yousef Rabah - April 13th, 2004 # # DisplaySpeech.pm # # Using people.pm, db.pm, and VEPD # # Package name: DisplaySpeech # # Function exported: displaySpeech (to be used in other scripts) # # -- displaySpeech() # # . First, Getting Info whether user wants to search by First of Last Name. Here we are # getting info of which option the user wants to search by, either by search through # first name, getFirstChar or by searching through last name, getLastChar. At the begining, # before this script is run, the main menu function in VEPD will call function of whether or # not user wants to search by first or last name, and here were opeing the file and storing # in a variable that will be used in this function the result. Either getFirstChar or getLastChar # . Run the record program to record wav files # . Run the wav to raw scrip that will change wav files into raw # files and place the raw files into raw files directory # . Get speech by runing the file get_speech.pl # . Opens decoded speech file from ASR sphinx log file and matching and split # Commands are used to strip unwanted namings, and get back string of decoded # speech into text # . Option: Play_wav() that would enalble user to hear what the user said # if the user chooses to do. # . For the decoded text, it connects to ADB and it to get back namess so here # we are connecting to database through db.pm, and getting back info through # people.pm and people.pl # ###################################################### package DisplaySpeech; require Exporter; @ISA = qw(Exporter); @EXPORT = qw( displaySpeech ); use strict; use people; use db; use VEPD; sub displaySpeech(){ my $wav_files_directory = "/usr/local/share/sphinx3/model/lm/an4/wav_files"; my $raw_files_directory = "/usr/local/share/sphinx3/model/lm/an4/raw_files"; my $raw_dir_rec = "/usr/local/share/sphinx3/model/lm/an4/raw_files/record001.raw"; my $DecodedSpeech = "/root/perl/DecodeSpeech.txt"; my $peopleLocation = "/root/perl/./people.pl"; my $choice_result = "/root/perl/choice_result.txt"; my $line; my @field; my ($i, $a, $user, $res, $input); my $decoded; my @getChoices; my @results; my $read; my $count =0; my $getChoice; ## Getting Info whether user wants to search by First of Last Name. Here we are # getting info of which option the user wants to search by, either by search through # first name, getFirstChar or by searching through last name, getLastChar. open (CH, $choice_result) || die "Cannot open $choice_result for reading: $!"; while (){ chomp; $getChoice = "$_"; } close (CH); # Runs the record program to record wav files record_wav(); # Runs the wav to raw scrip that will change wav files into raw # files and place the raw files into raw files directory wav_to_raw(); # after recording, should see whether or not there is another raw file, # if there is, then add string function would put both raw files together # to run through as one raw file. if (-e $raw_dir_rec){ add_string(); } # Get speech by runing the file get_speech.pl get_speech(); # Opens decoded speech file from ASR sphinx log file and matching and split # Commands are used to strip unwanted namings, and get back string of decoded # speech into text open (IN, $DecodedSpeech) || die "Cannot open $DecodedSpeech for reading: $!"; while (){ chomp; $line ="$_"; $line =~ s/FWDVIT: +//; $line =~ s/\(null\)//; @field = split (/ / , $line); $decoded = join ("",@field); ########################################################################### # Option: Play_wav() that would enalble user to hear what the user said # # if the user chooses to do so # plays what currently user said play new string #play_wav(); # # ########################################################################### # For the decoded text, it connects to ADB and it to get back namess so here # we are connecting to database through db.pm, and getting back info through # people.pm and people.pl print "\nDecoded as ", $decoded, ": "; system ("$peopleLocation $getChoice $decoded"); ################################################################################### # If USER want more interaction, to display whether or not command was right # # $user = # chomp ($user); # if ($user =~ /^[yY]/){ # #want it to connect to DB and try to match by getfirstchar of @field # system ("$peopleLocation $getChoice $decoded"); # }else { # print "\nNo Results: Lets start over \n\n"; # system("./record_wav.pl");; # } # ################################################################################### close(IN); } }