I’m using Unity 3.5.6 on a Mac and am trying to write a Unity script that runs a shell-script in the OSX terminal, in order to use OSX’s built in text-to-speech function. I’ve tried adding the following to the update function:
The script talk.sh contains:
osascript -e ‘say “halløjsa” using “Ida”’
When i run it, nothing happens. However if i delete the argument “sh talk.sh” a terminal window opens. If i replace with Start(“/applications/safari”, “http://google.com”) it also works fine.
I’ve also tried:
B: System.Diagnostics.Process.Start(“/applications/utilities/terminal.app”, “say hi”);
C: System.Diagnostics.Process.Start(“usr/bin/osascript”, “-e say hi”);
But still no luck. Any help or suggestions would be much appreciated.
PS: I’ve also tried opening a browser with google translate’s tts, which somehow works, but it’s restricted to 100 characters.
Thanks! I got it to work using the open command. However i would like to start the process in either a hidden- or minimised window, but it seems to ignore ProcessWindowStyle.Minimized. The way it is now, it will open the terminal window on top of the unity application while pausing the game.
using UnityEngine;
using System.Collections;
using System.Diagnostics;
public class talk : MonoBehaviour {
void Start () {
ProcessStartInfo proc = new ProcessStartInfo();
proc.FileName = "open";
proc.WorkingDirectory = "/users/myUserName";
proc.Arguments = "talk.sh";
proc.WindowStyle = ProcessWindowStyle.Minimized;
proc.CreateNoWindow = true;
Process.Start(proc);
UnityEngine.Debug.Log("Halløjsa");
}
void Update () {
}
}