{
  "nodes": [
    {
      "parameters": {
        "formTitle": "ElevenLabs Studio",
        "formDescription": "Convert text to speech, or upload an audio file to transcribe it to text. Results are sent to Telegram.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "What do you want to do?",
              "fieldType": "dropdown",
              "fieldName": "action",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Text to Speech"
                  },
                  {
                    "option": "Speech to Text"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "Text to convert to speech",
              "fieldType": "textarea",
              "fieldName": "text",
              "placeholder": "Type the text you want to turn into audio\u2026"
            },
            {
              "fieldLabel": "Audio file to transcribe",
              "fieldType": "file",
              "fieldName": "audio",
              "multipleFiles": false,
              "acceptFileTypes": ".mp3,.wav,.m4a,.ogg,.webm,.flac"
            }
          ]
        },
        "options": {}
      },
      "id": "528f0a69-f546-42cb-82ba-489d0369bedb",
      "name": "ElevenLabs Form",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.6,
      "position": [
        0,
        96
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "action-tts",
              "leftValue": "={{ $json.action }}",
              "rightValue": "Text to Speech",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "b786b778-1ebf-42ce-a3e3-f9af1cb3d720",
      "name": "Which Action?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        224,
        96
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.elevenlabs.io/v1/text-to-speech/{{ $json.voice_id || \"STjmKzbhWp5ypwxePJ6P\" }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpTemplatedCustomAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"text\": {{ JSON.stringify($json.text) }}, \"model_id\": \"eleven_multilingual_v2\"}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "317302ca-4499-43cb-8190-36012ce78a08",
      "name": "ElevenLabs TTS",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.5,
      "position": [
        448,
        0
      ],
      "credentials": {
        "httpTemplatedCustomAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "sendAudio",
        "chatId": "8597879262",
        "binaryData": true,
        "additionalFields": {
          "caption": "Here is your generated speech.",
          "fileName": "speech.mp3"
        }
      },
      "id": "0d3ce304-ed39-44a5-8346-a6f5c18d80c5",
      "name": "Send Audio to Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        672,
        0
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.elevenlabs.io/v1/speech-to-text",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpTemplatedCustomAuth",
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model_id",
              "value": "scribe_v1"
            },
            {
              "parameterType": "formBinaryData",
              "name": "file",
              "inputDataFieldName": "audio"
            }
          ]
        },
        "options": {}
      },
      "id": "681a3dc9-9110-4b61-ad2d-8cff33b4e2b7",
      "name": "ElevenLabs STT",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.5,
      "position": [
        448,
        192
      ],
      "credentials": {
        "httpTemplatedCustomAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "8597879262",
        "text": "=\ud83d\udde3\ufe0f Transcript:\n\n{{ $json.text }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "153914f4-6ee1-4495-a1de-97016062c94c",
      "name": "Send Transcript to Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        672,
        192
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "ElevenLabs Form": {
      "main": [
        [
          {
            "node": "Which Action?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Which Action?": {
      "main": [
        [
          {
            "node": "ElevenLabs TTS",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ElevenLabs STT",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ElevenLabs TTS": {
      "main": [
        [
          {
            "node": "Send Audio to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ElevenLabs STT": {
      "main": [
        [
          {
            "node": "Send Transcript to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}