From 8834269fee80c7d70a5cd4c0f5f6d578d1c0a2e7 Mon Sep 17 00:00:00 2001 From: Rose Liverman Date: Tue, 22 Sep 2026 20:36:03 -0600 Subject: [PATCH] testing with voices! --- book.json | 4 ++-- macos_say-en.json | 34 +++++++++++++++++++++++++++++++ src/main.lua | 52 +++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 macos_say-en.json diff --git a/book.json b/book.json index c05bf15..3ecbbef 100644 --- a/book.json +++ b/book.json @@ -1,4 +1,4 @@ { - "total_pages": 500, - "current_page": 0 + "current_page":0, + "total_pages":500 } diff --git a/macos_say-en.json b/macos_say-en.json new file mode 100644 index 0000000..bb972ed --- /dev/null +++ b/macos_say-en.json @@ -0,0 +1,34 @@ +[ + "Albert", + "Bad News", + "Bahh", + "Boing", + "Cellos", + "Daniel", + "Wobble", + "Eddy", + "Ellen", + "Flo", + "Fred", + "Good News", + "Grandma", + "Junior", + "Karen", + "Kathy", + "Moira", + "Organ", + "Superstar", + "Ralph", + "Reed", + "Rishi", + "Rocko", + "Samantha", + "Sandy", + "Shelley", + "Tara", + "Tessa", + "Trinoids", + "Whisper", + "Yelda", + "Zarvox" +] diff --git a/src/main.lua b/src/main.lua index 1755c23..ebc5714 100644 --- a/src/main.lua +++ b/src/main.lua @@ -1,5 +1,6 @@ local window_width, window_height = love.graphics.getDimensions() +-- local filament = require "lib.filament" local log = require "lib.log" local lovebird = require "lib.lovebird" local progress_bar = require "lib.progress_bar" @@ -9,13 +10,54 @@ local utility = require "lib.utility" lovebird.whitelist[#lovebird.whitelist + 1] = "192.168.*.*" -- LAN access log{ - testing = true, + debug = true, } local constants = require "data.constants" local classes, class_names = require "data.classes" local races, race_names = require "data.races" +local voices = utility.load_data("macos_say-en.json") +local voice_int = 0 +local send_test_message = function() + -- local selected_voice = voices[math.random(1, #voices)] + voice_int = voice_int + 1 + if voice_int > #voices then voice_int = 1 end + local selected_voice = voices[voice_int] + + local test_channel = love.thread.getChannel("say") + local line = "Hello, my name is " .. selected_voice .. "." + test_channel:push({ + voice = selected_voice:enquote(), + line = line:enquote(), + }) + log("debug", selected_voice, line) +end +send_test_message() + +-- filament.run(function() +-- local line = "Hello, my name is " .. selected_voice .. "." +-- os.execute("say -v " .. selected_voice:enquote() .. " " .. line:enquote()) +-- end) +-- local test_thread = love.thread.newThread([[ +-- -- local utility = require "lib.utility" +-- -- local voices = utility.load_data("macos_say-en.json") +-- -- local selected_voice = voices[math.random(1, #voices)] +-- local selected_voice = "Bells" +-- local line = "Hello, my name is " .. selected_voice .. "." +-- os.execute("say -v \"" .. selected_voice .. "\" \"" .. line .. "\"") +-- ]]) +local test_thread = love.thread.newThread([[ + local channel = love.thread.getChannel("say") + while true do + local message = channel:demand() + if message then + os.execute("say -v " .. message.voice .. " " .. message.line) + end + end +]]) +test_thread:start() + local new_character = function(name) local base_stat_roll = function() return 3 + math.random(1, 6) + math.random(1, 6) + math.random(1, 6) @@ -74,7 +116,7 @@ local test_bar = progress_bar(0, window_height - constants.progress_bar_height * local test_message = "This is a test text string of significant length. It exists to test printing over a progress bar." test_bar:set_text(test_message) -local test_timer = timer.every(#test_message * constants.reading_time_multiplier, function() log("testing", "The timer completed.") end) -- TODO consider making timer not need a function; cause I don't here! +local test_timer = timer.every(#test_message * constants.reading_time_multiplier, function() log("debug", "The timer completed.") end) -- TODO consider making timer not need a function; cause I don't here! local task_queue task_queue = { @@ -99,6 +141,10 @@ love.update = function(dt) timer.update(dt) test_bar:set_progress(test_timer.run_time / test_timer:get_interval()) + local thread_error = test_thread:getError() + if thread_error then + log("debug", thread_error) + end end love.draw = function() @@ -116,5 +162,7 @@ love.keypressed = function(key) update_book_progress(-1) elseif key == "right" then update_book_progress(1) + elseif key == "v" then + send_test_message() end end