static void Main(string[] args) { if (args.Length < 1 || args[0] == "listen") { Console.WriteLine("Listening"); Listen().Wait(); } else { Console.WriteLine("Hosting"); using (var tts = new FonixTalkEngine()) { var server = new WebSocketServer("ws://127.0.0.1:8181"); server.Start(socket => { socket.OnOpen = () => Console.WriteLine("Open!"); socket.OnClose = () => Console.WriteLine("Close!"); socket.OnMessage = message => tts.Speak(message); }); while (true) { if (Console.ReadKey() == new ConsoleKeyInfo('q', ConsoleKey.Q, false, false, false)) { return; } } } } }
static void speak(string msg) { using (var tts = new FonixTalkEngine()) { System.Collections.Specialized.NameValueCollection list = HttpUtility.ParseQueryString(msg); string message = list["msg"]; string ckey = list["ckey"]; ckey = ckey.Replace(System.Environment.NewLine, string.Empty); ckey = ckey.Replace("\r", string.Empty); message = HttpUtility.HtmlDecode(message); Console.WriteLine($"{message} {ckey} length:{ckey.Length}"); foreach (char c in ckey) { Console.WriteLine(System.Convert.ToInt32(c)); } try { tts.SpeakToWavFile($"sound\\playervoices\\{ckey}.wav", message); } catch { Console.WriteLine("Failed"); } Process process = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.FileName = "OggEnc.exe"; startInfo.Arguments = $"sound\\playervoices\\{ckey}.wav"; process.StartInfo = startInfo; process.Start(); } }
public static void PLEASE_TalkToWav(string fileName, string text) { using (var tts = new FonixTalkEngine()) { // tts.Voice = (TtsVoice)Enum.Parse(typeof(TtsVoice), VoiceSelector.Text); tts.SpeakToWavFile(fileName, text); } }
static void Main(string[] args) { Console.Title = "SharpTalk Speaking Terminal"; using (var tts = new FonixTalkEngine()) { string msg; while ((msg = Console.ReadLine()) != "exit") { tts.Speak(msg); } } }
// Start is called before the first frame update void Start() { textInput = GetComponent <InputField>(); tts = new FonixTalkEngine(); //using (var tts = new FonixTalkEngine()) //{ // string msg; // while ((msg = Console.ReadLine()) != "exit") // { // tts.Speak(msg); // } //} //phoneme<duration,pitch> }
public FonixModule() : base("fonix") { Get["speak"] = request => { using (var talkEngine = new FonixTalkEngine()) { var ms = new MemoryStream(); string encodedText = Request.Query.text; string rawText = HttpUtility.UrlDecode(encodedText).Replace(' ', '+'); var rawBytes = Convert.FromBase64String(rawText); string text = Encoding.UTF8.GetString(rawBytes); talkEngine.SpeakToWavStream(ms, text); ms.Position = 0; return(Response.FromStream(ms, "audio/wav;codec=pcm;rate=11025;bitrate=16"));//.WithHeader("Content-Disposition", "attachment; filename = file.wav"); } }; }
static void speak(string msg) { using (var tts = new FonixTalkEngine()) { System.Collections.Specialized.NameValueCollection list = HttpUtility.ParseQueryString(msg); string message = list["msg"]; string ckey = list["ckey"]; ckey = ckey.Replace(System.Environment.NewLine, string.Empty); ckey = ckey.Replace("\r", string.Empty); message = HttpUtility.HtmlDecode(message); try { tts.SpeakToWavFile(string.Format("sound\\playervoices\\{0}.wav", ckey), message); } catch { Console.WriteLine("Failed"); } } }
private void Button_Click(object sender, RoutedEventArgs e) { try { System.Windows.Controls.Button button = (System.Windows.Controls.Button)sender; switch (button.Name) { case "Ab0rt": break; case "IsraelNuke": var text = Richy.Text; if (MoonbaseCheckbox.IsChecked == true) { text = memetext(text); } //save as a sound file const string abusedFile = "abusedFile.wav"; using (var tts = new FonixTalkEngine()) { tts.Voice = (TtsVoice)Enum.Parse(typeof(TtsVoice), VoiceSelector.Text); tts.SpeakToWavFile(abusedFile, text); } if (LucciHear.IsChecked == true) { Console.WriteLine("how the f**k ise this happen?"); //System.IO.File.Copy(abusedFile, "copyboy", true); //playback on speaker string SelectedName = abusedFile; Thread thread = new Thread(new ParameterizedThreadStart((__SelectedName) => { string _SelectedName = (string)__SelectedName; //https://github.com/naudio/NAudio try { using (var audioFile = new AudioFileReader(_SelectedName)) { int selDevice = -1; { for (int n = -1; n < WaveOut.DeviceCount; n++) { var caps = WaveOut.GetCapabilities(n); if (caps.ProductName.StartsWith(CURRENT_SPEAKER_VALUE)) { selDevice = n; break; } } } Console.WriteLine("ree+ " + selDevice); using (var outputDevice = new WaveOutEvent() { DeviceNumber = selDevice }) { outputDevice.Init(audioFile); outputDevice.Volume = (float)percentagevolume; outputDevice.Play(); while (outputDevice.PlaybackState == PlaybackState.Playing) { Thread.Sleep(1000); } } } } catch (System.Runtime.InteropServices.COMException e3) { Console.WriteLine(e3); } })); thread.Start(SelectedName); } ////////// //now output from the sound file using (var audioFile = new AudioFileReader(abusedFile)) { int selDevice = -1; { Console.WriteLine("THIS SHOULD BE FIRST"); for (int n = -1; n < WaveOut.DeviceCount; n++) { var caps = WaveOut.GetCapabilities(n); Console.WriteLine(caps.ProductName + ", " + CURRENT_MIC_VALUE); if (caps.ProductName.StartsWith(CURRENT_MIC_VALUE)) { selDevice = n; break; } } } using (var outputDevice = new WaveOutEvent() { DeviceNumber = selDevice }) { // PressAppropriatePTTButton(true); outputDevice.Init(audioFile); outputDevice.Volume = (float)percentagevolume; outputDevice.Play(); while (outputDevice.PlaybackState == PlaybackState.Playing) { Thread.Sleep(1000); } // PressAppropriatePTTButton(false); } } break; } }catch (Exception exception) { Log("ERROR:" + exception.Message + ": " + exception.StackTrace); } }
private void PopDownAttachBoy() { if (sm_kp != _sm_kp.TTSMODE) { return; } attachboy.Hide(); sm_kp = _sm_kp.NORMAL; attachboy.hwndobject.SendMessage(WindowScrape.Constants.WM.ACTIVATE, 0, 0); attachboy.hwndobject.SendMessage(WindowScrape.Constants.WM.SETFOCUS, 0, 0); //now speak the text!) string text = (string)(attachboy.StebinTextBox.Text); // hwndobject. if (text == "") { return; } if (MoonbaseCheckbox.IsChecked == true) { text = memetext(text); } PressAppropriatePTTButton(true); new Thread(new ThreadStart(() => { //save as a sound file const string abusedFile = "abusedFile_overlay.wav"; using (var tts = new FonixTalkEngine()) { tts.Voice = (TtsVoice)Enum.Parse(typeof(TtsVoice), CURRENT_VOICESELECTOR_VALUE); tts.SpeakToWavFile(abusedFile, text); } if (OVERLAYPLAYBACKCHECKBOXCHECKED) { //System.IO.File.Copy(abusedFile, "copyboy", true); //playback on speaker string SelectedName = abusedFile; Thread thread = new Thread(new ParameterizedThreadStart((__SelectedName) => { string _SelectedName = (string)__SelectedName; //https://github.com/naudio/NAudio try { using (var audioFile = new AudioFileReader(_SelectedName)) { int selDevice = -1; { for (int n = -1; n < WaveOut.DeviceCount; n++) { var caps = WaveOut.GetCapabilities(n); if (caps.ProductName.StartsWith(CURRENT_SPEAKER_VALUE)) { selDevice = n; break; } } } using (var outputDevice = new WaveOutEvent() { DeviceNumber = selDevice }) { outputDevice.Init(audioFile); outputDevice.Volume = (float)percentagevolume; outputDevice.Play(); while (outputDevice.PlaybackState == PlaybackState.Playing) { Thread.Sleep(1000); } } } } catch (System.Runtime.InteropServices.COMException e3) { Console.WriteLine(e3); } })); thread.Start(SelectedName); } ////////// //now output from the sound file using (var audioFile = new AudioFileReader(abusedFile)) { int selDevice = -1; { for (int n = -1; n < WaveOut.DeviceCount; n++) { var caps = WaveOut.GetCapabilities(n); if (caps.ProductName.StartsWith(CURRENT_MIC_VALUE)) { selDevice = n; break; } } } using (var outputDevice = new WaveOutEvent() { DeviceNumber = selDevice }) { outputDevice.Init(audioFile); outputDevice.Volume = (float)percentagevolume; outputDevice.Play(); while (outputDevice.PlaybackState == PlaybackState.Playing) { Thread.Sleep(1000); } PressAppropriatePTTButton(false); } } })).Start(); }
public void Button_Click(object o, RoutedEventArgs e) { Button b = (Button)o; switch (b.Name) { case "GoButton": string text = TextBoxHandle.Text; TextBoxHandle.Text = ""; Console.WriteLine(text); if ((automeme.IsChecked == true)) { text = memetext(text); } //save as a sound file const string fileName = "abusedFile.wav"; /*using (var reader = new SpeechSynthesizer()) * { * foreach (var x in reader.GetInstalledVoices()) * Console.WriteLine(x.VoiceInfo.Name); * reader.Rate = (int)-2; * reader.SetOutputToWaveFile(fileName); * //https://stackoverflow.com/questions/16021302/c-sharp-save-text-to-speech-to-mp3-file * reader.Speak(text); * }*/ using (var tts = new FonixTalkEngine()) { tts.Voice = (TtsVoice)Enum.Parse(typeof(TtsVoice), VoiceSelector.Text); tts.SpeakToWavFile(fileName, text); } ////////// //now output from the sound file using (var audioFile = new AudioFileReader(fileName)) { int selDevice = -1; for (int n = -1; n < WaveOut.DeviceCount; n++) { var caps = WaveOut.GetCapabilities(n); if (caps.ProductName.Contains("CABLE Input")) { selDevice = n; break; } } using (var outputDevice = new WaveOutEvent() { DeviceNumber = selDevice }) { outputDevice.Init(audioFile); outputDevice.Volume = (float)percentagevolume; outputDevice.Play(); while (outputDevice.PlaybackState == PlaybackState.Playing) { Thread.Sleep(1000); } } } break; case "CloseButton": Environment.Exit(0); break; } }
static void Main(string[] args) { if (AlreadyRunning()) { Environment.Exit(0); } fte = new FonixTalkEngine(); /* Create data folder */ if (!Directory.Exists(data_folder)) { Directory.CreateDirectory(data_folder); } DirectoryInfo di = new DirectoryInfo(data_folder); /* Empty out the data folder */ foreach (FileInfo fi in di.GetFiles()) { if (fi.Extension == ".wav" || fi.Extension == ".ogg" || fi.Extension == ".tmp" || fi.Extension == ".meta" || fi.Extension == ".request" || fi.Extension == ".rlock") { fi.Delete(); } } while (true) { /* Hacky but wait a lil before trying again */ System.Threading.Thread.Sleep(10); try { if (fte == null) { fte = new FonixTalkEngine(); } List <string> requests = findRequests(); while (requests.Count > 0) { string working_file = requests[0]; requests.RemoveAt(0); if (String.IsNullOrEmpty(working_file)) { continue; } if (!File.Exists(working_file)) { continue; } string name = ""; /* Open the request * * We should see three lines: * name=123johnfg * voice=paul * text=hello world */ StreamReader sr = new StreamReader(working_file); string line = ""; if (sr != null) { string text = ""; TtsVoice?voice = null; while ((line = sr.ReadLine()) != null) { Match match = null; if ((match = Regex.Match(line, regex_voice)).Length > 0) { voice = checkVoice(match.Groups["voice"].Value); continue; } if ((match = Regex.Match(line, regex_text)).Length > 0) { text = match.Groups["text"].Value; continue; } if ((match = Regex.Match(line, regex_name)).Length > 0) { name = match.Groups["name"].Value; continue; } } if (!String.IsNullOrEmpty(name) && !String.IsNullOrEmpty(text)) { generateTTS(voice, text, Path.Combine(data_folder, name)); } sr.Close(); } /* Delete the request file */ File.Delete(working_file); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } }