1using System.Collections;
2using System.Collections.Generic;
3using System.Diagnostics;
11 private static string[] languages;
13 public static void Initialize()
15 var startInfo =
new ProcessStartInfo()
17 FileName = Path.Combine(Application.streamingAssetsPath,
"UnityTTSHelper.exe"),
19 CreateNoWindow =
true,
23 Process.Start(startInfo);
28 public static Process Speak(
string text,
string language =
"hu-HU")
30 var startInfo =
new ProcessStartInfo()
32 FileName = Path.Combine(Application.streamingAssetsPath,
"UnityTTSHelper.exe"),
33 Arguments = $
"-l {language} {text}",
34 CreateNoWindow =
true,
38 return Process.Start(startInfo);
43 public static Process SpeakToFile(
string text ,
string fileName =
"output.wav",
string language =
"hu-HU")
45 var startInfo =
new ProcessStartInfo()
47 FileName = Path.Combine(Application.streamingAssetsPath,
"UnityTTSHelper.exe"),
48 Arguments = $
"-l {language} -s {fileName} {text}",
49 CreateNoWindow =
true,
54 return Process.Start(startInfo);
59 public static string[] InstalledLanguages()
61 if (languages !=
null)
65 var startInfo =
new ProcessStartInfo()
67 FileName = Path.Combine(Application.streamingAssetsPath,
"UnityTTSHelper.exe"),
69 CreateNoWindow =
true,
70 RedirectStandardOutput =
true,
71 RedirectStandardError =
true,
72 UseShellExecute =
false,
74 var process = Process.Start(startInfo);
75 process.WaitForExit(2500);
76 var stdout = process.StandardOutput.ReadToEnd();
77 var stderr = process.StandardError.ReadToEnd();
79 if (
string.IsNullOrEmpty(stderr))
80 Debug.LogError(stderr);
82 if (
string.IsNullOrEmpty(stdout))
86 if (stdout.Contains(
";"))
88 languages = stdout.Split(
';');
92 languages =
new[] {stdout};