Speech To text In Visual Basic - visual-studio-2010

I have the code for speech to text written in Visual Basic, but it recognizes only first word or sentence spoken, then it stops recognizing. I want it to keep listening. How can I do that? What is the problem?
Here's the code I have for now:
Imports System.Speech
Public Class Form1
Public synth As New Speech.Synthesis.SpeechSynthesizer
Public WithEvents recognizer As New Speech.Recognition.SpeechRecognitionEngine
Dim gram As New System.Speech.Recognition.DictationGrammar()
Public Sub GotSpeech(ByVal sender As Object, ByVal phrase As System.Speech.Recognition.SpeechRecognizedEventArgs) Handles recognizer.SpeechRecognized
words.Text += phrase.Result.Text & vbNewLine
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
recognizer.LoadGrammar(gram)
recognizer.SetInputToDefaultAudioDevice()
recognizer.RecognizeAsync()
End Sub
End Class

RecognizeAsync() does a single recognition. RecognizeAsync(RecognizeMode.Multiple) will do multiple recognitions.

Imports System.Speech
Public Class Form1
Public synth As New Speech.Synthesis.SpeechSynthesizer
Public WithEvents recognizer As New Speech.Recognition.SpeechRecognitionEngine
Dim gram As New System.Speech.Recognition.DictationGrammar()
Public Sub GotSpeech(ByVal sender As Object, ByVal phrase As System.Speech.Recognition.SpeechRecognizedEventArgs) Handles recognizer.SpeechRecognized
word.Text += phrase.Result.Text + ""
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
recognizer.LoadGrammar(gram)
recognizer.SetInputToDefaultAudioDevice()
recognizer.RecognizeAsync(Recognition.RecognizeMode.Multiple)
End Sub
End Class
All Problems cleared
:)

Related

Spring Batch complex custom ItemReader

I'm newbie in spring batch and I can't determinate what pattern for reader I would need to use. I need to create the class WSRequestClass and send it to SOAP web service.
public class WSRequestClass{
private String data1;
private String data2;
private String data3;
private String data4;
private List<ClassB> dataList;
}
To create WSRequestClass is necessary:
Read data1 and data2 from table A.
Read data3 and data4 from table B.
The List<ClassB> should be create from more complex flow. First I get data from query from table C, but the result of this query is a List<ClassA>. I need process each item of List<ClassA> and convert it to ClassB, where some attributes are calculated from ClassA. (Chunk pattern but without writer).
public class ClassA {
private Date date;
private BigDecimal amount1;
private BigDecimal amount2;
private String data;
//getters & setters
...
}
public class ClassB {
private Date date;
private BigDecimal amount1;
private BigDecimal amount2;
private BigDecimal amount3;
private BigDecimal amount4;
private String data1;
private String data2;
//getters & setters
...
}
I have found multiple examples for simples chunk pattern and tasklets, but none follows this structure. This job use java configuration and JdbcTemplate for queries. The development of the web service call it's done, my only issue is that I have to read from multiple tables and read efficiently the list, transform each item to ClassB and set to WsRequestClass.
Please guide me with the pattern to use, because common ItemReadernot work for me, and I don't know how implement the custom reader that allow me do what I want.
I think you're going about this wrong. There is a pattern in batch processing called the driving query pattern. In it, your reader reads essentially the keys for the objects. You then use processors to fill in the additional information. You can read more about this pattern in the Spring Batch documentation here: https://docs.spring.io/spring-batch/trunk/reference/html/patterns.html#drivingQueryBasedItemReaders

Class property attribute for intellisense?

