Update to upstream 6e5f9365f0
Remove windows screen reader (probably not a good idea to have separate access forks, but this works for now.) Send rate when initialising speech (TODO: expose this via a config parameter)master
parent
4af19aeb7a
commit
44f31419b0
|
@ -6,16 +6,9 @@ namespace stardew_access.ScreenReader
|
|||
{
|
||||
public IScreenReader Initialize()
|
||||
{
|
||||
IScreenReader ScreenReader = new ScreenReaderWindows(); // Default is windows
|
||||
IScreenReader ScreenReader = new ScreenReaderMac(); // Mac by default
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
ScreenReaderWindows screenReaderWindows = new ScreenReaderWindows();
|
||||
screenReaderWindows.InitializeScreenReader();
|
||||
|
||||
ScreenReader = screenReaderWindows;
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
ScreenReaderLinux screenReaderLinux = new ScreenReaderLinux();
|
||||
screenReaderLinux.InitializeScreenReader();
|
||||
|
|
|
@ -11,40 +11,42 @@ namespace stardew_access.ScreenReader
|
|||
|
||||
public string PrevTextTile
|
||||
{
|
||||
get;
|
||||
set;
|
||||
get { return prevTextTile; }
|
||||
set { prevTextTile = value; }
|
||||
}
|
||||
|
||||
public string prevText = "", prevTextTile = " ", prevChatText = "", prevMenuText = "";
|
||||
|
||||
public void InitializeScreenReader()
|
||||
{
|
||||
MainClass.GetMonitor().Log("Screen reader initialized");
|
||||
MainClass.InfoLog("Screen reader initialized");
|
||||
_speakProcess = new Process();
|
||||
_speakProcess.StartInfo.FileName = "mac";
|
||||
_speakProcess.StartInfo.Verb = "mac";
|
||||
_speakProcess.StartInfo.RedirectStandardInput = true;
|
||||
_speakProcess.Start();
|
||||
// set rate (probably should be done through a config parameter)
|
||||
_speakProcess.StandardInput.WriteLine("r600");
|
||||
Speak("Mac screen reader ready", true);
|
||||
}
|
||||
|
||||
public void CloseScreenReader()
|
||||
{
|
||||
MainClass.GetMonitor().Log("Screen reader closed");
|
||||
MainClass.InfoLog("Screen reader closed");
|
||||
_speakProcess.Kill();
|
||||
}
|
||||
|
||||
public void Say(string text, bool interrupt)
|
||||
{
|
||||
if (text == null) return;
|
||||
MainClass.GetMonitor().Log($"{text}");
|
||||
MainClass.InfoLog($"{text}");
|
||||
Speak(text, interrupt);
|
||||
}
|
||||
|
||||
public void SayWithChecker(string text, bool interrupt)
|
||||
{
|
||||
if (text == null) return;
|
||||
MainClass.GetMonitor().Log($"{text}");
|
||||
MainClass.InfoLog($"{text}");
|
||||
if (text != prevText)
|
||||
{
|
||||
Speak(text, interrupt);
|
||||
|
@ -55,7 +57,7 @@ namespace stardew_access.ScreenReader
|
|||
public void SayWithMenuChecker(string text, bool interrupt)
|
||||
{
|
||||
if (text == null) return;
|
||||
MainClass.GetMonitor().Log($"{text}");
|
||||
MainClass.InfoLog($"{text}");
|
||||
if (text != prevMenuText)
|
||||
{
|
||||
Speak(text, interrupt);
|
||||
|
@ -66,7 +68,7 @@ namespace stardew_access.ScreenReader
|
|||
public void SayWithChatChecker(string text, bool interrupt)
|
||||
{
|
||||
if (text == null) return;
|
||||
MainClass.GetMonitor().Log($"{text}");
|
||||
MainClass.InfoLog($"{text}");
|
||||
if (text != prevChatText)
|
||||
{
|
||||
Speak(text, interrupt);
|
||||
|
@ -77,7 +79,7 @@ namespace stardew_access.ScreenReader
|
|||
public void SayWithTileQuery(string text, int x, int y, bool interrupt)
|
||||
{
|
||||
if (text == null) return;
|
||||
MainClass.GetMonitor().Log($"{text}");
|
||||
MainClass.InfoLog($"{text}");
|
||||
if (text != prevTextTile)
|
||||
{
|
||||
Speak(text, interrupt);
|
||||
|
|
|
@ -19,26 +19,26 @@ namespace stardew_access.ScreenReader
|
|||
|
||||
public void InitializeScreenReader()
|
||||
{
|
||||
MainClass.GetMonitor().Log("Screen reader initialized");
|
||||
MainClass.InfoLog("Screen reader initialized");
|
||||
Speak("Mac screen reader ready", true);
|
||||
}
|
||||
|
||||
public void CloseScreenReader()
|
||||
{
|
||||
MainClass.GetMonitor().Log("Screen reader closed");
|
||||
MainClass.InfoLog("Screen reader closed");
|
||||
}
|
||||
|
||||
public void Say(string text, bool interrupt)
|
||||
{
|
||||
if (text == null) return;
|
||||
MainClass.GetMonitor().Log($"{text}");
|
||||
MainClass.InfoLog($"{text}");
|
||||
Speak(text, interrupt);
|
||||
}
|
||||
|
||||
public void SayWithChecker(string text, bool interrupt)
|
||||
{
|
||||
if (text == null) return;
|
||||
MainClass.GetMonitor().Log($"{text}");
|
||||
MainClass.InfoLog($"{text}");
|
||||
if (text != prevText) {
|
||||
Speak(text, interrupt);
|
||||
prevText = text;
|
||||
|
@ -48,7 +48,7 @@ namespace stardew_access.ScreenReader
|
|||
public void SayWithMenuChecker(string text, bool interrupt)
|
||||
{
|
||||
if (text == null) return;
|
||||
MainClass.GetMonitor().Log($"{text}");
|
||||
MainClass.InfoLog($"{text}");
|
||||
if (text != prevMenuText) {
|
||||
Speak(text, interrupt);
|
||||
prevMenuText = text;
|
||||
|
@ -58,7 +58,7 @@ namespace stardew_access.ScreenReader
|
|||
public void SayWithChatChecker(string text, bool interrupt)
|
||||
{
|
||||
if (text == null) return;
|
||||
MainClass.GetMonitor().Log($"{text}");
|
||||
MainClass.InfoLog($"{text}");
|
||||
if (text != prevChatText) {
|
||||
Speak(text, interrupt);
|
||||
prevChatText = text;
|
||||
|
@ -68,7 +68,7 @@ namespace stardew_access.ScreenReader
|
|||
public void SayWithTileQuery(string text, int x, int y, bool interrupt)
|
||||
{
|
||||
if (text == null) return;
|
||||
MainClass.GetMonitor().Log($"{text}");
|
||||
MainClass.InfoLog($"{text}");
|
||||
if (text != prevTextTile) {
|
||||
Speak(text, interrupt);
|
||||
prevTextTile = text;
|
||||
|
|
|
@ -1,106 +0,0 @@
|
|||
using DavyKager;
|
||||
|
||||
namespace stardew_access.ScreenReader
|
||||
{
|
||||
public class ScreenReaderWindows : IScreenReader
|
||||
{
|
||||
private bool isLoaded = false;
|
||||
public string prevText = "", prevTextTile = " ", prevChatText = "", prevMenuText = "";
|
||||
|
||||
public string PrevTextTile
|
||||
{
|
||||
get { return prevTextTile; }
|
||||
set { prevTextTile = value; }
|
||||
}
|
||||
|
||||
public void InitializeScreenReader()
|
||||
{
|
||||
MainClass.InfoLog("Initializing Tolk...");
|
||||
Tolk.TrySAPI(true);
|
||||
Tolk.Load();
|
||||
|
||||
MainClass.InfoLog("Querying for the active screen reader driver...");
|
||||
string name = Tolk.DetectScreenReader();
|
||||
if (name != null)
|
||||
{
|
||||
MainClass.InfoLog($"The active screen reader driver is: {name}");
|
||||
isLoaded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MainClass.ErrorLog("None of the supported screen readers is running");
|
||||
isLoaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseScreenReader()
|
||||
{
|
||||
if (isLoaded)
|
||||
{
|
||||
Tolk.Unload();
|
||||
isLoaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Say(string text, bool interrupt)
|
||||
{
|
||||
if (text == null)
|
||||
return;
|
||||
|
||||
if (!isLoaded)
|
||||
return;
|
||||
|
||||
if (!MainClass.Config.TTS)
|
||||
return;
|
||||
|
||||
if (text.Contains('^')) text = text.Replace('^', '\n');
|
||||
|
||||
if (Tolk.Output(text, interrupt))
|
||||
{
|
||||
MainClass.DebugLog($"Speaking(interrupt: {interrupt}) = {text}");
|
||||
}
|
||||
else
|
||||
{
|
||||
MainClass.ErrorLog($"Failed to output text: {text}");
|
||||
}
|
||||
}
|
||||
|
||||
public void SayWithChecker(string text, bool interrupt)
|
||||
{
|
||||
if (prevText != text)
|
||||
{
|
||||
prevText = text;
|
||||
Say(text, interrupt);
|
||||
}
|
||||
}
|
||||
|
||||
public void SayWithMenuChecker(string text, bool interrupt)
|
||||
{
|
||||
if (prevMenuText != text)
|
||||
{
|
||||
prevMenuText = text;
|
||||
Say(text, interrupt);
|
||||
}
|
||||
}
|
||||
|
||||
public void SayWithChatChecker(string text, bool interrupt)
|
||||
{
|
||||
if (prevChatText != text)
|
||||
{
|
||||
prevChatText = text;
|
||||
Say(text, interrupt);
|
||||
}
|
||||
}
|
||||
|
||||
public void SayWithTileQuery(string text, int x, int y, bool interrupt)
|
||||
{
|
||||
string query = $"{text} x:{x} y:{y}";
|
||||
|
||||
if (prevTextTile != query)
|
||||
{
|
||||
prevTextTile = query;
|
||||
Say(text, interrupt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue