Ejemplo n.º 1
0
        public byte[] GenerateSound(string str)
        {
            List <byte[]> sound = new List <byte[]>();

            str = str.ToLower();
            var lastPhonem = "";

            for (int i = 0; i < str.Length; i++)
            {
                if (!_stopSounds.Contains(lastPhonem))
                {
                    try
                    {
                        var newSound = _sounds[Convert(lastPhonem + str[i])];
                    }
                    catch (Exception ex)
                    {
                        sound.Add(_sounds[Convert(lastPhonem)]);
                        lastPhonem = "";
                    }
                }
                else
                {
                    lastPhonem = "";
                }
                lastPhonem += str[i];
            }
            try
            {
                sound.Add(_sounds[Convert(lastPhonem)]);
            }
            catch (Exception ex) { }
            return(WaveIO.Merge(sound));
        }
Ejemplo n.º 2
0
            public static byte[] Merge(List <byte[]> files)
            {
                WaveIO wa_IN  = new WaveIO();
                WaveIO wa_out = new WaveIO();

                wa_out.DataLength = 0;
                wa_out.length     = 0;


                //Gather header data
                foreach (byte[] file in files)
                {
                    wa_IN.WaveHeaderIN(file);
                    wa_out.DataLength += wa_IN.DataLength;
                    wa_out.length     += wa_IN.length;
                }
                byte[] outFile = new byte[wa_out.DataLength];
                //Recontruct new header
                wa_out.BitsPerSample = wa_IN.BitsPerSample;
                wa_out.channels      = wa_IN.channels;
                wa_out.samplerate    = wa_IN.samplerate;
                outFile = wa_out.WaveHeaderOUT().Concat(outFile).ToArray();
                var pos = 44;

                foreach (byte[] file in files)
                {
                    MemoryStream ms      = new MemoryStream(file);
                    byte[]       arrfile = new byte[ms.Length - 44];
                    ms.Position = 44;
                    ms.Read(arrfile, 0, arrfile.Length);
                    ms.Close();

                    ms          = new MemoryStream(outFile);
                    ms.Position = pos;
                    BinaryWriter bw = new BinaryWriter(ms);
                    bw.Write(arrfile);
                    bw.Close();
                    pos += arrfile.Length;
                    ms.Close();
                }
                return(outFile);
            }
Ejemplo n.º 3
0
        private void c1Button7_Click(object sender, EventArgs e)
        {
            //mciSendString("Close MyMp3", tmpBuffer, 0, 0);
            String pathfile = "";

            pathfile = System.IO.Path.GetDirectoryName(Application.ExecutablePath);

            string tmpFilename = pathfile + "\\sound\\sample.mp3";

            tmpFilename = pathfile + "\\sound\\invite_number.wav";
            arrPlay.Add(tmpFilename);
            tmpFilename = pathfile + "\\sound\\a.wav";
            arrPlay.Add(tmpFilename);
            tmpFilename = pathfile + "\\sound\\0.wav";
            arrPlay.Add(tmpFilename);
            tmpFilename = pathfile + "\\sound\\0.wav";
            arrPlay.Add(tmpFilename);
            tmpFilename = pathfile + "\\sound\\0.wav";
            arrPlay.Add(tmpFilename);
            tmpFilename = pathfile + "\\sound\\1.wav";
            arrPlay.Add(tmpFilename);
            tmpFilename = pathfile + "\\sound\\at_slot.wav";
            arrPlay.Add(tmpFilename);
            tmpFilename = pathfile + "\\sound\\4.wav";
            arrPlay.Add(tmpFilename);
            tmpFilename = pathfile + "\\sound\\ka.wav";
            arrPlay.Add(tmpFilename);
            WaveIO wa = new WaveIO();

            wa.Merge(arrPlay, pathfile + "\\sound\\sound.wav");
            //MemoryStream sound  wa.MergetoStream(arrPlay);

            //MemoryStream stream = bqc.CombineFileStrean(arrPlay);
            //stream.Position = 0;
            //SoundPlayer sound = new SoundPlayer(stream);
            SoundPlayer sound1 = new SoundPlayer(pathfile + "\\sound\\sound.wav");

            sound1.Play();
            sound1.Dispose();
        }