Let's say I have this class...
Public Class Person
Public Property Gender As String = "male"
End Class
And I do this...
Dim p As New Person
p.Gender
... and hover the mouse over "Gender", then intellisence shows me ....
Property.Person.Gender As String
Can I somehow add an attribute to the Gender property to show more intellisence help - like...
Property.Person.Gender As String = "male"
Or maybe...
Property.Person.Gender As String
It is default set to 'Male'
I was hoping to do smething like...
Public Class Person
<Intellisence="It is default set to 'male'">
Public Property Gender As String = "male"
End Class
Thanks
You can use the XML comment to achieve that.
All tags are listed in Microsoft website: C# and VB.NET
More example can be found here: https://msdn.microsoft.com/en-us/library/z04awywx.aspx
Back to your question, you can set the summary tag in your property, e.g.:
Public Class Person
/// <summary>
/// It is default set to 'Male'</summary>
Public Property Gender As String = "male"
End Class

Spring mvc autocomplete textbox

I want to make a autocomplete textbox. I have an Entity Location
#Entity
public class Location {
#Id
#GeneratedValue(strategy=GenerationType.IDENTITY)
private int lId;
private String lName;
public Location() {
super();
}
public Location(int lId, String lName) {
super();
this.lId = lId;
this.lName = lName;
}
//getters and setters
It should be something like this
I have no idea how to complete this task. I have tried jQuery Autocomplite, but it wasn't success. Can anyone explaine me, how can i make it works.
I have already tried this solution. But it didn't help me. It doesnt work.
If you dont want to use a third-party library then use this: example
Else if you don't mind using third-party code, then you could use this one:
GlazedList implementation auto-completion.
You can install GlazedList on a JComboBox with only one line of Glazed code, like this:
JComboBox comboBox = new JComboBox();
Object[] elements = new Object[] {"name person", "name person", "name person", "name person"};
AutoCompleteSupport.install(comboBox, GlazedLists.eventListOf(elements));
Glazed Lists: source

Visual Basic browser that opens specific local file

I'm trying to create a simple webbrowser that automatically opends a html file named "Index.html" found in the same folder the application is run.
This is the code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate(#".\index.html")
End Sub
End Class
It does not work, I always get an "Expression expected" error. What am I doing wrong?
The other post did not help, I found the answer my self.
This is the answer:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Url = New Uri(String.Format("file:///{0}/index.html", CurDir))
End Sub
End Class

Cast Linq IEnumerable to Class that inherits Ienumerable

I have a resultset class:
Public Class AResultSet
Implements IEnumerable(Of ConcreteResult)
Private _list As List(Of ConcreteResult)
Public Sub New()
_list = New List(Of ConcreteResult)
End Sub
Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of ConcreteResult) Implements System.Collections.Generic.IEnumerable(Of ConcreteResult).GetEnumerator
Return _list.GetEnumerator
End Function
Public Function GetEnumerator1() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
Return _list.GetEnumerator
End Function
End Class
and a linq query:
Dim res As AResultSet = (From pk In testPackages, _
pp In pk.PackagePriceCollection _
Select New ConcreteResult(pk, pp))
But I get a cast error. So if I change the
Dim res As AResultSet
To:
Dim res As IEnumerable(Of ConcreteResult)
It works. But I want to cast the linq query result to the type AResultSet, which is also an IEnumerable(Of ConrecteResult).
Or am I doing something wrong here?
The result of calling Select is not an AResultSet, which is why the cast will fail. Nothing in the query knows that you want to create a AResultSet. Just because the result and AResultSet both implement the same interface doesn't mean they're the same type.
You could create an instance of AResultSet from the results, however:
Dim query = (From pk In testPackages, _
pp In pk.PackagePriceCollection _
Select New ConcreteResult(pk, pp))
Dim res as AResultSet = new AResultSet(query.ToList)
While it's unclear to me why you might want to create a class to duplicate the functionality of List(Of T), what you are trying to do is not directly possible. You should either create an implicit (Widening) user defined cast operator in your class or create a constructor that takes an IEnumerable(Of ConcreteResult) and uses that to fill the private list field.
Public Class AResultSet
Implements IEnumerable(Of ConcreteResult)
Private list As List(Of ConcreteResult)
Private Sub New(l As List(Of ConcreteResult))
list = l
End Sub
Public Shared Widening Operator CType(seq As IEnumerable(Of ConcreteResult)) As AResultSet
Return New AResultset(seq.ToList())
End Sub
...
End Class

Resources