- Home /
How to get .exe file to run through script?
I'm trying to implement text to speech through eSpeak into Unity (I'm on Windows). I've imported the eSpeak files into unity and I've made a script that I want to play the sound. This is what it looks like:
import System.Diagnostics;
var speak = "Hello";
function Start () {
var proc = new Process();
proc.StartInfo.FileName = "eSpeak/command_line/espeak.exe -s80 "+speak;
proc.Start();
}
Whenever I run it, I get the error "Win32Exception: The system cannot find the file specified." I tried it without the tags and it still doesn't work, so it might have to do with the path. The eSpeak folder is in the Assets folder and not any subfolders, and I tried putting in the full path from C:/, but that didn't work either. I'd appreciate any help.
Edit: I tried this instead:
import System.Diagnostics;
var speak = "Hello";
function Start () {
System.Diagnostics.Process.Start(Application.dataPath + "/eSpeak/command_line/espeak.exe);
}
It worked, but if I add the tags to the end of the path, it doesn't. Is there a way to get the tags to also work?
Answer by LukaKotar · Sep 30, 2017 at 02:00 AM
Try assigning the arguments (which you referred to as tags) to the proc.StartInfo.Arguments
field instead:
import System.Diagnostics;
var speak = "Hello";
function Start () {
var proc = new Process();
proc.StartInfo.FileName = Application.dataPath + "eSpeak/command_line/espeak.exe";
proc.StartInfo.Arguments = "-s80 "+speak;
proc.Start();
}