好吧,我的大腦已經對我產生了短暫的影響。我想要做的是編寫一個程序,讓我在電腦響了很多響之後打電話給我的電腦。在這一點上,我可以對我的電腦說話,並利用電腦的語音識別功能。但是,我的電腦沒有通過電話接收我的聲音,作爲「麥克風輸入」音頻源。這很可能是因爲COM4端口是調制解調器用作其中繼源的東西。C#調制解調器和AT命令
目前,我可以從我的電腦撥打電話,並從我的電腦接到電話。電腦目前是一個榮耀的電話。兩個用戶可以來回互相呼叫,但電腦就像第三個人一樣坐在那裏尷尬的日子。我希望計算機在收聽主叫方時發揮更積極的作用。
無論如何,我似乎無法確定讓我能讓電腦聽取來電者聲音的代碼。我只是在AT命令中破冰,所以請和我一起溫柔。
下面是來自from1的代碼。任何援助將是偉大的。謝謝!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.IO.Ports;
using System.Threading;
using System.IO;
namespace VoiceModem
{
public partial class Form1 : Form
{
byte[] buffer;
public Form1()
{
InitializeComponent();
}
SerialPort modemPort;
int bufferLoc;
string strBuf;
FileStream file;
StreamWriter logfile;
//note to self: the max port speed is listed at 115200
private void btnCALL_Click(object sender, System.EventArgs e)
{
string PHONENUMBER = "ATD=" + this.textBox1.Text + "\r";
//File.Close("raw.txt", FileMode.Create);
//C:\Documents and Settings\Commander\Desktop
file = File.Open("raw.txt", FileMode.Create);
logfile = File.CreateText("log.txt");
buffer = new byte[10 * 1024];
modemPort = new SerialPort("COM4", 112500, Parity.None, 8, StopBits.One);
modemPort.ReadTimeout = SerialPort.InfiniteTimeout;
modemPort.DataReceived += new SerialDataReceivedEventHandler(modemPort_DataReceived);
modemPort.Open();
modemPort.Write("AT\r"); //OK
modemPort.Write("ATA\r"); //ANSWERING IN VOICE MODE *** NO CARRIER
Thread.Sleep(500);
modemPort.Write("AT+FCLASS=8\r"); ///this should be voice here
Thread.Sleep(500);
modemPort.Write(PHONENUMBER); //DIAL number that D equals
// modemPort.Write("ATH\r"); //HANG UP IN VOICE MODE //ERROR
//modemPort.Write("AT+VSM=1\r");
// modemPort.Write("AT+VTX\r"); //VOICE TRANSMIT MODE //ERROR
// modemPort.Write("AT+VLS=5\r");
Thread.Sleep(500);
modemPort.Write("AT+VRX\r"); //VOICE RECEIVE MODE
Thread.Sleep(500);
modemPort.Write("AT+VLS=3+RX\r");
//VLS
//0 - Telephone Line Select (Go on hook)
//2 - Speakers
//3 - Microphone
//4 - Telephone Line Select + Samples routed to/from Speakers/Mic in TX/RX modes
//6 - Speakerphone
}
private void button1_Click(object sender, System.EventArgs e)
{
//C:\Documents and Settings\Commander\Desktop
file = File.Open("raw.txt", FileMode.Create);
logfile = File.CreateText("log.txt");
buffer = new byte[10*1024];
modemPort = new SerialPort("COM4",112500, Parity.None, 8,StopBits.One);
modemPort.ReadTimeout = SerialPort.InfiniteTimeout;
modemPort.DataReceived+= new SerialDataReceivedEventHandler(modemPort_DataReceived);
modemPort.Open();
modemPort.Write("AT\r"); //OK
//modemPort.Write("ATA\r"); //ANSWERING IN VOICE MODE *** NO CARRIER
modemPort.Write("AT+FCLASS=8\r");
// "ATD=6022626151;\r"
//modemPort.Write(this.textBox1.Text);
//ATD4412345679;
//Dmn ATDmn will dial a phone number where m is the modifier: L, W, ,, ;, @, or S.
//It will dial the telephone number n.
// string str = "Hello " + userName + ". Today is " + date + ".";
string PHONENUMBER = "ATD=" + this.textBox1.Text + "\r";
Thread.Sleep(500);
modemPort.Write(PHONENUMBER); //DIAL number that D equals
Thread.Sleep(500);
modemPort.Write("ATH\r"); //HANG UP IN VOICE MODE //ERROR
//modemPort.Write("AT+VSM=1\r");
Thread.Sleep(500);
modemPort.Write("AT+VLS=?\r");
Thread.Sleep(500);
modemPort.Write("AT+VTX\r"); //VOICE TRANSMIT MODE //ERROR
//modemPort.Write("AT+VLS=1\r");
Thread.Sleep(500);
buffer = new byte[10*1024];
modemPort.Write("AT+VRX\r"); //VOICE RECEIVE MODE
//modemPort.Write("AT+VRX\r");
}
void modemPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs args)
{
int x = modemPort.BytesToRead;
modemPort.Read(buffer,0,x);
file.Write(buffer,0,x);
logfile.WriteLine(x.ToString()+args.EventType.ToString());
}
private void button2_Click(object sender, System.EventArgs e)
{
modemPort.Close();
file.Close();
logfile.Close();
}
private void button3_Click(object sender, System.EventArgs e)
{
Form2 form2 = new Form2();
form2.Show();
//Form2.show();
}
private void button4_Click(object sender, System.EventArgs e)
{
this.richTextBox1.Text = System.IO.File.ReadAllText("raw.txt");
}
private void button5_Click(object sender, System.EventArgs e)
{
this.richTextBox2.Text = System.IO.File.ReadAllText("log.txt");
}
private void NUMBER1_Click(object sender, System.EventArgs e)
{
//tBox1.Text += "a";
this.textBox1.Text += "1";
}
private void NUMBER2_Click(object sender, System.EventArgs e)
{
this.textBox1.Text += "2";
}
private void NUMBER3_Click(object sender, System.EventArgs e)
{
this.textBox1.Text += "3";
}
private void NUMBER4_Click(object sender, System.EventArgs e)
{
this.textBox1.Text += "4";
}
private void NUMBER5_Click(object sender, System.EventArgs e)
{
this.textBox1.Text += "5";
}
private void NUMBER6_Click(object sender, System.EventArgs e)
{
this.textBox1.Text += "6";
}
private void NUMBER7_Click(object sender, System.EventArgs e)
{
this.textBox1.Text += "7";
}
private void NUMBER8_Click(object sender, System.EventArgs e)
{
this.textBox1.Text += "8";
}
private void NUMBER9_Click(object sender, System.EventArgs e)
{
this.textBox1.Text += "9";
}
private void NUMBER0_Click(object sender, System.EventArgs e)
{
this.textBox1.Text += "0";
}
private void btnREDIAL_Click(object sender, System.EventArgs e)
{
buffer = new byte[10 * 1024];
modemPort = new SerialPort("COM4", 112500, Parity.None, 8, StopBits.One);
modemPort.ReadTimeout = SerialPort.InfiniteTimeout;
modemPort.DataReceived += new SerialDataReceivedEventHandler(modemPort_DataReceived);
modemPort.Open();
modemPort.Write("AT\r"); //OK
modemPort.Write("ATDL\r"); //OK
}
private void Form1_Load(object sender, System.EventArgs e)
{
this.textBox1.Focus();
}
private void btnANSWER_Click(object sender, System.EventArgs e)
{
//C:\Documents and Settings\Commander\Desktop
file = File.Open("raw.txt", FileMode.Create);
logfile = File.CreateText("log.txt");
buffer = new byte[10 * 1024];
modemPort = new SerialPort("COM4", 112500, Parity.None, 8, StopBits.One);
modemPort.ReadTimeout = SerialPort.InfiniteTimeout;
modemPort.DataReceived += new SerialDataReceivedEventHandler(modemPort_DataReceived);
modemPort.Open();
modemPort.Write("AT\r"); //OK
Thread.Sleep(500);
modemPort.Write("ATA\r"); //ANSWERING then gives beep-boops
Thread.Sleep(500);
//modemPort.Write("AT+VLS=1");
//modemPort.Write("AT+FCLASS=8\r");
// string str = "Hello " + userName + ". Today is " + date + ".";
// string PHONENUMBER = "ATD=" + this.textBox1.Text + "\r";
// modemPort.Write(PHONENUMBER); //DIAL number that D equals
//modemPort.Write("ATH\r"); //HANG UP IN VOICE MODE //ERROR
//modemPort.Write("AT+VSM=1\r");
//modemPort.Write("AT+++\r");// disconnects data mode to allow for voice mode
//voice mode is activated using ata
modemPort.Write("AT+VRX\r");
//modemPort.Write("AT+VTX\r"); //VOICE TRANSMIT MODE //ERROR
//modemPort.Write("AT+VLS=1\r");
// modemPort.Write("ATH\r"); //HANG UP IN VOICE MODE //ERROR
//modemPort.Write("AT+VRX\r");
//modemPort.Write("ATA\r"); //answer the call
}
private void btnHANGUP_Click(object sender, System.EventArgs e)
{
modemPort.Close();
}
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
//int iPhone = 7065551212;
//string strPhone = string.Format("{0:(###) ###-####}", iPhone);
// this.textBox1.Mask = "(999) 000-0000";
}
private void textBox1_Leave(object sender, System.EventArgs e)
{
// Reset the colors and selection of the TextBox after focus is lost.
string x = textBox1.Text;
double y = Double.Parse(x);
textBox1.Text = String.Format("{0:(###) ###-####}", y);
textBox1.ForeColor = Color.Black;
textBox1.BackColor = Color.White;
textBox1.Select(0, 0);
}
/*
* ACTIVE PROFILE:
E0 L1 M1 Q0 T V1 X4 &C1 &D2 &G0 &P0
S00:000 S01:000 S02:043 S03:013 S04:010 S05:008 S06:002 S07:060 S08:002
S10:014 S12:050 S29:070
STORED PROFILE 0:
E0 L1 M1 Q0 T V1 X4 &C1 &D2 &G0 &P0
S00:000 S02:043 S06:002 S07:050 S08:002 S10:014 S12:050 S29:070
*
*
* DIAG <2A4D3263 0=10>
DIAG <2A4D3263 1=0>
DIAG <2A4D3263 60=1>
* */
}
}
+1。自1996年以來沒有看到「AT」命令。啊..回憶。我想知道是否有關於'zmodem'和'kermit'協議的帖子。 – ja72
我同意,這就像彙編老派,但它真的很厲害!我告訴你,我的VR(語音識別)程序會搖動你的世界。目前,它幾乎控制了我實驗室的各個方面。 –