Switch to tdsr speech server
parent
a83e1a79a1
commit
2c845abb23
|
@ -20,12 +20,18 @@ namespace stardew_access.ScreenReader
|
||||||
public void InitializeScreenReader()
|
public void InitializeScreenReader()
|
||||||
{
|
{
|
||||||
MainClass.GetMonitor().Log("Screen reader initialized");
|
MainClass.GetMonitor().Log("Screen reader initialized");
|
||||||
|
_speakProcess = new Process();
|
||||||
|
_speakProcess.StartInfo.FileName = "mac";
|
||||||
|
_speakProcess.StartInfo.Verb = "mac";
|
||||||
|
_speakProcess.StartInfo.RedirectStandardInput = true;
|
||||||
|
_speakProcess.Start();
|
||||||
Speak("Mac screen reader ready", true);
|
Speak("Mac screen reader ready", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CloseScreenReader()
|
public void CloseScreenReader()
|
||||||
{
|
{
|
||||||
MainClass.GetMonitor().Log("Screen reader closed");
|
MainClass.GetMonitor().Log("Screen reader closed");
|
||||||
|
_speakProcess.Kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Say(string text, bool interrupt)
|
public void Say(string text, bool interrupt)
|
||||||
|
@ -39,7 +45,8 @@ namespace stardew_access.ScreenReader
|
||||||
{
|
{
|
||||||
if (text == null) return;
|
if (text == null) return;
|
||||||
MainClass.GetMonitor().Log($"{text}");
|
MainClass.GetMonitor().Log($"{text}");
|
||||||
if (text != prevText) {
|
if (text != prevText)
|
||||||
|
{
|
||||||
Speak(text, interrupt);
|
Speak(text, interrupt);
|
||||||
prevText = text;
|
prevText = text;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +56,8 @@ namespace stardew_access.ScreenReader
|
||||||
{
|
{
|
||||||
if (text == null) return;
|
if (text == null) return;
|
||||||
MainClass.GetMonitor().Log($"{text}");
|
MainClass.GetMonitor().Log($"{text}");
|
||||||
if (text != prevMenuText) {
|
if (text != prevMenuText)
|
||||||
|
{
|
||||||
Speak(text, interrupt);
|
Speak(text, interrupt);
|
||||||
prevMenuText = text;
|
prevMenuText = text;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +67,8 @@ namespace stardew_access.ScreenReader
|
||||||
{
|
{
|
||||||
if (text == null) return;
|
if (text == null) return;
|
||||||
MainClass.GetMonitor().Log($"{text}");
|
MainClass.GetMonitor().Log($"{text}");
|
||||||
if (text != prevChatText) {
|
if (text != prevChatText)
|
||||||
|
{
|
||||||
Speak(text, interrupt);
|
Speak(text, interrupt);
|
||||||
prevChatText = text;
|
prevChatText = text;
|
||||||
}
|
}
|
||||||
|
@ -69,28 +78,21 @@ namespace stardew_access.ScreenReader
|
||||||
{
|
{
|
||||||
if (text == null) return;
|
if (text == null) return;
|
||||||
MainClass.GetMonitor().Log($"{text}");
|
MainClass.GetMonitor().Log($"{text}");
|
||||||
if (text != prevTextTile) {
|
if (text != prevTextTile)
|
||||||
|
{
|
||||||
Speak(text, interrupt);
|
Speak(text, interrupt);
|
||||||
prevTextTile = text;
|
prevTextTile = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Speak(string text, bool interupt) {
|
private void Speak(string text, bool interupt)
|
||||||
if (interupt) {
|
{
|
||||||
if (_speakProcess != null) {
|
if (interupt)
|
||||||
_speakProcess.Kill();
|
{
|
||||||
_speakProcess = null;
|
_speakProcess.StandardInput.WriteLine("x");
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_speakProcess == null) {
|
|
||||||
_speakProcess = new Process();
|
|
||||||
_speakProcess.StartInfo.FileName = "say";
|
|
||||||
_speakProcess.StartInfo.Verb = "say";
|
|
||||||
_speakProcess.StartInfo.RedirectStandardInput = true;
|
|
||||||
_speakProcess.StartInfo.Arguments = text;
|
|
||||||
_speakProcess.Start();
|
|
||||||
}
|
}
|
||||||
|
_speakProcess.StandardInput.WriteLine($"s{text}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,96 @@
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace stardew_access.ScreenReader
|
||||||
|
{
|
||||||
|
public class ScreenReaderMacOld : IScreenReader
|
||||||
|
{
|
||||||
|
private Process? _speakProcess;
|
||||||
|
|
||||||
|
|
||||||
|
public string PrevTextTile
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string prevText = "", prevTextTile = " ", prevChatText = "", prevMenuText = "";
|
||||||
|
|
||||||
|
public void InitializeScreenReader()
|
||||||
|
{
|
||||||
|
MainClass.GetMonitor().Log("Screen reader initialized");
|
||||||
|
Speak("Mac screen reader ready", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseScreenReader()
|
||||||
|
{
|
||||||
|
MainClass.GetMonitor().Log("Screen reader closed");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Say(string text, bool interrupt)
|
||||||
|
{
|
||||||
|
if (text == null) return;
|
||||||
|
MainClass.GetMonitor().Log($"{text}");
|
||||||
|
Speak(text, interrupt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SayWithChecker(string text, bool interrupt)
|
||||||
|
{
|
||||||
|
if (text == null) return;
|
||||||
|
MainClass.GetMonitor().Log($"{text}");
|
||||||
|
if (text != prevText) {
|
||||||
|
Speak(text, interrupt);
|
||||||
|
prevText = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SayWithMenuChecker(string text, bool interrupt)
|
||||||
|
{
|
||||||
|
if (text == null) return;
|
||||||
|
MainClass.GetMonitor().Log($"{text}");
|
||||||
|
if (text != prevMenuText) {
|
||||||
|
Speak(text, interrupt);
|
||||||
|
prevMenuText = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SayWithChatChecker(string text, bool interrupt)
|
||||||
|
{
|
||||||
|
if (text == null) return;
|
||||||
|
MainClass.GetMonitor().Log($"{text}");
|
||||||
|
if (text != prevChatText) {
|
||||||
|
Speak(text, interrupt);
|
||||||
|
prevChatText = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SayWithTileQuery(string text, int x, int y, bool interrupt)
|
||||||
|
{
|
||||||
|
if (text == null) return;
|
||||||
|
MainClass.GetMonitor().Log($"{text}");
|
||||||
|
if (text != prevTextTile) {
|
||||||
|
Speak(text, interrupt);
|
||||||
|
prevTextTile = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Speak(string text, bool interupt) {
|
||||||
|
if (interupt) {
|
||||||
|
if (_speakProcess != null) {
|
||||||
|
_speakProcess.Kill();
|
||||||
|
_speakProcess = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_speakProcess == null) {
|
||||||
|
_speakProcess = new Process();
|
||||||
|
_speakProcess.StartInfo.FileName = "say";
|
||||||
|
_speakProcess.StartInfo.Verb = "say";
|
||||||
|
_speakProcess.StartInfo.RedirectStandardInput = true;
|
||||||
|
_speakProcess.StartInfo.Arguments = text;
|
||||||
|
_speakProcess.Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue