Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using a config file for TTS #236

Closed
Applevangelist opened this issue Oct 13, 2023 · 10 comments · Fixed by #242 or #243
Closed

Error using a config file for TTS #236

Applevangelist opened this issue Oct 13, 2023 · 10 comments · Fixed by #242 or #243

Comments

@Applevangelist
Copy link
Contributor

Applevangelist commented Oct 13, 2023

If you create a config file, it gets loaded but the lua environment in DCS will throw this error

2023-10-13 11:32:03.329 ERROR   SCRIPTING (Main): Mission script error: attempt to concatenate a userdata value
stack traceback:
    [C]: ?
    [C]: in function 'start'
    [string "C:\Users\post\Saved Games\DCS\Scripts\DCS-gRPC\grpc.lua"]:12: in function 'f'
    [string "C:\Users\post\Saved Games\DCS\Scripts\DCS-gRPC\grpc-mission.lua"]:59: in function 'load'
    [string "C:\Users\post\Saved Games\DCS\Missions\test19.lua"]:4: in main chunk
    [string "assert(loadfile("C:\\Users\\post\\Saved Games\\DCS\\Missions\\test19.lua"))()"]:1: in main chunk

which refers back to

if isMissionEnv then
  grpc.start({
    writeDir = lfs.writedir(),
    dllPath = GRPC.dllPath,
    host = GRPC.host,
    port = GRPC.port,
    debug = GRPC.debug,
    evalEnabled = GRPC.evalEnabled,
    tts = GRPC.tts,
    srs = GRPC.srs,
  })
end

-> in the grpc.start() function your are trying to concat a nil value, probably one of the pathes.

@rurounijones
Copy link
Contributor

Can you provide an appropriately redacted config file that triggers this and confirm you have made the MissionScripting.lua changes (and that those changes are not getting replaced by something like SLMod)

@Applevangelist
Copy link
Contributor Author

Applevangelist commented Oct 14, 2023

Sure, config looks like below. Let me stress it works if I'm not using the config file. MissionScripting.lua has also been redacted (not using SLMod) as per instructions

-- Whether the `Eval` method is enabled or not.
evalEnabled = false

-- The host the gRPC listens on (use "0.0.0.0" to listen on all IP addresses of the host).
host = "127.0.0.1"

-- The port to listen on.
port = 50051

-- Whether debug logging is enabled or not.
debug = true

-- Limit of calls per second that are executed inside of the mission scripting environment.
throughputLimit = 600

-- The default TTS provider to use if a TTS request does not explicitly specify another one.
tts.defaultProvider = "gcloud"

-- Your Google Cloudd access key.
tts.provider.gcloud.key = "<API Key Here>"

-- The default Google Cloud voice to use (see https://cloud.google.com/text-to-speech/docs/voices).
tts.provider.gcloud.defaultVoice = "en-GB-Standard-F"

-- The default Windows voice to use (see https://support.microsoft.com/en-us/windows/appendix-a-supported-languages-and-voices-4486e345-7730-53da-fcfe-55cc64300f01).
-- Requires at least Windows Server 2019 to work properly.
tts.provider.win.defaultVoice = "Hedda"

-- Your SRS server's address.
srs.addr = "127.0.0.1:5002"

@rurounijones
Copy link
Contributor

I think there is an invisible character after the first " in the section below that may be causing issues.

tts.provider.gcloud.defaultVoice = "en-GB-Standard-F"

Could you delete everything after the = and type it in by hand to make sure there are no copy/paste encoding issues.

@Applevangelist
Copy link
Contributor Author

That is not the issue, there's no extra character in my local file. Error is the same.

@Applevangelist
Copy link
Contributor Author

Applevangelist commented Oct 16, 2023

Hint: I have the latest release pack. Franky has 0.7.0 and it reads the config no issues. Also, the lua files in the release pack do not match the dev tree

@rkusa
Copy link
Collaborator

rkusa commented Oct 17, 2023

Proper error gets swallowed due to #179. Can you check your Logs\grpc.log if it contains a more useful error?

@Applevangelist
Copy link
Contributor Author

It doesn’t bc it’s not compiled with debug on and this happens before anything starts showing up in the logs. Let me see if I can compile a version with debug on and then on what it says.

@Applevangelist
Copy link
Contributor Author

Applevangelist commented Oct 18, 2023

That wasn't helpful. Finding in between: I assume that the RPC cannot write to the tts structure you create in the mission environment, or it is not there, really. If you create the tts table from the mission before starting the config file is read and no error is thrown:

local tts = {}
tts.provider = {
  gcloud = {
    key = MSRS.APIKey,
    defaultVoice = MSRS.defaultVoice
  },
  defaultProvider = MSRS.GRPCOptions.DefaultProvider
}

GRPC.tts = tts
GRPC.debug = true
GRPC.integrityCheckDisabled = true

GRPC.load()

however, if you comment out the GRPC.tts = tts in the above example it is thrown. i.e. the load command in your lua files calling GRPC cannot write to the tts structure, hence the error

if isMissionEnv then
  assert(grpc.start({
    version = GRPC.version,
    writeDir = lfs.writedir(),
    dllPath = GRPC.dllPath,
    luaPath = GRPC.luaPath,
    host = GRPC.host,
    port = GRPC.port,
    debug = GRPC.debug,
    evalEnabled = GRPC.evalEnabled,
    integrityCheckDisabled = GRPC.integrityCheckDisabled,
    tts = GRPC.tts,
    srs = GRPC.srs,
  }))
end

possible the (basically empty) tts table is removed by the optimizer before you can even write to it.

@rkusa
Copy link
Collaborator

rkusa commented Oct 19, 2023

I think I found the culprit. The following change fixes your config:

- tts.defaultProvider = "gcloud"
+ tts.defaultProvider = "gCloud"

That is not intended, fixed in #243 to be the expected lowercase value.

@Applevangelist
Copy link
Contributor Author

Confirmed working with the change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants