I'm trying to take text from a repository via a desktop application, create a waveout recording(not a file), and have it playback to both the caller and the customer. I can't seem to get it to work with headsets over VoIP and can't figure it out. It seems to be working fine in pretty much ever other scenario.
Example: Playback Tab Setup Recording Tab Setup
Both microphones are setup like this: Microphone Setup
The only way the waveout audio is heard by the customer is if the top microphone(Jabra Evolve 20) is disabled, or the headset is disconnected, but then the caller and I cannot communicate at all.
Leaving it as is, the customer and I can communicate, but the customer does not hear the waveout audio being played.
My Setup, which works without any issues: My Playback Tab My Recording Tab
Microphone is setup to listen and playback through Virtual Audio Cable. I'm able to dial out to my cell or anyone else's phone and play the audio without any issues. We can both hear each other fine and the waveout audio is heard by both of us.
Here's my code:
I'm just looping through all the playback devices, finding the VAC and default devices, adding the device ID to a list, and then creating an audio wave to be played on all devices in that list.
private List<WaveOut> _waveOut = new List<WaveOut>();
//Gets VAC and Default Audio devices
//var deviceList = (from device in WaveOutDevice.EnumerateDevices() select device.DeviceId + " " + device.Name).ToList(); //Testing
var devices = (from device in WaveOutDevice.EnumerateDevices() where device.Name.Contains("CABLE Input") select device.DeviceId).ToList();
devices.Add(WaveOutDevice.DefaultDevice.DeviceId);
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount };
//Dispose if exists
if (_waveOut != null && _waveOut.Count > 0)
{
foreach (var waveOut in _waveOut)
{
waveOut.Stop();
waveOut.Dispose();
}
_waveOut.Clear();
}
//Setup Audio Wave to be played through each device
Parallel.ForEach(devices, parallelOptions, (i, loopState) =>
{
var stream = new MemoryStream();
var speechEngine = new SpeechSynthesizer();
speechEngine.SetOutputToWaveStream(stream);
speechEngine.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
speechEngine.Speak(text);
var waveOut = new WaveOut();
waveOut.Device = new WaveOutDevice(i);
waveOut.Latency = 50;
waveOut.Initialize(new MediaFoundationDecoder(stream));
_waveOut.Add(waveOut);
});
var playing = false;
//Check Playback state of each WaveOut
foreach (var waveOut in _waveOut)
{
switch (waveOut.PlaybackState)
{
case PlaybackState.Playing:
playing = true;
waveOut.Pause();
break;
case PlaybackState.Paused:
playing = true;
waveOut.WaveSource.Position = waveOut.WaveSource.Position - 40000 < 0 ? 0 : waveOut.WaveSource.Position - 40000;
waveOut.Resume();
break;
case PlaybackState.Stopped:
playing = false;
break;
default:
playing = false;
break;
}
}
//If stopped or nothing has been played yet
if (!playing)
{
foreach (var waveOut in _waveOut)
{
waveOut.WaveSource.Position = 0;
waveOut.Play();
}
}
I understand that what I'm doing has really nothing to do with the devices on the recording tab, but that seems to be where the issue lies (unless I'm missing something).
Anyone else run into anything like this?