Exemple #1
0
        private int typesOfErrors = 2; // shyness and eagerness, can be changed if more different types of errors are found

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="M_speakers">Number of speakers</param>
        /// <param name="M_word_types">Number of word types</param>
        /// <param name="M_sample">Number of samples per word type per speaker</param>
        /// <param name="d">audio data</param>
        /// <param name="grammar_directory">output directory of created grammars</param>
        /// <param name="input">grammar file input</param>
        /// <param name="number_of_alternates">number of alternative pronunciations</param>
        /// <param name="r">number of repeats</param>
        public Tester(int M_speakers, int M_word_types, int M_sample, Data d, string grammar_directory, GrammarReader input, int number_of_alternates, int r)
        {
            MWordTypes = M_word_types;
            MSample = M_sample;
            MSpeakers = M_speakers;
            data = d;
            grammarDirectory = grammar_directory;
            this.input = input;
            numberOfAlternates = number_of_alternates;
            repeats = r;
            // initialize output
            SampleAccuracy = new Fraction[MSpeakers - 1, MSample, V.Length, MSpeakers, MWordTypes, MSample];
            WordTypeAccuracy = new Fraction[MSpeakers - 1, MSample, V.Length, MSpeakers, MWordTypes];
            OverallWordTypeAccuracy = new Fraction[MSpeakers - 1, MSample, V.Length, MWordTypes];
            OverallAccuracy = new Fraction[MSpeakers-1, MSample, V.Length];
            SampleDeviation = new List<int>[MSpeakers-1,MSample, MSpeakers, MWordTypes];
            ConfusionMatrix = new Fraction[MSpeakers - 1, MSpeakers, MWordTypes * MSample, (numberOfAlternates * MWordTypes) + 1];
            ErrorRates = new Fraction[MSpeakers - 1, MSpeakers, typesOfErrors, (numberOfAlternates * MWordTypes)];

            for (int NTrainingSpeakersIndex = 0; NTrainingSpeakersIndex < MSpeakers - 1; NTrainingSpeakersIndex++)
            {
                for (int NTrainingSamplesPerSpeakerIndex = 0; NTrainingSamplesPerSpeakerIndex < MSample; NTrainingSamplesPerSpeakerIndex++)
                {
                    for (int vocabSizeIndex = 0; vocabSizeIndex < V.Length; vocabSizeIndex++)
                    {
                        OverallAccuracy[NTrainingSpeakersIndex, NTrainingSamplesPerSpeakerIndex, vocabSizeIndex] = new Fraction();
                        for (int iTestSpeakerIndex = 0; iTestSpeakerIndex < MSpeakers; iTestSpeakerIndex++)
                        {
                            for (int iWordTypeIndex = 0; iWordTypeIndex < MWordTypes; iWordTypeIndex++)
                            {
                                WordTypeAccuracy[NTrainingSpeakersIndex, NTrainingSamplesPerSpeakerIndex, vocabSizeIndex, iTestSpeakerIndex, iWordTypeIndex] = new Fraction();
                                OverallWordTypeAccuracy[NTrainingSpeakersIndex, NTrainingSamplesPerSpeakerIndex, vocabSizeIndex, iWordTypeIndex] = new Fraction();
                                SampleDeviation[NTrainingSpeakersIndex, NTrainingSamplesPerSpeakerIndex, iTestSpeakerIndex, iWordTypeIndex] = new List<int>();
                                for (int iSamplesIndex = 0; iSamplesIndex < MSample; iSamplesIndex++)
                                {
                                    SampleAccuracy[NTrainingSpeakersIndex, NTrainingSamplesPerSpeakerIndex, vocabSizeIndex, iTestSpeakerIndex, iWordTypeIndex, iSamplesIndex] = new Fraction();
                                }
                            }
                        }

                    }
                }
            }
            for (int NTrainingSpeakersIndex = 0; NTrainingSpeakersIndex < MSpeakers - 1; NTrainingSpeakersIndex++)
            {
                for (int iTestSpeakerIndex = 0; iTestSpeakerIndex < MSpeakers; iTestSpeakerIndex++)
                {
                    for (int i = 0; i < MSample*MWordTypes; i++)
                    {
                        for (int j = 0; j < (numberOfAlternates*MWordTypes) + 1; j++)
                        {
                            ConfusionMatrix[NTrainingSpeakersIndex, iTestSpeakerIndex, i, j] = new Fraction();
                            if ( i < typesOfErrors && j < numberOfAlternates*MWordTypes)
                                ErrorRates[NTrainingSpeakersIndex, iTestSpeakerIndex, i, j] = new Fraction();
                        }
                    }
                }
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            // speakers to be tested
            List<int> speakersToBeTested = new List<int>();
            speakersToBeTested.Add(0);
            speakersToBeTested.Add(1);
            speakersToBeTested.Add(2);

            // words to be tested
            List<int> wordsToBeTested = new List<int>();
            for (int i = 1; i <= 50; i += 5)
                wordsToBeTested.Add(i);
            //wordsToBeTested.Add(25);

            // samples to be tested
            List<int> samplesToBeTested = new List<int>();
            samplesToBeTested.Add(1);
            samplesToBeTested.Add(2);
            samplesToBeTested.Add(3);
            samplesToBeTested.Add(4);
            samplesToBeTested.Add(5);

            // audio directory
            List<string> audioDirectory = new List<string>();
            audioDirectory.Add("C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data\\audio\\092910_123758_Hebrew");
            audioDirectory.Add("C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data\\audio\\101410_140344_Hebrew");
            audioDirectory.Add("C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data\\audio\\101510_111237_Hebrew");
            // audio file names

            // audio file names
            List<string> audioFileNames = new List<string>();
            audioFileNames.Add("[Wed_(Sep_29_2010)_12-37-58]_4124143701_");
            audioFileNames.Add("[Thu_(Oct_14_2010)_14-03-44]_4122688595_");
            audioFileNames.Add("[Fri_(Oct_15_2010)_11-12-37]_4126203298_");

            GrammarReader gr = new GrammarReader("Hebrew", "C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data", "allcombinations");

            // set up data
            data = new Data(audioDirectory, audioFileNames, 5, speakersToBeTested, wordsToBeTested, samplesToBeTested,
               "C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data\\config_files\\config.txt.100.english");

            Tester t = new Tester(MSpeakers, MWordTypes, MSamples, data, directory,null,10, 1);
            t.runTestDiscriminative("multiList", new List<bool>(){true, true, true, true});
            //GrammarConverter gc = new GrammarConverter("Hebrew", "C:\\Users\\cheem\\Desktop\\SalaamTest", "allcombinations", 3, 5);
            //gc.convert();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            // words to be tested
            List<int> wordsToBeTested = new List<int>();
            for(int i = 1; i <= 100; i++)
               wordsToBeTested.Add(i);
            //wordsToBeTested.Add(1);

            // samples to be tested
            List<int> samplesToBeTested = new List<int>();
            samplesToBeTested.Add(1);
            samplesToBeTested.Add(2);
            samplesToBeTested.Add(3);
            samplesToBeTested.Add(4);
            samplesToBeTested.Add(5);

            // audio directory
            List<string> audioDirectory = new List<string>();
            audioDirectory.Add("C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data\\audio\\092910_123758_Hebrew");
            audioDirectory.Add("C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data\\audio\\101410_140344_Hebrew");
            audioDirectory.Add("C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data\\audio\\101510_111237_Hebrew");
            // audio file names
            List<string> audioFileNames = new List<string>();
            audioFileNames.Add("[Wed_(Sep_29_2010)_12-37-58]_4124143701_");
            audioFileNames.Add("[Thu_(Oct_14_2010)_14-03-44]_4122688595_");
            audioFileNames.Add("[Fri_(Oct_15_2010)_11-12-37]_4126203298_");

            for (int i = 0; i < 3; i++)
            {
                List<int> speakersToBeTested = new List<int>();
                speakersToBeTested.Add(i);
                // set up data
                data = new Data(audioDirectory, audioFileNames, 5, speakersToBeTested, wordsToBeTested, samplesToBeTested,
                    "C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data\\config_files\\config.txt.100.english");

                // setup grammar
                GrammarCreator gc = new GrammarCreator("C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data", "Hebrew", "allcombinations");

                // setup training
                TrainingAlgorithm ta = new TrainingAlgorithm(gc, data, 10, 15);

                ta.LearnAllWords();
            }
        }
Exemple #4
0
        static void Main(string[] args)
        {
            // speakers to be tested
            List<int> speakersToBeTested = new List<int>();
            speakersToBeTested.Add(0);
            speakersToBeTested.Add(1);
            speakersToBeTested.Add(2);

            // words to be tested
            List<int> wordsToBeTested = new List<int>();
            for (int i = 1; i <= 50; i += 5)
                wordsToBeTested.Add(i);
            //wordsToBeTested.Add(25);

            // samples to be tested
            List<int> samplesToBeTested = new List<int>();
            samplesToBeTested.Add(1);
            samplesToBeTested.Add(2);
            samplesToBeTested.Add(3);
            samplesToBeTested.Add(4);
            samplesToBeTested.Add(5);

            // audio directory
            List<string> audioDirectory = new List<string>();

            audioDirectory.Add("C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data\\audio\\092910_123758_Hebrew");
            audioDirectory.Add("C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data\\audio\\101410_140344_Hebrew");
            audioDirectory.Add("C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data\\audio\\101510_111237_Hebrew");
            // audio file names
            List<string> audioFileNames = new List<string>();
            audioFileNames.Add("[Wed_(Sep_29_2010)_12-37-58]_4124143701_");
            audioFileNames.Add("[Thu_(Oct_14_2010)_14-03-44]_4122688595_");
            audioFileNames.Add("[Fri_(Oct_15_2010)_11-12-37]_4126203298_");

            //GrammarReader gr = new GrammarReader("Hebrew", "C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data", "Allphone");

            // set up data
            data = new Data(audioDirectory, audioFileNames, 5, speakersToBeTested, wordsToBeTested, samplesToBeTested,
                "C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data\\config_files\\config.txt.100.english");

            TrainingAlgorithm ta = new TrainingAlgorithm(10, data, directory, MWordTypes, MSamples, MSpeakers, "C:\\Users\\Administrator\\Documents\\Visual Studio 2008\\Projects\\cmuspeechrecognition_cmuspeechmain\\test_data", 1, "eliminative");
            ta.trainWordsDiscriminativeEliminative();
        }
Exemple #5
0
        /// <summary>
        /// Given a list of speakers and the samples per speakers to train on, training is carried out to produce a List of pronunciations
        /// </summary>
        /// <param name="speakerList">list of speakers for training</param>
        /// <param name="sampleList">list of samples for training</param>
        /// <returns>List of pronunciations</returns>
        private Dictionary<string, List<string>> trainAllWords(List<int> speakerList, List<int> sampleList)
        {
            string speaker = "speaker-";
            for (int i = 0; i < speakerList.Count; i++)
            {
                speaker += speakerList[i].ToString()+"_";
            }
            string sample = "sample-";

            List<int> trueSampleList = new List<int>();
            trueSampleList.AddRange(sampleList);
            for (int i = 0; i < trueSampleList.Count; i++)
            {
                trueSampleList[i]++;
                sample += trueSampleList[i].ToString() + "_";
            }
            System.Diagnostics.Debug.WriteLine("training " + speaker +  sample);

            // words to be tested
            List<int> wordsToBeTested = new List<int>();
             for (int i = 1; i <= MWordTypes; i++)
                 wordsToBeTested.Add(i);

             // set up data
             Data tempData = new Data(data.audioDirectory, data.audioFileName, data.numberOfSamplesPerWord, speakerList, wordsToBeTested, trueSampleList,
                 data.wordListPath);

             // setup grammar
             GrammarCreator gc = new GrammarCreator(grammarDirectory, data.language + speaker + sample, "allcombinations");

             // setup training
             TrainingAlgorithm ta = new TrainingAlgorithm(gc, tempData, numberOfAlternates, 15);

             return ta.LearnAllWords();
        }