Skip to content

Commit

Permalink
Use announce() for speech on Windows
Browse files Browse the repository at this point in the history
This uses announce() for speech on Windows, and removes the trigger and event handler.
  • Loading branch information
tspivey committed Jul 12, 2022
1 parent 02b4b85 commit 38f8c05
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/keys/reader/curline.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
reader.stop()
local line = getLines(reader.line, reader.line + 1)[1]
ttsQueue(line)
reader.say(line, true)
3 changes: 1 addition & 2 deletions src/keys/reader/lastline.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
reader.stop()
-- We subtract 1 here because of the always blank line at the end.
reader.line = getLineCount() - 1
local line = getLines(reader.line, reader.line + 1)[1]
ttsQueue(line)
reader.say(line, true)
5 changes: 2 additions & 3 deletions src/keys/reader/nextline.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
reader.stop()
reader.line = reader.line + 1
-- We subtract 1 here because of the always blank line at the end.
if reader.line > getLineCount() - 1 then
ttsQueue("Bottom")
reader.say("Bottom", true)
reader.line = getLineCount() - 1
end
local line = getLines(reader.line, reader.line + 1)[1]
ttsQueue(line)
reader.say(line)
5 changes: 2 additions & 3 deletions src/keys/reader/prevline.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
reader.stop()
reader.line = reader.line - 1
if reader.line < 0 then
ttsQueue("Top")
reader.say("Top", true)
reader.line = 0
end
local line = getLines(reader.line, reader.line + 1)[1]
ttsQueue(line)
reader.say(line)
25 changes: 20 additions & 5 deletions src/scripts/reader/code.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ function reader:install_trigger()
end
reader.trigger_id = tempRegexTrigger("^", f)
end
tempTimer(0, function() reader:install_trigger() end)
if getOS() ~= "windows" then
tempTimer(0, function() reader:install_trigger() end)
end
function reader.remove(event, pkg)
if pkg ~= "reader" then
return true -- keep our handler around
Expand All @@ -29,9 +31,22 @@ function reader.stop()
ttsClearQueue()
ttsSkip()
end
reader.send_event = registerAnonymousEventHandler("sysDataSendRequest", function()
if command then
function reader.say(text, interrupt)
if getOS() == "windows" then
announce(text)
return
end
if interrupt then
reader.stop()
end
end)
setConfig("announceIncomingText", false)
ttsQueue(text)
end

if getOS() ~= "windows" then
reader.send_event = registerAnonymousEventHandler("sysDataSendRequest", function()
if command then
reader.stop()
end
end)
setConfig("announceIncomingText", false)
end

0 comments on commit 38f8c05

Please sign in to comment.