{
  "name": "Voice Synthesizer Workflow",
  "nodes": [
    {
      "parameters": {},
      "id": "workflow-start",
      "name": "Start",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "// Prepare Google TTS request\nconst data = $input.item.json;\nconst apiKey = data.apiKeys?.googleTTS || $env.GOOGLE_TTS_API_KEY;\n\nreturn {\n  apiKey,\n  script: data.script,\n  voiceSettings: data.voiceSettings || {\n    languageCode: 'en-US',\n    name: 'en-US-Neural2-D',\n    speed: 1.0\n  },\n  userId: data.userId,\n  topic: data.topic\n};"
      },
      "id": "prepare-tts-request",
      "name": "Prepare TTS Request",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://texttospeech.googleapis.com/v1/text:synthesize?key={{ $json.apiKey }}",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "input",
              "value": "={ \"text\": \"{{ $json.script }}\" }"
            },
            {
              "name": "voice",
              "value": "={{ $json.voiceSettings }}"
            },
            {
              "name": "audioConfig",
              "value": "={ \"audioEncoding\": \"MP3\", \"speakingRate\": {{ $json.voiceSettings.speed }} }"
            }
          ]
        },
        "options": {}
      },
      "id": "call-tts-api",
      "name": "Call Google TTS",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "// Decode base64 audio and prepare for storage\nconst response = $input.item.json;\nconst audioContent = response.audioContent;\n\n// Convert base64 to binary buffer\nconst audioBuffer = Buffer.from(audioContent, 'base64');\n\nreturn {\n  audioBuffer: audioBuffer,\n  audioBase64: audioContent,\n  fileName: `audio_${Date.now()}.mp3`,\n  mimeType: 'audio/mpeg',\n  userId: $('Prepare TTS Request').item.json.userId,\n  topic: $('Prepare TTS Request').item.json.topic\n};"
      },
      "id": "process-audio",
      "name": "Process Audio",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        850,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Prepare TTS Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare TTS Request": {
      "main": [
        [
          {
            "node": "Call Google TTS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Google TTS": {
      "main": [
        [
          {
            "node": "Process Audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 0,
  "updatedAt": "2026-01-25T00:00:00.000Z",
  "versionId": "1"
}