예제 #1
1
        public void run(string text)
        {
          iSpeechSynthesis iSpeech=  new iSpeechSynthesis(_api, _production);

           iSpeech.setVoice("usenglishfemale");
           iSpeech.setOptionalCommands("format", "mp3");
            
           TTSResult result = iSpeech.speak(text);         
            
           byte [] audioData = new byte[result.getAudioFileLength()];

           int read = 0;
           int totalRead = 0;

           while (totalRead < audioData.Length)
           {
               read = result.getStream().Read(audioData, totalRead, audioData.Length - totalRead);
               totalRead += read;
           }


           FileStream fs = new FileStream("audio.mp3", FileMode.Create);
           BinaryWriter bw = new BinaryWriter(fs);

           bw.Write(audioData, 0, audioData.Length);           

        }
예제 #2
0
        static public string Synthesis(string text)
        {
            string FileName = Path.GetTempFileName()+".mp3";

            bool production = true;
            iSpeechSynthesis iSpeech = new iSpeechSynthesis(api_key, production);

            iSpeech.setVoice("usenglishfemale");
            iSpeech.setOptionalCommands("format", "mp3");
            iSpeech.setOptionalCommands("speed", "-5");
            TTSResult result = iSpeech.speak(text);

            byte[] audioData = new byte[result.getAudioFileLength()];

            int read = 0;
            int totalRead = 0;

            while (totalRead < audioData.Length)
            {
                read = result.getStream().Read(audioData, totalRead, audioData.Length - totalRead);
                totalRead += read;
            }

            FileStream fs = new FileStream(FileName, FileMode.Create);
            BinaryWriter bw = new BinaryWriter(fs);

            bw.Write(audioData, 0, audioData.Length);

            return FileName;
        }
예제 #3
0
        public void run(string text)
        {
            iSpeechSynthesis iSpeech = new iSpeechSynthesis(_api, _production);

            iSpeech.setVoice("usenglishfemale");
            iSpeech.setOptionalCommands("format", "mp3");

            TTSResult result = iSpeech.speak(text);

            byte [] audioData = new byte[result.getAudioFileLength()];

            int read      = 0;
            int totalRead = 0;

            while (totalRead < audioData.Length)
            {
                read       = result.getStream().Read(audioData, totalRead, audioData.Length - totalRead);
                totalRead += read;
            }


            FileStream   fs = new FileStream("audio.mp3", FileMode.Create);
            BinaryWriter bw = new BinaryWriter(fs);

            bw.Write(audioData, 0, audioData.Length);
        }