AdvancedHMI Software
General Category => Open Discussion => Topic started by: m.hesler on May 31, 2018, 04:52:15 AM
-
Morning All
I don't know if this is already an open discussion, but I would like to use the messagelistbyvalue control and add in the "Speak Message" property that is in the messagedisplaybyvalue control.
I have looked in the code but cant find the reference to it.
Any help will be hugely appreciated.
Thanks
-
Do you mean text to speech the content of the message?
-
Yes that's exactly what I want to do
-
I am not sure a property of "Speak Message" will do for you, but my thought is to use the value change event of the MessageDisplayByvalue, then do something along the line:
Dim synthesizer As SpeechSynthesizer = New SpeechSynthesizer()
synthesizer.Volume = 100
synthesizer.SelectVoice("Microsoft Anna")
synthesizer.Rate = -2
synthesizer.SpeakAsync("This is my message")
-
Thanks bachphi.
I'll give that a try. Didn't realise you could reference Microsoft voices.
Would this work with Cortana
-
I just did a quick test, it worked for me. Here is my code:
Dim synthesizer As SpeechSynthesizer = New SpeechSynthesizer()
Private Sub MessageDisplayByValue1_ValueChanged(sender As Object, e As Controls.ValueChangedEventArgs) Handles MessageDisplayByValue1.ValueChanged
synthesizer.Volume = 100
'synthesizer.SelectVoice("Microsoft Anna")
'synthesizer.SelectVoice("Microsoft David Desktop")
synthesizer.SelectVoice("Microsoft Zira Desktop")
synthesizer.Rate = -2
synthesizer.SpeakAsync(sender.Messages(e.NewValue).Message.ToString)
End Sub
-
Thanks bachphi
I actually got it working. I did a bit of translation as I'm using C#.
Every time I referenced the voice type it threw back errors. So I just let it use my default voice in Windows.
Thanks for pointing me in the right direction though
Much Appreciated
-
You might consider posting your C# functional code just in case if somebody else might need it.
-
I Tried
using System.Speech.Synthesis;
using System.Speech;
private void AlarmList_ValueChanged(object sender, MfgControl.AdvancedHMI.Controls.ValueChangedEventArgs e)
{
SpeechSynthesizer speechSynthesizer1 = new SpeechSynthesizer();
speechSynthesizer1.Volume = 100;
speechSynthesizer1.Rate = 2;
speechSynthesizer1.SpeakAsync(AlarmList.Text);
}
But she read EVERYTHING. Including the value, settings and time date stamp
so I opted for
private void dataSubscriber21_DataChanged(object sender, MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs e)
{
string data = "";
data = e.Values[0];
string plcAddress = "";
plcAddress = e.PlcAddress;
//C3
switch (plcAddress)
{
case "N170:30"://C3
switch (data)
{
case "1":
C3.ValueSelect2 = true;
C3.ValueSelect1 = false;
C3.ValueSelect3 = false;
break;
case "2":
C3.ValueSelect3 = true;
C3.ValueSelect1 = false;
C3.ValueSelect2 = false;
break;
case "5":
C3.ValueSelect1 = true;
C3.ValueSelect2 = false;
C3.ValueSelect3 = false;
AlarmList.Value = 1; SpeechSynthesizer speechSynthesizer1 = new SpeechSynthesizer();
speechSynthesizer1.Volume = 100;
speechSynthesizer1.Rate = 2;
speechSynthesizer1.SpeakAsync("Conveyor 3 Fault");
break;
default:
break;
}
break;
You may be able to help me further, as I have to type this code for every fault, and there's about 100
-
This is above my pay grade.
In your AdvancedHMIcs project, add a MessageDisplaybyValue, set your PLCAddress value and set up your texts in Messages.
Next click the Lightning icon, scroll down and double click ValueChanged event:
private SpeechSynthesizer synthesizer = new SpeechSynthesizer();
private void messageDisplayByValue1_ValueChanged(object sender, MfgControl.AdvancedHMI.Controls.ValueChangedEventArgs e)
{
AdvancedHMIControls.MessageDisplayByValue msgDsp = (AdvancedHMIControls.MessageDisplayByValue)sender;
int ee = (int)e.NewValue;
synthesizer.Volume = 100;
synthesizer.Rate = -2;
synthesizer.SpeakAsync(msgDsp.Messages[ee].Message);
}
Good luck!
-
The message display by value already has the "Speak Message" Property.
So there is no need for this extra code.
My dilemma is, I have a large range of messages spanning across multiple PLC addresses. I want to list them until the operator decides to clear the messages. I have this working already, but for that extra touch would like Cortana or any other built in voice to speak them.
The code I wrote works, however has its faults. If multiple faults occur at once, she speaks them all simultaneously. I would like her to read each text line..... one at a time.
-
Disregard my last post
bachphi you are an absolute star. If you were in front of me now I swear I would kiss you.
Your code worked, slightly tweaked, but it worked.
Thank you so much.
private SpeechSynthesizer synthesizer = new SpeechSynthesizer();
private void AlarmList_ValueChanged(object sender, MfgControl.AdvancedHMI.Controls.ValueChangedEventArgs e)
{
AdvancedHMIControls.MessageListByValue msgDsp = (AdvancedHMIControls.MessageListByValue)sender;
int ee = (int)e.NewValue;
synthesizer.Volume = 100;
synthesizer.Rate = -2;
synthesizer.SpeakAsync(msgDsp.Messages[ee].Message);
}
-
I did not even notice that "SpeakMessage", lol.