Simplify DECTalk conditional

Signed-off-by: Ayane Satomi <ayane@vignetteapp.org>
This commit is contained in:
Ayane Satomi 2022-04-30 21:43:43 +08:00
parent 96350afbdb
commit e287600e26

View file

@ -30,7 +30,7 @@ function itExists(table, val)
end end
end end
function speak(ent, txt, remote, variant) function TTSLib:speak(ent, txt, remote, variant)
if not itExists(remoteList, remote) then if not itExists(remoteList, remote) then
print(remote .. " Does not exist in this context") print(remote .. " Does not exist in this context")
else else
@ -40,7 +40,7 @@ function speak(ent, txt, remote, variant)
if not itExists(sapi4Voices, variant) then if not itExists(sapi4Voices, variant) then
print("Invalid voice argument, valid voices are: Sam, Mike, Mary") print("Invalid voice argument, valid voices are: Sam, Mike, Mary")
else else
url = string.format(remoteList[1], voice) url = string.format(remoteList[1], variant)
end end
end end
@ -48,17 +48,14 @@ function speak(ent, txt, remote, variant)
if not itExists(googleVoices, variant) then if not itExists(googleVoices, variant) then
print("Invalid voice argument, valid voices are: en, fr, jp") print("Invalid voice argument, valid voices are: en, fr, jp")
else else
url = string.format(remoteList[2], variant, txt) url = string.format(remoteList[2], variant)
end end
end end
if remote == "dectalk" then if remote == "dectalk" then
if variant ~= nil then -- Ignore arguments here
print("Warning: DECTalk does not have arguments, ignoring.") -- DECTalk only has one variant
url = remote[3] url = remote[3]
else
url = remote[3]
end
end end
http.get(url .. http.urlEncode(text), function(code, body) http.get(url .. http.urlEncode(text), function(code, body)