当前位置: 首页>>代码示例>>C#>>正文


C# WaveFileReader.CopyTo方法代码示例

本文整理汇总了C#中NAudio.Wave.WaveFileReader.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# WaveFileReader.CopyTo方法的具体用法?C# WaveFileReader.CopyTo怎么用?C# WaveFileReader.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NAudio.Wave.WaveFileReader的用法示例。


在下文中一共展示了WaveFileReader.CopyTo方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertWavToMp3

 public static void ConvertWavToMp3(string WavFile, string outPutFile)
 {
     CheckAddBinPath();
     WaveFileReader rdr = new WaveFileReader(WavFile);
     using (var wtr = new LameMP3FileWriter(outPutFile, rdr.WaveFormat, 128))
     {
         rdr.CopyTo(wtr);
         rdr.Dispose();
         wtr.Dispose();
         return;
     }
 }
开发者ID:Qder,项目名称:MusicEditor,代码行数:12,代码来源:WavFileUtils.cs

示例2: WavToMP3

        /// <summary>
        ///  Convert WAV to MP3 using libmp3lame library
        /// </summary>
        /// <param name="waveFileName">WAV filename</param>
        /// <param name="mp3FileName">MP3 filename</param>
        /// <param name="bitRate">Bit rate, default 128</param>
        /// <param name="artist">Optional artist name</param>
        /// <param name="album">Optional album name</param>
        /// <param name="setID3Tags">Set ID3 tags</param>
        public static bool WavToMP3(string waveFileName, string mp3FileName, int bitRate = 128, string artist = null, string album = null, bool setID3Tags = false, string genre = "148")
        {
            bool result = true;
            try
            {
                ID3TagData tags = new ID3TagData();
                if (setID3Tags)
                {
                    if (!String.IsNullOrEmpty(artist))
                    {
                        tags.Artist = artist;
                        tags.Album = album;
                        tags.Genre = genre;
                    }
                }

                using (var reader = new WaveFileReader(waveFileName))
                using (var writer = new LameMP3FileWriter(mp3FileName, reader.WaveFormat, bitRate, tags))
                    reader.CopyTo(writer);

            }
            catch (Exception)
            {
                result = false;
            }

            return result;
        }
开发者ID:simondgh,项目名称:WavToMP3,代码行数:37,代码来源:Form1.cs

示例3: ConvertWavStreamToMp3File

        public static void ConvertWavStreamToMp3File(ref MemoryStream ms, string savetofilename)
        {
            //rewind to beginning of stream
            ms.Seek(0, SeekOrigin.Begin);

            using (var retMs = new MemoryStream())
            using (var rdr = new WaveFileReader(ms))
            using (var wtr = new LameMP3FileWriter(savetofilename, rdr.WaveFormat, LAMEPreset.VBR_90))
            {
                rdr.CopyTo(wtr);
            }
        }
开发者ID:cjerome04,项目名称:TTSServiceSonos,代码行数:12,代码来源:Mp3Helpers.cs

示例4: ConvertWavStreamToMp3File

        public static void ConvertWavStreamToMp3File(Configuration cfg, ref MemoryStream ms, string savetofilename)
        {
            //rewind to beginning of stream
            ms.Seek(0, SeekOrigin.Begin);

            using (var retMs = new MemoryStream())
            {
                using (var rdr = new WaveFileReader(ms))
                {
                    using (var wtr = new LameMP3FileWriter(savetofilename, rdr.WaveFormat, cfg.MP3BitRate))
                    {
                        rdr.CopyTo(wtr);
                        wtr.Close();
                    }

                    rdr.Close();

                    Console.WriteLine(savetofilename + " ok.");
                }
            }
        }
开发者ID:gnagypal,项目名称:Anki,代码行数:21,代码来源:Program.cs

示例5: WaveToMP3

 // Convert WAV to MP3 using libmp3lame library
 public static void WaveToMP3(string waveFileName, string mp3FileName, int bitRate = 128)
 {
     using (var reader = new WaveFileReader(waveFileName))
     using (var writer = new LameMP3FileWriter(mp3FileName, reader.WaveFormat, bitRate))
         reader.CopyTo(writer);
 }
开发者ID:connecticutortho,项目名称:ct-ortho-repositories4,代码行数:7,代码来源:Program.cs

示例6: Recognize

 public void Recognize(string path) {
   Log("Recognize: " + Path.GetFullPath(path));
   if (!File.Exists(path)) { return; }
   using (var reader = new WaveFileReader(path)) {
     var tmp = buffer.Position;
     reader.CopyTo(buffer);
     buffer.Position = tmp;
   }
 }
