I just have tried to get list of chats and I am not able to get it.
from Chat chat in _skype.chats select new Chat
It doesn't include all chats. I have create new one and can't see it in list.
This will show all chats, including hidden ones. For this reason, you may see duplicates of chats with single contacts only.
Imports SKYPE4COMLib
Public Class Form1
Dim skype As Skype
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
For Each r As Chat In skype.Chats
'If topic = "", then it is an individual chat
If r.Topic <> "" Then
RichTextBox1.AppendText(r.Topic & vbCrLf)
Else
'If topic = "", then display the FriendlyName instead (individual chat)
RichTextBox1.AppendText(r.FriendlyName & vbCrLf)
End If
Next
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
skype = New Skype()
skype.Attach(7, True)
End Sub
End Class
Related
I have a module that opens a Form with a Webview2 browser. The Webview2 control then uses the user username and password (which he entered earlier into two textboxes) to log into a website and loads through a few links to a specific webpage where the user can search for customers, www.login.ca/search. After the user enters a name and clicks on the search button the next page load for a second but then loads the www.login.ca/search page again. I just want to user to be able to continue through the page further without the browser reloading "login.ca/search" webpage.
I have this:
Imports System.Windows.Interop
Imports Microsoft.Web.WebView2.Core
Module SearchForCustomer
Public Sub CheckCustomer()
WebviewForm.Show()
OpenAndLogIn()
End Sub
Public Sub OpenAndLogIn()
'Open webpage and log in
Dim Loginwebaddress As String = "https://www.login.ca"
WebviewForm.WebView21.Source = New Uri(Loginwebaddress)
AddHandler(WebviewForm.WebView21.NavigationCompleted), AddressOf FirstPageWebView
End Sub
Private Async Sub FirstPageWebView(ByVal sender As Object, ByVal e As CoreWebView2NavigationCompletedEventArgs)
Dim msg = TextBox1.Text 'Username
Dim msg2 = TextBox2.Text 'password
Await WebviewForm.WebView21.ExecuteScriptAsync($"document.getElementById('LoginUN').value = '{msg}';")
Await WebviewForm.WebView21.ExecuteScriptAsync($"document.getElementById('Login1PW').value = '{msg2}';")
Await WebviewForm.WebView21.ExecuteScriptAsync($"document.getElementById('Login1_DoLogin').click();")
AddHandler(WebviewForm.WebView21.NavigationCompleted), AddressOf LoginWebpageLoaded
End Sub
Private Sub LoginWebpageLoaded
'Load the search for customer page
Dim Loginwebaddress As String = "https://www.login.ca/search"
WebviewForm.WebView21.Source = New Uri(Loginwebaddress)
End Sub
The first line of FirstPageWebView should remove the handler again, since it should only be used once.
When you call AddHandler you acutually have 2 handlers registered, and they will run both on every NavigationCompleted event.
(I don't know Vb.Net so this code might be wrong, but I hope you get the idea:
Private Async Sub FirstPageWebView(ByVal sender As Object, ByVal e As CoreWebView2NavigationCompletedEventArgs)
RemoveHandler(WebviewForm.WebView21.NavigationCompleted), AddressOf LoginWebpageLoaded
......... more code .........
I am still working on my speech pronunciation test. I have this code, but I need it to use SpeechRecognitionEngine instead of the system popup recognizer. This bit of working code is in VB, even though I prefer to work in C#, but this has been so difficult that I will settle for whatever code or programming language that I can get. This code is totally functional, and can be tested by simply pasting into an empty VB projects, and including Import System.Speech.Recognition. Can someone show me how to make this code use the SpeechEngine with the .
I can discuss setting the default audio input and getting rid of the recognizer start code, it of course must be removed. But, to keep things simple, I have left the code as is for live testing. Thanks
Imports System.Speech.Recognition
Imports System.Threading
Imports System.Globalization
Public Class Form1
' recogniser & grammar
Dim recog As New SpeechRecognizer
Dim gram As Grammar
' events
Public Event SpeechRecognized As _
EventHandler(Of SpeechRecognizedEventArgs)
Public Event SpeechRecognitionRejected As _
EventHandler(Of SpeechRecognitionRejectedEventArgs)
' word list
Dim wordlist As String() = New String() {"Yes", "No", "Maybe"}
' word recognised event
Public Sub recevent(ByVal sender As System.Object,
ByVal e As RecognitionEventArgs)
LabelYes.ForeColor = Color.LightGray
LabelNo.ForeColor = Color.LightGray
LabelMaybe.ForeColor = Color.LightGray
If (e.Result.Text = "Yes") Then
LabelYes.ForeColor = Color.Green
ElseIf (e.Result.Text = "No") Then
LabelNo.ForeColor = Color.Green
ElseIf (e.Result.Text = "Maybe") Then
LabelMaybe.ForeColor = Color.Green
End If
End Sub
' recognition failed event
Public Sub recfailevent(ByVal sender As System.Object,
ByVal e As RecognitionEventArgs)
LabelYes.ForeColor = Color.LightGray
LabelNo.ForeColor = Color.LightGray
LabelMaybe.ForeColor = Color.LightGray
End Sub
' form initialisation
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
' need these to get British English rather than default US
Thread.CurrentThread.CurrentCulture = New CultureInfo("en-GB")
Thread.CurrentThread.CurrentUICulture = New CultureInfo("en-GB")
' convert the word list into a grammar
Dim words As New Choices(wordlist)
gram = New Grammar(New GrammarBuilder(words))
recog.LoadGrammar(gram)
' add handlers for the recognition events
AddHandler recog.SpeechRecognized, AddressOf Me.recevent
AddHandler recog.SpeechRecognitionRejected, AddressOf Me.recfailevent
' enable the recogniser
recog.Enabled = True
End Sub
End Class
Imports AForge.Video
Imports AForge.Video.VFW
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim Stream As AForge.Video.MJPEGStream = New AForge.Video.MJPEGStream("http://192.168.1.250/mjpeg.cgi")
Stream.Login = ("admin")
Stream.Password = ("admin")
Stream.Start()
Dim st As String = ""
Catch ex As Exception
MsgBox(ex.Message.ToString(), MsgBoxStyle.OkOnly, "Error")
Exit Sub
End Try
End Sub
End Class
this is what i have done so far....to get stream started...
know i want know.
how can i show this stream in picture box? and how to get images from this stream.
The MJEGStream includes events. Declare your Stream object on class level as
Private WithEvents Stream As AForge.Video.MJPEGStream
Then add an event handler to the MJPEGStream.NewFrame event with a sub like
Private Sub Handle_NewFrame(sender as Object, e as AForge.Video.NewFrameEventArgs)
Picturebox1.Image = e.Frame
End Sub
Start the stream like you have done in your code.
Don't forget to initialize the Source object.
Source = New AForge.Video.MJPEGStream("http://192.168.1.250/mjpeg.cgi")
The eventargs variable contains the new frame as an image that you can then display in a picturebox.
It's been a while since I have worked with AForge, but it should be ok.
I am looking to convert a .wav file recorded through an android phone at 16000 to text using C#; namely the System.Speech namespace. My code is mentioned below;
recognizer.SetInputToWaveFile(Server.MapPath("~/spoken.wav"));
recognizer.LoadGrammar(new DictationGrammar());
RecognitionResult result = recognizer.Recognize();
label1.Text = result.Text;
The is working perfectly with sample .wav "Hello world" file. However when i record something on teh phone and try to convert to on the pc, the converted text is no where close to what i had recoreded. Is there some way to make sure the audio file is transcribed accurately?
What format is the phone's audio file recorded in? Is the file encoded? Microsoft recognizer supports PCM, ALaw, and ULaw. Make sure you are recording in a supported format. You can look at the RecognizerInfo.SupportedAudioFormats Property - http://msdn.microsoft.com/en-us/library/system.speech.recognition.recognizerinfo.supportedaudioformats(v=VS.90).aspx and check the formats your recognizer version supports.
Did you listen to the file you recorded on your phone? Is it noisy? Does it sound clear? Make sure you are feeding the recognizer the best sounding audio you can.
Since you are using a Dictation grammar, I'm assuming you're using Windows 7. Have you tried training the recognizer? My understanding is that the dictation grammar performance can be improved by training and that the standard Windows 7 speech recognition training will help its performance - http://windows.microsoft.com/en-US/windows7/Set-up-Speech-Recognition
Some other questions on StackOverflow may also give you some insights. See good Speech recognition API to start.
Full implementation details for exactly what you want can be found here:
Converting WAV audio to text using System.Speech
Imports System
Imports System.Speech.Recognition
Public Class Form1
Dim WithEvents sre As SpeechRecognitionEngine
Private Sub btnLiterate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLiterate.Click
If TextBox1.Text.Trim.Length = 0 Then Exit Sub
sre.SetInputToWaveFile(TextBox1.Text)
Dim r As RecognitionResult
r = sre.Recognize()
If r Is Nothing Then
TextBox2.Text = "Could not fetch result"
Return
End If
TextBox2.Text = r.Text
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = String.Empty
Dim dr As DialogResult
dr = OpenFileDialog1.ShowDialog()
If dr = Windows.Forms.DialogResult.OK Then
If Not OpenFileDialog1.FileName.Contains("wav") Then
MessageBox.Show("Incorrect file")
Else
TextBox1.Text = OpenFileDialog1.FileName
End If
End If
End Sub
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
sre = New SpeechRecognitionEngine()
End Sub
Private Sub sre_LoadGrammarCompleted(ByVal sender As Object, ByVal e As System.Speech.Recognition.LoadGrammarCompletedEventArgs) Handles sre.LoadGrammarCompleted
End Sub
Private Sub sre_SpeechHypothesized(ByVal sender As Object, ByVal e As System.Speech.Recognition.SpeechHypothesizedEventArgs) Handles sre.SpeechHypothesized
System.Diagnostics.Debug.Print(e.Result.Text)
End Sub
Private Sub sre_SpeechRecognitionRejected(ByVal sender As Object, ByVal e As System.Speech.Recognition.SpeechRecognitionRejectedEventArgs) Handles sre.SpeechRecognitionRejected
System.Diagnostics.Debug.Print("Rejected: " & e.Result.Text)
End Sub
Private Sub sre_SpeechRecognized(ByVal sender As Object, ByVal e As System.Speech.Recognition.SpeechRecognizedEventArgs) Handles sre.SpeechRecognized
System.Diagnostics.Debug.Print(e.Result.Text)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim words As String() = New String() {"triskaidekaphobia"}
Dim c As New Choices(words)
Dim grmb As New GrammarBuilder(c)
Dim grm As Grammar = New Grammar(grmb)
sre.LoadGrammar(grm)
End Sub
End Class
or try this link
Audio to text software free
I've got an app using .net UIAutomation, it eventually runs out of memory and crashes just monitoring windows being shown and closed. Seemed easier to show this in VB than C# but happens the same either way. It appears to be a leak/pool in the underlying proxy objects. Most of the memory is not being shown as in use as .net memory.
Any ideas on how to get this to stop leaking and still monitor StructureChangedEvents?
Imports System.Windows.Automation
Public Class Form1
Delegate Sub AddListCallback(ByVal Text As String)
Dim UIAeventHandler As StructureChangedEventHandler
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BtnStartStop.Text = "Stop"
Subscribe()
End Sub
Private Sub BtnStartStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnStartStop.Click
If "Start" = BtnStartStop.Text Then
BtnStartStop.Text = "Stop"
Subscribe()
Else
BtnStartStop.Text = "Start"
Unsubscribe()
lbEvents.Items.Clear()
GC.GetTotalMemory(True)
End If
End Sub
Public Sub Subscribe()
UIAeventHandler = New StructureChangedEventHandler(AddressOf OnUIAutomationEvent)
Automation.AddStructureChangedEventHandler(AutomationElement.RootElement, TreeScope.Descendants, UIAeventHandler)
End Sub
Public Sub Unsubscribe()
Automation.RemoveStructureChangedEventHandler(AutomationElement.RootElement, UIAeventHandler)
End Sub
''' <summary>
''' AutomationEventHandler delegate.
''' </summary>
''' <param name="src">Object that raised the event.</param>
''' <param name="e">Event arguments.</param>
Private Sub OnUIAutomationEvent(ByVal src As Object, ByVal e As StructureChangedEventArgs)
' Make sure the element still exists. Elements such as tooltips can disappear
' before the event is processed.
If e.StructureChangeType = StructureChangeType.ChildrenInvalidated Then
Exit Sub
End If
Dim sourceElement As AutomationElement
Try
sourceElement = DirectCast(src, AutomationElement)
Catch ex As ElementNotAvailableException
Exit Sub
End Try
' TODO Handle any other events that have been subscribed to.
Console.WriteLine( "Element : """ & sourceElement.Current.LocalizedControlType & """ """ & sourceElement.Current.Name _
& """ Struct Change Type : " & [Enum].GetName(GetType(StructureChangeType), e.StructureChangeType) _
& " Runtime ID : " & getString(e.GetRuntimeId()))
End Sub
Private Function getString(ByVal ints As Integer()) As String
getString = ""
For Each i As Integer In ints
getString = getString & " " & i.ToString
Next
End Function
End Class
I would do something like this when you unsubscribe:
Automation.RemoveAllEventHandlers();
UIAeventHandler = null;
UIAutomation will keep some threads alive as long as you've got an AutomationEventHandler object around. Its pretty much a black box to me, but the above has fixed all issues that I had.
#jaws is correct (there are some additional things to think about), but it is in C#. for VB you need to do the following:
Automation.RemoveStructureChangedEventHandler(AutomationElement.RootElement, UIAeventHandler)
UIAeventHandler = Nothing
Because you do not set the UIAeventHandler to nothing, when you unsubscribe then, you are re-assigning the event handler which is already in memory.
To think about. Notice that you are calling subscribe when the form loads and subscribe/unsubscribe with a button. When the form loads then, the event handler is assigned and should work fine, that is until you hit unsubscribe/subscribe (in that order). When you did not set the UIAeventHandler to Nothing then, you are causing a memory leak because you then set the UIAeventHandler to a NEW instance on subscribe. Therefore, you could also do the following as suggested by #jaws :
Imports System.Windows.Automation
Public Class Form1
Dim UIAeventHandler as StructureChangedEventHandler
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BtnStartStop.Text = "Stop"
Subscribe()
End Sub
Public Sub Subscribe()
UIAeventHandler = New StructureChangedEventHandler(AddressOf OnUIAutomationEvent)
Automation.AddStructureChangedEventHandler(AutomationElement.RootElement, TreeScope.Descendants, UIAeventHandler)
End Sub
Public Sub Unsubscribe()
Automation.RemoveStructureChangedEventHandler(AutomationElement.RootElement, UIAeventHandler)
UIAeventHandler = Nothing 'Here is the Important part!
End Sub
End Class