我正在为大学项目开发一个原型演讲文本字幕应用程序.我将在我的项目中使用手势识别,所以我认为使用Kinect作为麦克风源是一个好主意,而不是使用额外的麦克风.我的应用的想法是识别自发的演讲,如长而复杂的句子(我明白,语音听写不会是完美的).我看过许多Kinect语音示例,它引用了Microsoft.Speech,但没有引用System.Speech.由于我需要训练语音引擎并将DictationGrammar加载到语音识别引擎中,因此Microsoft.Speech是我的唯一选择.
我已经设法使用Kinect作为直接麦克风音频源,但由于我正在加载Kinect进行视频预览和手势识别,我无法将其作为直接麦克风访问.
这是直接访问麦克风而无需加载Kinect硬件进行手势等的代码,并且工作正常:
private void InitializeSpeech()
{
var speechRecognitionEngine = new SpeechRecognitionEngine();
speechRecognitionEngine.SetInputToDefaultAudioDevice();
speechRecognitionEngine.LoadGrammar(new DictationGrammar());
speechRecognitionEngine.RecognizeAsync(RecognizeMode.Multiple);
speechRecognitionEngine.SpeechRecognized += (s, args) => MessageBox.Show(args.Result.Text);
}
Run Code Online (Sandbox Code Playgroud)
这是我需要在加载后通过Kinect访问访问源的地方,它根本没有做任何事情.我想这样做:
using (var audioSource = new KinectAudioSource())
{
audioSource.FeatureMode = true;
audioSource.AutomaticGainControl = false;
audioSource.SystemMode = SystemMode.OptibeamArrayOnly;
var recognizerInfo = GetKinectRecognizer();
var speechRecognitionEngine = new SpeechRecognitionEngine(recognizerInfo.Id);
speechRecognitionEngine.LoadGrammar(new DictationGrammar());
speechRecognitionEngine.SpeechRecognized += (s, args) => MessageBox.Show(args.Result.Text);
using (var s = audioSource.Start())
{
speechRecognitionEngine.SetInputToAudioStream(s, new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));
speechRecognitionEngine.RecognizeAsync(RecognizeMode.Multiple);
}
}
Run Code Online (Sandbox Code Playgroud)
所以问题是,是否可以使用System.Speech而不是Microsoft.Speech与当前的Kinect SDK,以及我在第二个代码示例中做错了什么?
GetKinectRecognizer方法
private static …Run Code Online (Sandbox Code Playgroud) 我有一个XML文件,开头像这样:
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">
<DataSources>
Run Code Online (Sandbox Code Playgroud)
当我运行以下代码时:
byte[] fileContent = //gets bytes
string stringContent = Encoding.UTF8.GetString(fileContent);
XDocument xml = XDocument.Parse(stringContent);
Run Code Online (Sandbox Code Playgroud)
我得到以下XmlException:
根级别的数据无效.第1行,第1位.
删除版本和编码节点可以解决问题.为什么?如何正确处理这个xml?
样式是WPF的一大特色.当然可以使文本框看起来与操作系统文本框完全相同吗?
我已经厌倦了选择必须具有的暗淡的去饱和颜色,以便可以看到黑色文本:

