Page 1 of 1
Text to speech
Posted: Mon May 01, 2023 1:45 pm
by togFox
Much googling tells me TTS is a very under-developed space for lua and Love and the best I could find was this command line app that can run locally:
https://github.com/espeak-ng/espeak-ng/ ... s/index.md
I've never thought about how I might have my game in Love2d doing the regular game loop thing and then occasionally executing a command line outside the program.
Let's assume the command line is visually hidden and non-interrupting. Would launching a command line program with command and parameters from Love2d be possible?
I'm expecting a less than stellar gaming experience but might be a fun experiment.
Re: Text to speech
Posted: Mon May 01, 2023 2:00 pm
by BrotSagtMist
Congrats to your 666th post.
What do you ask here? Having löve run another program constantly in the background?
That would be io.popen inside a thread, not too hard.
In that case it doesnt matter what language it is in anyway.
Re: Text to speech
Posted: Mon May 01, 2023 2:31 pm
by BrotSagtMist
I tried with popen to no luck. This works tho, kinda funny.
Code: Select all
local op=print
local channel=love.thread.newChannel()
local tcode=[[
channel = ...
repeat
text=os.execute("espeak '"..channel:demand().."'")
until false
]]
Lthread = love.thread.newThread( tcode )
Lthread:start(channel)
print=function(...) channel:push(table.concat({...})," ") op(...) end
Tx=""
function love.textinput(t)
Tx=Tx..t
end
function love.keypressed(_,k)
if k=="return" then
print(Tx)
Tx=""
end
end
Edit: I missed the buffer for popen:
Code: Select all
local tcode=[[
channel = ...
handle=io.popen("espeak","w")
handle:setvbuf ("no")
repeat
handle:write(channel:demand().."\n")
until false
]]
Re: Text to speech
Posted: Mon May 01, 2023 3:17 pm
by zorg
If you don't care much about quality (that is, humanlike sounding output), then technically you could implement a "simple" (relatively, that is) tts like SAM; source code has been available for some time, just needs some porting to lua; there's already a js version available, besides the C source.
Also, löve supports queueable sources, so you can technically generate sound realtime as well; that includes speech.
Re: Text to speech
Posted: Tue May 02, 2023 2:31 am
by togFox
Thanks. I have since found what seems to be the real solution (for Windows) and that is to use the speech API:
https://github.com/fiendish/MS_Speech_API_Lua
I've yet to test it.
I'd lose OS portability but was almost certain to happen anyway - unless I used zorgs' approach.
Re: Text to speech
Posted: Tue May 02, 2023 4:24 am
by tourgen
togFox wrote: ↑Tue May 02, 2023 2:31 am
Thanks. I have since found what seems to be the real solution (for Windows) and that is to use the speech API:
https://github.com/fiendish/MS_Speech_API_Lua
I've yet to test it.
I'd lose OS portability but was almost certain to happen anyway - unless I used zorgs' approach.
Hey! I've used that from C++. It works well. there are additional voices you can use, some are paid. It was a while ago, but I think I had access to some at&t voices at the time.
If I remember right, the MS API package also came with a 'say' command. spawning it from a thread to say a single line of text also worked well.
Re: Text to speech
Posted: Tue May 02, 2023 6:44 am
by togFox
Great. I'm hoping that lua module, and its dependency, will be a no-fuss way of getting some entry- level TTS.