From d0173dea790b2745351541bd89ff8335055e8e23 Mon Sep 17 00:00:00 2001 From: Avi Kelman Date: Thu, 3 Jun 2021 11:46:53 -0600 Subject: [PATCH] add pause/resume commands --- README.md | 14 ++++++++++---- sapi_interface.lua | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7ba9d92..369a85b 100644 --- a/README.md +++ b/README.md @@ -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 | @@ -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" diff --git a/sapi_interface.lua b/sapi_interface.lua index 96bb2f6..8a9e8bc 100644 --- a/sapi_interface.lua +++ b/sapi_interface.lua @@ -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 @@ -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() @@ -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, @@ -343,3 +356,4 @@ return { replacements = replacements, print_spoken = print_spoken -- for debugging } +