2011-11-23 6 views
3

Windows 양식의 버튼을 클릭하면 오디오 파일 (또는 Skype 용 현재 입력 장치에 직접 오디오)을 보내려고합니다. 링크를 찾았지만 모든 참조가 깨진 것 같아서 어떻게 작동하는지 미칠 것입니다.Skype 통화로 오디오 보내기

이미 skype api에 연결하여 사용하고 있습니다. 이미 다른 프로젝트에서 사용 중이며 잘 작동합니다.하지만 입력 오디오 스트림에 오디오를 보낼 수 없습니다.

모든 의견을 환영합니다.

현재 코드 :

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 
{ 
    /// <summary> 
    /// Logica di interazione per MainWindow.xaml 
    /// </summary> 
    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(); 
      } 
     } 
    } 
} 

지금까지 발견했습니다 무엇 : 문제가 작동해야 내 코드를 직접적으로는 파일 형식에 대한처럼 http://community.skype.com/t5/Desktop-API-former-Public-API/Sending-Audio-in-Skype/td-p/422

답변

4

보인다. 이것은 내가 스카이프 포럼에 대한 응답으로 가지고 무엇

: http://devforum.skype.com/t5/Developer-Corner/Skype4COM-and-C-Sending-audio-on-current-call-through-input/td-p/8414?utm_source=Subsciption&utm_medium=Subsciption&utm_campaign=Subsciption

그것은 내가 16 개 비트 샘플, 16kHz의, 모노 WAV 파일로 파일을 내장, 작동합니다. 여기 System.Speech 라이브러리를 사용하는 코드입니다 : (A SpeechSynthesize 객체는 말)

Speak.SetOutputToWaveFile(filepath, new System.Speech.AudioFormat.SpeechAudioFormatInfo(
     16000, 
     System.Speech.AudioFormat.AudioBitsPerSample.Sixteen, 
     System.Speech.AudioFormat.AudioChannel.Mono 
    )); 

희망이 도움