这可以解决吗?
我正在研究一个控制台应用程序,它将按照设定的时间间隔进行安排和运行,比如说每30分钟一次.其唯一目的是查询Web服务以更新一批数据库行.
Web Service API重新命令每30秒调用一次,并在设置的间隔后超时.以下伪代码作为示例给出:
listId := updateList(<list of terms>)
LOOP
WHILE NOT isUpdatingComplete(listId)
END LOOP
statuses := getStatuses(“LIST_ID = {listId}”)
Run Code Online (Sandbox Code Playgroud)
我在C#中大致编码为:
int callCount = 0;
while( callCount < 5 && !client.isUpdateComplete(listId, out messages) )
{
listId = client.updateList(options, terms, out messages);
callCount++;
Thread.Sleep(30000);
}
// Get resulting status...
Run Code Online (Sandbox Code Playgroud)
在这种情况下使用Thread.Sleep()可以吗?我知道这通常不是好的做法,但从阅读理由不使用它看起来似乎是可接受的用法.
谢谢.
Object Typecasting在性能方面有多昂贵?
我应该尽可能避免使用Typecasting吗?
各位开发者大家好,
我正在尝试使用 Linq 查询改进 Oracle 数据库中以 BLOB 格式存储的 XML 对象列表的导出。
遗憾的是,其中一个 BLOB 相当大,当我读取它时,内存使用量增加到 2 GB。我的fileSet对象是一个IQueryable<myRecord>对象。我试过
foreach (var file in fileSet){...}
Run Code Online (Sandbox Code Playgroud)
和
var files = fileSet.ToList(); //This time the list is causing the memory load.
foreach(file in files){...}
Run Code Online (Sandbox Code Playgroud)
和
var e = fileSet.AsEnumerable().GetEnumerator();
while(e.MoveNext()){...}
Run Code Online (Sandbox Code Playgroud)
但每次我达到列表中的大记录时,内存都会被过度使用。为了创建导出,我正在寻找一些使用的代码Buffer.BlockCopy,但由于内存过度充电,如果您知道如何减少内存使用或延迟加载每个 blob,则没有必要朝这个方向进一步发展:(
我有一个通用控制器,我传递一个只包含属性的类.一切都很好,但......
我想在Controller类中创建另一个继承传递类的类.
有点像:
public class Products
{
public Int32 ProductID {get; set;}
public String ProductName {get; set;}
}
public class ProductController : Controller<Products>
{
public ProductsController() : base("Products", "ProductID", "table", "dbo")
{
}
}
public class Controller<T> : IDisposable where T : new()
{
protected Controller(String tablename, String keyname, String entitytype, String tableschema = "dbo")
{
...
}
//How do I create the Recordset class inheriting T
public class Recordset : T //<----This is what I don't know how to …Run Code Online (Sandbox Code Playgroud) 我有一个日期的字符串,格式为MMDDYYYY(即01132012,01142012等)
如果该字符串距离当前日期不超过14天,我需要在页面上执行某些操作.
即.今天是01132012,所以任何带有12312011或更少日期的字符串都会在页面上显示某些内容.
有人能帮忙吗?我试过了
echo date("d/m/Y", strtotime('01142012'));
Run Code Online (Sandbox Code Playgroud)
但无济于事.
我遇到了这个错误:当我尝试向包含 itemtemplate 复选框的网格添加新行时,指定的强制转换无效,如下所示。每当我使用“已检查”一词而不是“文本”时,就会显示错误。但是我想要做的是在我的“choiceQn”为真时显示“选中”复选框,而不是在我的复选框旁边显示“真”。如果你能解决我的问题,请帮助我。
ASP.NET
<ItemTemplate>
<asp:CheckBox ID="ChoiceCheckBox" runat="server" **Checked**='<%# Bind("ChoiceQn") %>'/>
</ItemTemplate>
Run Code Online (Sandbox Code Playgroud)
C#
private void AddNewRowToGrid()
{
int rowIndex = 0;
if (ViewState["CurrentTable"] != null)
{
DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
DataRow drCurrentRow = null;
if (dtCurrentTable.Rows.Count > 0)
{
for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
{
TextBox box1 = (TextBox)UpdateQuestionGrid.Rows[rowIndex].Cells[0].FindControl("QuestionsTbx");
drCurrentRow = dtCurrentTable.NewRow();
drCurrentRow["QuestionId"] = i + 1;
drCurrentRow["Question"] = "";
drCurrentRow["ChoiceQn"] = false;
rowIndex++;
}
//add new row to DataTable
dtCurrentTable.Rows.Add(drCurrentRow);
//Store the current …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Newtonsoft.json 将 json 字符串转换为对象,但以下转换遇到一些问题。我想知道是否有人可以解释这一点。谢谢。
AddFaceResponse ir = JsonConvert.DeserializeObject<AddFaceResponse>(responseContentStr);
Run Code Online (Sandbox Code Playgroud)
这是 json 字符串 responseContentStr
[{
"faceId": "1fe48282-a3b0-47d1-8fa8-67c4fac3d984",
"faceRectangle": {
"top": 80,
"left": 50,
"width": 147,
"height": 147
}
}]
Run Code Online (Sandbox Code Playgroud)
这是我的模型对象。
public class AddFaceResponse
{
public class Face
{
public class FaceRectangle
{
public int top, left, width, height;
public FaceRectangle(int t, int l, int w, int h)
{
top = t;
left = l;
width = w;
height = h;
}
}
public string faceId;
public FaceRectangle faceRectangle;
public Face(string id, …Run Code Online (Sandbox Code Playgroud)