8
n8n 中文网amn8n.com

智能PDF摘要生成器(带音频)

高级

这是一个Document Extraction, Multimodal AI领域的自动化工作流,包含 17 个节点。主要使用 Set, Code, Webhook, HttpRequest, Agent 等节点。 使用Groq AI总结PDF文档,并通过Qwen TTS转换为音频

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "Epn1xGw0ipAAedby",
  "meta": {
    "instanceId": "68ddca27a7d76186abf455a85b824d0d098822a7040451687281ac896e639893",
    "templateCredsSetupCompleted": true
  },
  "name": "智能 PDF 摘要生成器(带音频)",
  "tags": [],
  "nodes": [
    {
      "id": "f18454b2-afb3-4df6-942c-98771c21fb5a",
      "name": "从文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -1632,
        -896
      ],
      "parameters": {
        "options": {},
        "operation": "pdf",
        "binaryPropertyName": "=file"
      },
      "typeVersion": 1
    },
    {
      "id": "7b982a3d-e8a9-48ab-a9a0-8746bc440984",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1808,
        -896
      ],
      "webhookId": "95e13ed6-86f6-41fe-9b5d-66c1a40fc582",
      "parameters": {
        "path": "summarize-pdf",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "lastNode"
      },
      "typeVersion": 1
    },
    {
      "id": "12356a91-75ed-4099-a9c6-35458b578d1f",
      "name": "TTS 请求",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -672,
        -896
      ],
      "parameters": {
        "url": "https://qwen-qwen-tts-demo.hf.space/gradio_api/call/predict",
        "method": "POST",
        "options": {
          "response": {
            "response": {}
          }
        },
        "jsonBody": "={\n  \"data\": [\n    \"{{ $json.summary }}\",\n    \"Dylan\"\n  ]\n} ",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "dfefaa26-a0a5-4e9c-91a6-ea1af4e82541",
      "name": "TTS 轮询",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -496,
        -896
      ],
      "parameters": {
        "url": "=https://qwen-qwen-tts-demo.hf.space/gradio_api/call/predict/{{ $json.event_id }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "27856995-2ada-40bd-81df-957b526f9b33",
      "name": "提取音频 URL",
      "type": "n8n-nodes-base.code",
      "position": [
        -336,
        -896
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const raw = $json.data || $json || \"\";\n\n// Case 1: If it's already parsed JSON with data[0].url\nif (Array.isArray($json.data)) {\n  return {\n    json: {\n      audioUrl: $json.data[0]?.url || null,\n      rawJson: $json.data\n    }\n  };\n}\n\n// Case 2: Handle raw SSE text\nconst match = typeof raw === \"string\" ? raw.match(/data:\\s*(\\[[^\\]]+\\])/s) : null;\n\nif (match) {\n  try {\n    const parsed = JSON.parse(match[1]);\n    return {\n      json: {\n        audioUrl: parsed?.[0]?.url || null,\n        rawJson: parsed\n      }\n    };\n  } catch (e) {\n    return {\n      json: {\n        error: \"Failed to parse SSE JSON\",\n        raw\n      }\n    };\n  }\n}\n\n// Case 3: If neither worked\nreturn {\n  json: {\n    error: \"No audio URL found\",\n    raw\n  }\n};\n"
      },
      "typeVersion": 2
    },
    {
      "id": "9a375495-759d-44cd-a097-bf2368bb4360",
      "name": "同时响应",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        48,
        -896
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={\n  \"summary\": \"{{ $json.summary }}\",\n  \"audioUrl\": \"{{ $json.audioUrl }}\"\n}"
      },
      "typeVersion": 1.4
    },
    {
      "id": "80e57a89-6986-4b97-ad63-9b46f03420b7",
      "name": "代码2",
      "type": "n8n-nodes-base.code",
      "position": [
        -1424,
        -896
      ],
      "parameters": {
        "language": "python",
        "pythonCode": "data = _input.first().json.text\nreturn {\"data\": data}"
      },
      "typeVersion": 2
    },
    {
      "id": "7751dff9-400d-4230-86ea-6f8f85ab341c",
      "name": "Groq 聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "position": [
        -1376,
        -688
      ],
      "parameters": {
        "model": "openai/gpt-oss-20b",
        "options": {}
      },
      "credentials": {
        "groqApi": {
          "id": "B5I9hP4ok5scTeKB",
          "name": "Groq account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "97f2f63e-acbb-4e42-9e0c-50f456e10c4a",
      "name": "AI 代理1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1248,
        -896
      ],
      "parameters": {
        "text": "=Summarize the data into 4-5 lines or less : {{ $json.data }}\n",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "a0e98280-7a13-46d7-853d-5831468a2329",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        -128,
        -896
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b7efed1c-af46-4f2d-8da7-08b783248f19",
              "name": "audioUrl",
              "type": "string",
              "value": "={{ $json.audioUrl }}"
            },
            {
              "id": "924be2a2-9c3b-4d00-9e96-65b5d86e350c",
              "name": "summary",
              "type": "string",
              "value": "={{ $('summary').item.json.summary }}"
            }
          ]
        }
      },
      "executeOnce": false,
      "typeVersion": 3.4,
      "alwaysOutputData": false
    },
    {
      "id": "b11bc942-ecd6-4255-9b72-66d9478f4dfc",
      "name": "简单内存",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -1216,
        -656
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "3c3304a9-578c-4355-b036-c60f47291ebc",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        -1056
      ],
      "parameters": {
        "width": 640,
        "height": 80,
        "content": "## 智能 PDF 摘要生成器(带音频播放)"
      },
      "typeVersion": 1
    },
    {
      "id": "d571385e-5410-43cd-981f-ddd0624fcec8",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1712,
        -736
      ],
      "parameters": {
        "height": 80,
        "content": "- 这将从前端提取 PDF 文件。"
      },
      "typeVersion": 1
    },
    {
      "id": "f68b392f-7586-40fa-a0c3-43b244b903d9",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1376,
        -528
      ],
      "parameters": {
        "width": 256,
        "height": 192,
        "content": "- 使用代码节点将数据获取到 JSON 输出中。"
      },
      "typeVersion": 1
    },
    {
      "id": "adae39f6-540f-4cdd-99fe-d6b3cf43d47b",
      "name": "摘要",
      "type": "n8n-nodes-base.set",
      "position": [
        -912,
        -896
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={{ '{ \"summary\": \"' + $json.output + '\" }' }}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "6c5e1e3b-10a7-4cc7-a6f0-99374a18601e",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        -736
      ],
      "parameters": {
        "height": 112,
        "content": "- 使用 Hugging Face Qwen TTS 演示,通过摘要将文本转换为语音并生成音频。"
      },
      "typeVersion": 1
    },
    {
      "id": "5aef29ff-3aa0-468f-8605-809fb31ecdc6",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -16,
        -752
      ],
      "parameters": {
        "height": 112,
        "content": "- 使用代码节点提取音频 URL,并将两个响应发送到 webhook,以便在前端生成摘要和音频。"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a6d4cacd-8d02-4e53-b70b-7e91c083f4e7",
  "connections": {
    "Code2": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "summary": {
      "main": [
        [
          {
            "node": "TTS Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "TTS Poll": {
      "main": [
        [
          {
            "node": "Extract Audio URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Respond with Both",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "TTS Request": {
      "main": [
        [
          {
            "node": "TTS Poll",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Groq Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Extract Audio URL": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Code2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Respond with Both": {
      "main": [
        []
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 文档提取, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量17
分类2
节点类型10
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者

AI & Data Consultant with over 1 year of experience, helping people to streamline their processes. If you want any service you can contact me over this below link.

外部链接
在 n8n.io 查看

分享此工作流