I'm new to C# and I'm new to Speech.Recognition.
I searched very long for tutorials but didn't find that much, I'm even not quiet sure whether I included everything correctly.
I downloaded:
SDK
Runtime
Languages
I'm programming local, I have Windows XP, .net framework 3.5.
Now I just want to get started with some simple lines of code, like to say "hello world" or say one or two words as input.
I tried following, and of course it doesn't work :>
error:
"The Typ- or Namespacename "SpeechSynthesizer" couldn't be found (Is a Using-Direktive or a Assemblyverweis missing?)"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Recognition;
using System.Speech.Synthesis;
namespace System.Speech.Recognition { }
namespace System.Speech.AudioFormat {}
namespace System.Speech.Recognition.SrgsGrammar{}
namespace System.Speech.Synthesis { }
namespace System.Speech.Synthesis.TtsEngine { }
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
SpeechSynthesizer foo = new SpeechSynthesizer();
foo.Speak("Test");
}
}
}
edit:
hello,
i tried you code,but
using SpeechLib;
couldn't be found :>
well now i wrote:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Recognition;
using System.Speech.Synthesis;
using System.SpeechLib;
namespace System.SpeechLib { }
namespace System.Speech.Recognition { }
namespace System.Speech.AudioFormat {}
namespace System.Speech.Recognition.SrgsGrammar{}
namespace System.Speech.Synthesis { }
namespace System.Speech.Synthesis.TtsEngine { }
but I get an error with:
numericUpDown1,SpVoice,SpeechVoiceSpeakFlags,textBox1 and Timeout
Project + Add Reference, .NET tab, select "System.Speech".
A project template pre-selects several .NET assemblies. But only common ones, like System.dll, System.Core.dll, etcetera. You have to add the 'unusual' ones yourself.
you can try this:
get Interop.SpeechLib.dll
using SpeechLib;
private void ReadText(string readText)
{
int iCounter = 0;
while (Convert.ToInt32(numericUpDown1.Value) > iCounter)
{
SpVoice spVoice = new SpVoice();
spVoice.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak);
spVoice.WaitUntilDone(Timeout.Infinite);
iCounter = iCounter + 1;
}
}
Related
c# File handler error.I can't find it.
use SafeFileHandle filehandle -> error
I tried to copy it, but it didn't work out well.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Microsoft.Win32.SafeHandles;
namespace test
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("검색할 경로를 입력하세요.");
string result1 = Console.ReadLine();
Console.WriteLine("파일 확장자를 입력하세요.");
string result2 = Console.ReadLine();
Filehandle file1 = new Filehandle();
file1.FileCheck(result1,result2);
}
}
You need to install the package in your project before you can use it.
dotnet add package Microsoft.Win32.SafeHandles
how can i change signal value in CANoe from C# in Visual Studio? I don't want to make a test module and run it from CANoe, i just want to run from Visual Studio and signal value to be changed. I get this error when i'm trying to set a signal value:
Vector.CANoe.Runtime.Internal.DBTypeNotFoundException: 'The type SignalName could not be found in the configuration.'
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using Vector.PanelControlPlugin;
using NetworkDB;
using Vector.CANoe.Runtime;
using Vector.CANoe.Runtime.Internal;
using Vector.CANoe.Runtime.ValueEntitiesInternal;
using Vector.PostCompiler;
using Vector.CANoe.Sockets;
using Vector.CANoe.VTS;
using Vector.CANoe.VTSInternal;
using Vector.Diagnostics;
using NetworkDB;
namespace Demo
{
public class Class1// : IPanelControlPluginLibrary
{
[OnChange(typeof(NetworkDB.PAAK_WELCOME_LIGHTS))]
public static void OnSignalLockState()
{
double value = 1;
NetworkDB.PAAK_WELCOME_LIGHTS.Instance.GetValue();
}
static void Main(String[] args)
{
OnSignalLockState();
}
}
}
The assemblies Vector.CANoe.Runtime can only be used in .NET code which is run within CANoe, i.e. in Nodes, Tests, Snippets, etc.
If you want to interact with CANoe from outside you have to use the COM-Interface of CANoe.
I'm fairly new to c# and writing a simple selenium code which will go onto www.asos.com. I then click on the country on the right hand side by finding the xpath. When I click on the country I want to change the country to 'india' and the currency to 'USD', and then select my preference.
I'm getting exception for driver.FindElement, SelectElement, SelectByValue previously when using java I wasn't getting these exceptions.
Exception I see for driver = The name driver doesn't exist in the current context
SelectElement = the type or namespace name 'SelectElement' could not be found
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
namespace Exercise1
{
class Program
{
static void Main(string[] args)
{
IWebDriver webDriver = new ChromeDriver(#"Path to my chrome driver defined here");
webDriver.Navigate().GoToUrl("www.asos.com");
driver.FindElement(By.XPath("//*[#id="chrome - header"]/header/div[2]/div/ul/li[3]/div/button')]")).Click();
var country = driver.FindElement(By.Id("country"));
var select_country = new SelectElement(country);
select_country = SelectByValue("India");
var currency = driver.FindElement(By.Id("currency"));
var select_currency = new SelectElement(currency);
select_currency = SelectByValue("$ USD");
driver.FindElement(By.XPath("//*[#id="chrome - header"]/header/div[5]/div[2]/div/section/form/div[3]/button")).Click();
}
}
driver.FindElement(By.XPath("//*[#id="chrome - header"]/header/div[5]/div[2]/div/section/form/div[3]/button")).Click();
The erro in quotation marks, try:
driver.FindElement(By.XPath("//*[#id='chrome - header']/header/div[5]/div[2]/div/section/form/div[3]/button")).Click();
Use the value of the option in the html. Also call the select on the select element. For example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
namespace Exercise1
{
class Program
{
static void Main(string[] args)
{
IWebDriver driver= new ChromeDriver(#"Path to my chrome driver defined here");
driver.Navigate().GoToUrl("www.asos.com");
driver.FindElement(By.XPath("//*[#id='chrome - header']/header/div[2]/div/ul/li[3]/div/button')]")).Click();
var country = driver.FindElement(By.Id("country"));
var select_country = new SelectElement(country);
select_country.SelectByValue("IN");
var currency = driver.FindElement(By.Id("currency"));
var select_currency = new SelectElement(currency);
select_currency.SelectByValue("2");
driver.FindElement(By.XPath("//*[#id='chrome - header']/header/div[5]/div[2]/div/section/form/div[3]/button")).Click();
}
}
You may also want to throw in some waits to give the page time to load.
I have couple questions about referencing methods / variables between two or more *.cs files. I know that there are similar topics, but I still don't quite understand what is going on.
I'm using Visual Studio Community 2015.
So here is the problem. I have 2 files, those files are First.cs and Second.cs. They are saved in completely different, known locations on hard disc.
Inside First.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Forum
{
class First
{
static void Main(string[] args)
{
}
public int GiveMeNumber()
{
return 5;
}
}
}
Inside Second.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Forum
{
class Second
{
int number = // method from file First.cs
}
}
How do I access method GiveMeNumber() from First.cs in Second.cs as assignment for int number? How do I tell my compiler where are those files?
Thanks for any help :)
Like Alex said in his comment.
You can create a solution/project, add existing item, and browse to your first.cs and second.cs.
Mark both files with the public-keyword
for example:
namespace Forum
{
public class Second
{
int number = // method from file First.cs
}
}
Then both class can be used within each other.
So you could do
var first = new First();
var number = first.GiveMeNumber();
you probably want to do it the other way around, because I think you have a console app where your First class has a main-method.
does that help>?
I'm attempting to grab a device handle on the Synaptics Touchpad using the Synaptics SDK, specifically using methods in the SYNCTRLLib.
However, the SYNCTRL method failed to find it, returning -1.
Syn.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SYNCOMLib;
using SYNCTRLLib;
namespace TP_Test1
{
class Syn
{
SynAPICtrl SynTP_API = new SynAPICtrl();
SynDeviceCtrl SynTP_Dev = new SynDeviceCtrl();
SynPacketCtrl SynTP_Pack = new SynPacketCtrl();
int DeviceHandle;
//Constructor
public Syn ()
{
SynTP_API.Initialize();
SynTP_API.Activate();
//DeviceHandle == -1 ? Can't find device?
DeviceHandle = SynTP_API.FindDevice(new SynConnectionType(), new SynDeviceType(), 0);
//Below line causing Unhandled Exception
SynTP_Dev.Select(DeviceHandle);
SynTP_Dev.Activate();
SynTP_Dev.OnPacket += SynTP_Dev_OnPacket;
}
public void SynTP_Dev_OnPacket()
{
Console.WriteLine(SynTP_Pack.FingerState);
Console.WriteLine(SynTP_Pack.X);
Console.WriteLine(SynTP_Pack.Y);
}
}
}
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SYNCOMLib;
using SYNCTRLLib;
namespace TP_Test1
{
class Program
{
static void Main(string[] args)
{
Syn mySyn = new Syn();
mySyn.SynTP_Dev_OnPacket();
}
}
}
I see that you are using the C# wrappers for Synaptics SDK. Even though CPP code might be not trivial to you, you might want to take a look at the file Samples/ComTest.cpp. It contains some example logic in order to find devices, more specifically at lines 66-76:
// Find a device, preferentially a TouchPad or Styk.
ISynDevice *pDevice = 0;
long lHandle = -1;
if ((pAPI->FindDevice(SE_ConnectionAny, SE_DeviceTouchPad, &lHandle) &&
pAPI->FindDevice(SE_ConnectionAny, SE_DeviceStyk, &lHandle) &&
pAPI->FindDevice(SE_ConnectionAny, SE_DeviceAny, &lHandle)) ||
pAPI->CreateDevice(lHandle, &pDevice))
{
printf("Unable to find a Synaptics Device.\n");
exit(-1);
}
Also, make sure you have registered the dlls. According to the ReadSynSDK.txt file:
For certain purposes it may be necessary to register the dlls
that are provided with the SDK. This can be done with the windows regsvr32
utility.