Search code examples
c#text-to-speechskype4com

skype4com reset input device after playing wave


I'm using SKype4Com and it seems that whenever I play a wav file, I can't ever change back to my microphone. I literally have to end the call, and call back in order to use my mic again. Here's some code:

DeviceType = TCallIoDeviceType.callIoDeviceTypeFile
var filename = Path.GetTempFileName();
using (this.Speak = new SpeechSynthesizer())
{
    this.Speak.SetOutputToWaveFile(
        filename,
        new System.Speech.AudioFormat.SpeechAudioFormatInfo(
            16000,
            System.Speech.AudioFormat.AudioBitsPerSample.Sixteen,
            System.Speech.AudioFormat.AudioChannel.Mono));
    this.Speak.Speak(reply);
    this.Speak.SetOutputToDefaultAudioDevice();
    this.Speak.Speak(reply);
    CurrentCall.set_InputDevice(DeviceType, filename);
    this.skype.SendMessage(pMessage.FromHandle, reply);
    this.Speak.SetOutputToNull();
    this.Speak.Dispose();
    CurrentCall.set_InputDevice(DeviceType,"");
}
CurrentCall.set_InputDevice(TCallIoDeviceType.callIoDeviceTypeSoundcard, "default");
Dispatcher.Invoke(new Action(() =>
    {
        tb1.Text += "sound card: ";
        tb1.Text += CurrentCall.get_InputDevice(TCallIoDeviceType.callIoDeviceTypeSoundcard);
        tb1.Text += Environment.NewLine;
        tb1.Text += "port: ";
        tb1.Text += CurrentCall.get_InputDevice(TCallIoDeviceType.callIoDeviceTypePort);
        tb1.Text += Environment.NewLine;
        tb1.Text += "file: ";
        tb1.Text += CurrentCall.get_InputDevice(TCallIoDeviceType.callIoDeviceTypeFile);
        tb1.Text += Environment.NewLine;
    }));
}

Any ideas how I can get this to work? After the auto finishes, I just hear silence forever.


Solution

  • There is a way to put audio into skype using tcp, so I did that instead.