Requirements
On a server, the API key can be used directly (
apiKey: process.env.LOKUTOR_API_KEY). Never send it to a browser: give browsers tickets (Secure browser setup).
Setup
node-record-lpcm16 needs SoX (brew install sox, sudo apt install sox); speaker may need ALSA headers on Linux (sudo apt install libasound2-dev).
Voice agent in a terminal
NodeAudioManager connects the microphone and the speaker for you:
client.sendAudio(chunk), and play the 44.1 kHz Int16 mono PCM that arrives on client.on('audio', …).
Save TTS to a file
POST /tts/synthesize.