Indeed nothing wrong with the code. I tested your second function and it is loading the global variable with an object according to the value of msg.message
[{"id":"f6a0a4b4.33beb8","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"248936c9.f4b12a","type":"debug","z":"f6a0a4b4.33beb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"check","x":870,"y":360,"wires":[]},{"id":"3cef16e4.3c021a","type":"function","z":"f6a0a4b4.33beb8","name":"Second Function","func":"\nif (msg.message == \"speech on\") {\n \n var publicVariables = {\n speechOnOff: \"On\"\n }\n global.set(\"publicVariables\", publicVariables);\n}\nelse if (msg.message == \"speech off\") {\n \n var publicVariables = {\n speechOnOff: \"Off\"\n }\n global.set(\"publicVariables\", publicVariables);\n}\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":280,"wires":[["ddc8ec64.70f6"]]},{"id":"975438f6.3aa918","type":"inject","z":"f6a0a4b4.33beb8","name":"","topic":"","payload":"speech on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":260,"wires":[["3f3265e9.a6205a"]]},{"id":"771aa6ad.91b118","type":"inject","z":"f6a0a4b4.33beb8","name":"","topic":"","payload":"speech off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":300,"wires":[["3f3265e9.a6205a"]]},{"id":"3f3265e9.a6205a","type":"change","z":"f6a0a4b4.33beb8","name":"","rules":[{"t":"set","p":"message","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":280,"wires":[["3cef16e4.3c021a"]]},{"id":"ddc8ec64.70f6","type":"function","z":"f6a0a4b4.33beb8","name":"Retrieve value from global context","func":"msg.check = global.get(\"publicVariables\");\nreturn msg;","outputs":1,"noerr":0,"x":640,"y":360,"wires":[["248936c9.f4b12a"]]}]