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); }
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; }
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); }