I wanted to be able to click "play" and have the program directly output the audio to a game or voice chat program.
To do this, I added a drop down menu where you can choose the playback device, and it will output the audio to whatever device is selected.
So now you can use this in conjuction with virtual audio cable to talk with TTS in games.
The only real changes were Form1.cs line 169 - 175, 216-217, 220, 225:
The Form1_Load function is changed to load up the new combo box with the user's sound devices:
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < WaveOut.DeviceCount; i++)
{
WaveOutCapabilities WOC = WaveOut.GetCapabilities(i);
comboBox2.Items.Add(WOC.ProductName);
}
}
the play button function now passes in whatever was selected from the new combo box:
private void button2_Click(object sender, EventArgs e)
{
string link = "";
switch (comboBox1.GetItemText(comboBox1.SelectedItem))
{
case "WillFromAfar":
link = Parse(textBox1.Text, "willfromafar22k_hq");
break;
case "WillLittleCreature":
link = Parse(textBox1.Text, "willlittlecreature22k_hq");
break;
}
if (link == "")
{
MessageBox.Show("Can't download. Maybe this voice is paid.");
return;
}
int id = comboBox2.SelectedIndex; //added to get the id from the box
Task.Run(() => Playsnd(link, id)); //now passes in the id to the play function
}
and the Playsnd function would now take in the device id and play it on that device:
void Playsnd(string link, int WaveOutDeviceId) //now takes in a device id
{
using (var mf = new MediaFoundationReader(link))
using (var wo = new WaveOutEvent())
{
wo.DeviceNumber = WaveOutDeviceId; //sets the device id to the one passed in
wo.Init(mf);
wo.Play();
while (wo.PlaybackState == PlaybackState.Playing)
{
Thread.Sleep(1000);
}
}
}
Here's a picture of the updated window with the new drop down menu:
If you want, feel free to ignore this pull request and add those lines manually to the master, since my pull request has some other unnecessary changes from when I was first messing around with the code (just added/deleted whitespace, not actual functionality changes)
I wanted to be able to click "play" and have the program directly output the audio to a game or voice chat program.
To do this, I added a drop down menu where you can choose the playback device, and it will output the audio to whatever device is selected.
So now you can use this in conjuction with virtual audio cable to talk with TTS in games.
The only real changes were Form1.cs line 169 - 175, 216-217, 220, 225:
The Form1_Load function is changed to load up the new combo box with the user's sound devices:
the play button function now passes in whatever was selected from the new combo box:
and the Playsnd function would now take in the device id and play it on that device:
Here's a picture of the updated window with the new drop down menu:
https://i.imgur.com/qZhBjh2.png
If you want, feel free to ignore this pull request and add those lines manually to the master, since my pull request has some other unnecessary changes from when I was first messing around with the code (just added/deleted whitespace, not actual functionality changes)