title: Send audio over skype call
body: <p>I'm trying to send an audio file (or directly audio over current input device for skype) when I click a button on a windows form. I found some links but all references appear to be broken and I'm going mad on how to work with it.</p>
  
  <p>I already manage to connect to skype api and use it (I already use it for other projects and it's working well), but I really can't send any audio over input audio stream.</p>
  
  <p>Any suggestion will be appreciated.</p>
  
  <p>Current code: </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Navigation;
  using System.Windows.Shapes;
  using System.Speech;
  using System.Speech.Synthesis;
  using SKYPE4COMLib;
  using System.Reflection;
  using System.IO;
  
  namespace TestSendAudioOnSkype
  {
      /// &lt;summary&gt;
      /// Logica di interazione per MainWindow.xaml
      /// &lt;/summary&gt;
      public partial class MainWindow : Window
      {
          private Call CurrentCall = null;
          private Skype SkypeApplet;
          private const int SkypeProtocol = 9;
  
          private SpeechSynthesizer Speak = new SpeechSynthesizer();
  
          public MainWindow()
          {
              InitializeComponent();
              try
              {
                  SkypeApplet = new Skype();
                  SkypeApplet.Attach(SkypeProtocol, true);
                  SkypeApplet.CallStatus += SkypeApplet_CallStatus;
                  //CurrentCall = SkypeApplet.ActiveCalls[0];
              }
              catch (Exception e)
              {
                  MessageBox.Show("errore: " + e.ToString());
                  System.Windows.Application.Current.Shutdown();
              }
          }
  
          void SkypeApplet_CallStatus(Call pCall, TCallStatus Status)
          {
              if (Status == TCallStatus.clsInProgress)
                  CurrentCall = pCall;
          }
  
          private void button1_Click(object sender, RoutedEventArgs e)
          {
              if (CurrentCall == null)
              {
                  CurrentCall = SkypeApplet.ActiveCalls[1];
              }
  
              string path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
              string filepath = System.IO.Path.Combine(path,"tmp.wav");
              Speak.SetOutputToWaveFile(filepath);
              Speak.Speak("Hello world");
              Speak.SetOutputToDefaultAudioDevice();
              //Speak.SpeakAsync("Hello world");
  
              try
              {
                  CurrentCall.set_OutputDevice(TCallIoDeviceType.callIoDeviceTypeFile, filepath);
                  CurrentCall.set_InputDevice(TCallIoDeviceType.callIoDeviceTypeFile, filepath);
                  System.Threading.Thread.Sleep(3000);
                  CurrentCall.set_InputDevice(TCallIoDeviceType.callIoDeviceTypeFile, "");
                  CurrentCall.set_OutputDevice(TCallIoDeviceType.callIoDeviceTypeFile, "");
                  MessageBox.Show("invio terminato");
              }
              catch (Exception exc)
              {
                  MessageBox.Show("errore: " + exc.ToString());
                  //System.Windows.Application.Current.Shutdown();
              }
          }
      }
  }
  </code></pre>
  
  <p>What I've found so far: <a href="http://community.skype.com/t5/Desktop-API-former-Public-API/Sending-Audio-in-Skype/td-p/422" rel="nofollow">http://community.skype.com/t5/Desktop-API-former-Public-API/Sending-Audio-in-Skype/td-p/422</a></p>