开发者ID:JpEncausse,项目名称:SARAH-Client-Windows,代码行数:9,代码来源:OSManager.cs

示例7: ConvertWavStreamToMp3File

        private void ConvertWavStreamToMp3File(ref MemoryStream ms, string savetofilename)
        {
            ms.Seek(0, SeekOrigin.Begin);

            using (var rdr = new WaveFileReader(ms))
            using (var wtr = new LameMP3FileWriter(savetofilename, rdr.WaveFormat, LAMEPreset.VBR_90))
            {
                rdr.CopyTo(wtr);
            }
        }
开发者ID:olathunberg,项目名称:RecordToMP3,代码行数:10,代码来源:Recorder.cs

示例8: WriteMP3

        // Writes wave memorystream out to a file.
        private void WriteMP3(byte[] wave, string file)
        {
            string outputFile = file;

            if (File.Exists(outputFile))
            {
                outputFile = this.GetAlternatePath(outputFile);
            }

            using (MemoryStream waveMemoryStream = new MemoryStream(wave))
            {
                using (WaveFileReader reader = new WaveFileReader(waveMemoryStream))
                {
                    using (LameMP3FileWriter writer = new LameMP3FileWriter(outputFile, reader.WaveFormat, LAMEPreset.V4))
                    {
                        reader.CopyTo(writer);
                    }
                }
            }
        }
开发者ID:etray,项目名称:NCorder,代码行数:21,代码来源:MP3Writer.cs

示例9: ConvertWavToMp3

 //this method takes an actual wav file and converts it
 public static byte[] ConvertWavToMp3(string wavFile, bool deleteWavAfter)
 {
     byte[] mp3bytes = null;
     try
     {
         using (var retMs = new MemoryStream())
         using (var rdr = new WaveFileReader(wavFile))
         using (var wtr = new LameMP3FileWriter(retMs, rdr.WaveFormat, bitRate))
         {
             rdr.CopyTo(wtr);
             mp3bytes = retMs.ToArray();
         }
         if(deleteWavAfter)
         {
             File.Delete(wavFile);
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e);
     }
     return mp3bytes;
 }
开发者ID:Tomiscout,项目名称:SoundCloud-Playlist-Sync,代码行数:24,代码来源:audioConverter.cs

示例10: DownloadAndPlayItem

        public override void DownloadAndPlayItem(PhraseItem item, string folder)
        {
            String SSMLText = String.Format(@"<?xml version=""1.0""?>
            <speak xmlns=""http://www.w3.org/2001/10/synthesis"" version=""1.0"" xml:lang=""{1}"">
            <p>
            <s>{0}</s>
            </p>
            </speak>
            ", item.Phrase.Replace("&", "&amp;"), SelectedVoice.Language);

            try
            {
                new Task(() =>
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        ms.Seek(0, SeekOrigin.Begin);
                        using (var synth = new SpeechSynthesizer())
                        {
                            synth.SelectVoice(SelectedVoice.Name);
                            synth.Volume = Int32.Parse(SelectedDiscreteVolume);
                            synth.Rate = Int32.Parse(SelectedDiscreteSpeed);
                            synth.SetOutputToWaveStream(ms);//.SetOutputToWaveFile(String.Format("{0}\\wav22050\\{1}\\{2}.wav", folder, item.Folder, item.FileName));
                            synth.SpeakSsml(SSMLText);
                        }
                        ms.Seek(0, SeekOrigin.Begin);
                        using (WaveFileReader wav = new WaveFileReader(ms))// String.Format("{0}\\wav22050\\{1}\\{2}.wav", folder, item.Folder, item.FileName)))
                        {
                            using (FileStream fs = new FileStream(String.Format("{0}\\mp3\\{1}\\{2}.mp3", folder, item.Folder, item.FileName), FileMode.Create))
                            {
                                using (var writer = new LameMP3FileWriter(fs, wav.WaveFormat, 128))
                                {
                                    wav.CopyTo(writer);
                                }
                            }
                        }
                        ms.Seek(0, SeekOrigin.Begin);
                        using (WaveFileReader wav = new WaveFileReader(ms))// String.Format("{0}\\wav22050\\{1}\\{2}.wav", folder, item.Folder, item.FileName)))
                        {
                            ConvertToWav(item, folder, true, new String[] { Name, SelectedVoice.Name, SelectedDiscreteSpeed, SelectedDiscreteVolume });
                        }
                    }
                }).Start();
            }
            catch (Exception Ex)
            {
                Logger.Log(Ex.ToString());
            }
        }
