'string.Trim(params char[])' is a 'method', which is not valid in the given context
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 SpeechLib; using System.Speech.Recognition; namespace SpeechToTextTest { public partial class Form1 : Form { private SpeechRecognitionEngine withEventsField_sre; public SpeechRecognitionEngine sre { get { return withEventsField_sre; } set { if (withEventsField_sre != null) { withEventsField_sre.LoadGrammarCompleted -= sre_LoadGrammarCompleted; withEventsField_sre.SpeechHypothesized -= sre_SpeechHypothesized; withEventsField_sre.SpeechRecognitionRejected -= sre_SpeechRecognitionRejected; withEventsField_sre.SpeechRecognized -= sre_SpeechRecognized; } withEventsField_sre = value; if (withEventsField_sre != null) { withEventsField_sre.LoadGrammarCompleted += sre_LoadGrammarCompleted; withEventsField_sre.SpeechHypothesized += sre_SpeechHypothesized; withEventsField_sre.SpeechRecognitionRejected += sre_SpeechRecognitionRejected; withEventsField_sre.SpeechRecognized += sre_SpeechRecognized; } } } public Form1() { Load += Form1_Load; InitializeComponent(); sre = new SpeechRecognitionEngine(); } private void Form1_Load(object sender, EventArgs e) { string[] words = new string[] { "Kathy S" }; Choices c = new Choices(words); GrammarBuilder grmb = new GrammarBuilder(c); Grammar grm = new Grammar(grmb); sre.LoadGrammar(grm); } private void btnLiterate_Click(object sender, EventArgs e) { if (TextBox1.Text.Trim.Length == 0) return; sre.SetInputToWaveFile(TextBox1.Text); RecognitionResult r = default(RecognitionResult); r = sre.Recognize(); if (r == null) { TextBox2.Text = "Could not fetch result"; return; } TextBox2.Text = r.Text; } private void Button1_Click(object sender, EventArgs e) { TextBox1.Text = string.Empty; OpenFileDialog fileDlg = new OpenFileDialog(); //wave As WaveFile() if (fileDlg.ShowDialog() == DialogResult.OK) { //wave = New WaveFile(fileDlg.FileName) TextBox1.Text = "Reading .WAV file..."; //wave.Read() TextBox1.Text = OpenFileDialog1.FileName; //TextBox1.Text = "Finished Reading .WAV file..." //m_DrawWave = True Refresh(); } } private void sre_LoadGrammarCompleted(object sender, System.Speech.Recognition.LoadGrammarCompletedEventArgs e) { } private void sre_SpeechHypothesized(object sender, System.Speech.Recognition.SpeechHypothesizedEventArgs e) { System.Diagnostics.Debug.Print(e.Result.Text); } private void sre_SpeechRecognitionRejected(object sender, System.Speech.Recognition.SpeechRecognitionRejectedEventArgs e) { System.Diagnostics.Debug.Print("Rejected: " + e.Result.Text); } private void sre_SpeechRecognized(object sender, System.Speech.Recognition.SpeechRecognizedEventArgs e) { System.Diagnostics.Debug.Print(e.Result.Text); } private void openFileDialog1_FileOk(object sender, CancelEventArgs e) { } } }
if (TextBox1.Text.Trim.Length == 0)
if (TextBox1.Text.Trim().Length == 0)
Trim()
String
DialogResult dr = default(DialogResult); dr = OpenFileDialog1.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { if (!OpenFileDialog1.FileName.Contains("C:\\Documents and Settings\\Kathy\\Desktop\\SpeechToTextTest\\SpeechToTextTest\\OpenFileDialog1.wav")) { MessageBox.Show("Incorrect file"); } else { TextBox1.Text = OpenFileDialog1.FileName; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)