It is not possible to “get the actual pitch” via Lua scripting, unfortunately.
However, depending on the scope of what you want to do, it might be worthwhile to look into doing it semi-automatically, by providing the pitch information manually either via the console (as a function call), or through some cleverly chosen keycommands via ConsoleTools.