开发者ID:CaffeineAU,项目名称:TTSTranslator,代码行数:49,代码来源:MicrosoftTTSProvider.cs

示例11: GenerateMp3File

        private static void GenerateMp3File(string filename = "output")
        {

            using (var reader = new WaveFileReader(GenerateMemoryStream()))
            using (var writer = new LameMP3FileWriter(filename + ".mp3", reader.WaveFormat, LAMEPreset.ABR_32))
                reader.CopyTo(writer);
        }
开发者ID:KR0SIV,项目名称:EAS-Encoder,代码行数:7,代码来源:EASEncoder.cs

示例12: ParseText


//.........这里部分代码省略.........
            string[] lines = Regex.Split(inputText, "\n");

            List<string> sentences = new List<string>();
            List<string> symbols = new List<string>();
            List<bool> quotes = new List<bool>();
            


            foreach (string line in lines)
            {

                if (line.Length == 1 && line.GetHashCode() == -842352733)
                    continue;
                else if (line.Length == 0)
                    continue;

                DeleteOperation operation = DeleteOperation.None;
                foreach (KeyValuePair<string, DeleteOperation> kvp in deleteDictionary)
                {
                    if (line.Contains(kvp.Key))
                    {
                        operation = kvp.Value;
                        break;
                    }
                }

                if (operation == DeleteOperation.DeleteAllAfter)
                    break;
                else if (operation == DeleteOperation.DeleteLine)
                    continue;


                string[] quoteSplit = Regex.Split(line, "\"");

                for (int q = 0; q < quoteSplit.Length; q++)
                {
                    bool quoted = q % 2 == 1 ? true : false;
                    string[] parts = Regex.Split(quoteSplit[q], "([,…。:?!])");

                    string sentence = "";
                    string symbol = "";
                    
                    //Console.WriteLine("======" + parts.Length);
                    for (int i = 0; i < parts.Length; i++)
                    {
                        if (parts[i].Length == 0)
                            continue;
                        sentence = parts[i];

                        while (i + 1 < parts.Length)
                        {
                            //Console.WriteLine("Symbol " + parts[i + 1] + " " + parts[i + 1].GetHashCode());
                            if (parts[i + 1].GetHashCode() == 757602046)
                            {
                                i++;
                                continue;
                            }
                            if (",…。:?!".Contains(parts[i + 1]))
                            {
                                symbol += parts[i + 1];
                                i++;
                                continue;
                            }
                            break;
                        }
                        if (symbol.Length == 0)
                            symbol = "。";

                        //BuildPrompt(sentence, symbol, quoted);
                        sentences.Add(sentence);
                        symbols.Add(symbol);
                        quotes.Add(quoted);
                        sentence = "";
                        symbol = "";
                    }

                }
            }

            for (int i = 0; i < sentences.Count; i++)
            {
                BuildPrompt(sentences[i], symbols[i], quotes[i]);
                int percent = (int)(100.0f * (float)(i + 1) / (float)sentences.Count);
                //Console.Write("\r " + fileName + " Progress: {0}%   ", percent);
                Console.WriteLine(percent);
            }

            if (outputFileLocation != null)
            {
                ms.Seek(0, SeekOrigin.Begin);

                //Convert from wav to mp3 to save space
                using (var rdr = new WaveFileReader(ms))
                using (var wtr = new LameMP3FileWriter(outputFileLocation, rdr.WaveFormat, LAMEPreset.VBR_90))
                {
                    rdr.CopyTo(wtr);
                }
            }

        }
开发者ID:TheTerribleChild,项目名称:Windows-Novel-Reader,代码行数:101,代码来源:MandarinPromptSpeaker.cs

示例13: ReadFileAndConvertToMp3

        private byte[] ReadFileAndConvertToMp3()
        {
            using (var reader = new WaveFileReader(this._fileName))
            using (var result = new MemoryStream())
            using (var mp3Writer = new LameMP3FileWriter(result, reader.WaveFormat, (int)this._settings.BitRate))
            {
                if (reader.TotalTime.TotalSeconds <= this._settings.SecondsToSkipSongsUnder)
                    return new byte[0];

                reader.CopyTo(mp3Writer);
                return result.ToArray();
            }
        }
开发者ID:haefele,项目名称:SpotifyRecorder,代码行数:13,代码来源:AudioRecorder.cs


注:本文中的NAudio.Wave.WaveFileReader.CopyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。