Skip to content

Commit

Permalink
add pause/resume commands
Browse files Browse the repository at this point in the history
  • Loading branch information
fiendish committed Jun 3, 2021
1 parent d3954b1 commit d0173de
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@

Easy text-to-speech in Lua with MS SAPI ( https://en.wikipedia.org/wiki/Microsoft_Speech_API ).

### Dependencies
## Dependencies

LuaCOM ( https://github.com/davidm/luacom )

### Note for use on non-Microsoft systems with Wine

SAPI speech functionality depends on the Microsoft Speech API, which is not included by default in Wine, and SpeechSDK51.exe must be separately installed.
You can download it from https://download.microsoft.com/download/B/4/3/B4314928-7B71-4336-9DE7-6FA4CF00B7B3/SpeechSDK51.exe
You can install it with `winetricks speechsdk` or download it from https://download.microsoft.com/download/B/4/3/B4314928-7B71-4336-9DE7-6FA4CF00B7B3/SpeechSDK51.exe

## API

# API
| Function | Arguments | Returns | Description |
| --- | --- | --- | --- |
| say | *string* message | | Speak the given string. |
| pause | | | Pause speaking. |
| resume | | | Resume speaking. |
| skip_sentence | | | Stop speaking the current line and move to the next line in the SAPI buffer. |
| skip_all | | | Stop speaking and clear the SAPI buffer. |
| set_voice_by_number | *int* SAPI_index, [*bool* quietly] | *int* SAPI_index, *string* SAPI_ID | Choose the SAPI voice indexed from 1 to n |
Expand All @@ -38,7 +43,8 @@ You can download it from https://download.microsoft.com/download/B/4/3/B4314928-
| --- | --- |
| replacements | Table of tables in the form {*string* pattern, *string* replacement} for filtering level 3 via string.gsub. |

# Usage Example
## Usage Example

```lua
sapi_interface = require "sapi_interface"

Expand Down
14 changes: 14 additions & 0 deletions sapi_interface.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ local function say (what)
end


local function pause ()
engine:Pause()
end


local function resume ()
engine:Resume()
end


local function list_filtering_levels ()
say("Filtering level options are:")
for i,v in ipairs(filter_descs) do
Expand All @@ -150,6 +160,7 @@ local function list_filtering_levels ()
say("Level "..tostring(#filter_descs).." is recommended.")
end


local function list_voices ()
local enumerate_voices = luacom.GetEnumerator(engine:GetVoices())
local voice = enumerate_voices:Next()
Expand Down Expand Up @@ -321,6 +332,8 @@ end

return {
say = say,
pause = pause,
resume = resume,
skip_sentence = skip_sentence,
skip_all = skip_all,
set_voice_by_number = set_voice_by_number,
Expand All @@ -343,3 +356,4 @@ return {
replacements = replacements,
print_spoken = print_spoken -- for debugging
}

0 comments on commit d0173de

Please sign in to comment.