使用Zonos通过API进行文本转语音语音克隆(本地存储)
高级
这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 18 个节点。主要使用 If, Set, Code, Webhook, HttpRequest 等节点。 使用Zyphra Zonos API从文本到语音克隆声音
前置要求
- •HTTP Webhook 端点(n8n 会自动生成)
- •可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "hqMRsze38RaTmgQh",
"meta": {
"instanceId": "f21406c1aebdcd02925535f333c258bfa61f9b4107a822ced8462b5dd631899b",
"templateCredsSetupCompleted": true
},
"name": "使用 Zonos 通过 API 进行文本转语音语音克隆(本地存储)",
"tags": [],
"nodes": [
{
"id": "76f2c278-c769-443f-8aa5-541713323b51",
"name": "Webhook 触发器",
"type": "n8n-nodes-base.webhook",
"position": [
-560,
60
],
"webhookId": "zyphra-voice-clone",
"parameters": {
"path": "voice-clone",
"options": {},
"httpMethod": "POST"
},
"typeVersion": 1
},
{
"id": "0772d98e-7cd8-487d-a3db-26c3d6d50304",
"name": "设置克隆参数",
"type": "n8n-nodes-base.set",
"position": [
-340,
60
],
"parameters": {
"values": {
"number": [
{
"name": "happiness",
"value": "={{ $json.body.emotion.happiness || 0.6}}"
},
{
"name": "neutral",
"value": "={{ $json.body.emotion.neutral || 0.6}}"
},
{
"name": "sadness",
"value": "={{ $json.body.emotion.sadness || 0.05}}"
},
{
"name": "disgust",
"value": "={{ $json.body.emotion.disgust || 0.05}}"
},
{
"name": "fear",
"value": "={{ $json.body.emotion.fear || 0.05}}"
},
{
"name": "surprise",
"value": "={{ $json.body.emotion.surprise || 0.05}}"
},
{
"name": "anger",
"value": "={{ $json.body.emotion.anger || 0.05}}"
},
{
"name": "other",
"value": "={{ $json.body.emotion.other || 0.5}}"
}
],
"string": [
{
"name": "text",
"value": "={{ $json.body.text || 'Hello, this is a test of voice cloning!' }}"
},
{
"name": "speaking_rate",
"value": "={{ $json.body.speaking_rate || 15 }}"
},
{
"name": "language_iso_code",
"value": "={{ $json.body.language_iso_code || 'en-us' }}"
},
{
"name": "mime_type",
"value": "={{ $json.body.mime_type || 'audio/wav'}}"
},
{
"name": "sample_voice_path",
"value": "={{ $json.body.sample_voice_path }}"
},
{
"name": "model",
"value": "={{ $json.body.model || 'zonos-v0.1-transformer' }}"
},
{
"name": "output_path",
"value": "={{ $json.body.output_path }}"
}
]
},
"options": {},
"keepOnlySet": true
},
"typeVersion": 1
},
{
"id": "b3dc1528-90d7-4397-83e6-18c5f2dbf495",
"name": "读取样本语音",
"type": "n8n-nodes-base.readWriteFile",
"onError": "continueErrorOutput",
"position": [
40,
60
],
"parameters": {
"options": {
"mimeType": "={{ $json.mime_type }}",
"dataPropertyName": ""
},
"fileSelector": "={{ $json.sample_voice_path }}"
},
"typeVersion": 1
},
{
"id": "86e0f9bf-ccec-4bb1-b9ce-7d1b94fdfcca",
"name": "检查文件是否已加载",
"type": "n8n-nodes-base.if",
"position": [
560,
-80
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "file-exists-check",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $ifEmpty($binary.data, false) !== false }}\n",
"rightValue": ""
}
]
}
},
"typeVersion": 2
},
{
"id": "2980ae94-30e3-4065-8d2c-b607c73c3c5f",
"name": "调用 Zyphra 克隆 API",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueErrorOutput",
"position": [
980,
-120
],
"parameters": {
"url": "http://api.zyphra.com/v1/audio/text-to-speech",
"method": "POST",
"options": {
"response": {
"response": {}
}
},
"jsonBody": "={\n \"text\": \"{{ $('Set Clone Parameters').item.json.text }}\",\n \"speaking_rate\": {{ parseFloat($('Set Clone Parameters').item.json.speaking_rate) }},\n \"language_iso_code\": \"{{ $('Set Clone Parameters').item.json.language_iso_code }}\",\n \"mime_type\": \"{{ $('Set Clone Parameters').item.json.mime_type }}\",\n \"model\": \"{{ $('Set Clone Parameters').item.json.model }}\",\n \"emotion\": {\n \"happiness\": {{ $('Set Clone Parameters').item.json.happiness }},\n \"neutral\": {{ $('Set Clone Parameters').item.json.neutral }},\n \"sadness\": {{ $('Set Clone Parameters').item.json.sadness }},\n \"disgust\": {{ $('Set Clone Parameters').item.json.disgust }},\n \"fear\": {{ $('Set Clone Parameters').item.json.fear }},\n \"surprise\": {{ $('Set Clone Parameters').item.json.surprise }},\n \"anger\": {{ $('Set Clone Parameters').item.json.anger }},\n \"other\": {{ $('Set Clone Parameters').item.json.other }}\n },\n \"speaker_audio\": \"{{ $json.base64_content }}\"\n}\n",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "X-API-Key",
"value": "put-your-API-key-here"
}
]
}
},
"typeVersion": 4.1
},
{
"id": "0f896518-98ce-4176-8977-1f0380b54469",
"name": "保存克隆的音频",
"type": "n8n-nodes-base.readWriteFile",
"position": [
1440,
0
],
"parameters": {
"options": {},
"fileName": "={{ $('Set Clone Parameters').item.json.output_path }}{{ 'cloned_voice_' + new Date().getTime() + '.webm' }}",
"operation": "write"
},
"typeVersion": 1
},
{
"id": "02f1b766-953a-4834-8d93-4cc596ffe77c",
"name": "成功响应",
"type": "n8n-nodes-base.set",
"position": [
1660,
0
],
"parameters": {
"values": {
"string": [
{
"name": "success",
"value": "true"
},
{
"name": "message",
"value": "Voice cloning completed successfully!"
},
{
"name": "filename",
"value": "={{ $json.fileName }}"
},
{
"name": "text_processed",
"value": "={{ $('Set Clone Parameters').item.json.text }}"
},
{
"name": "sample_voice_used",
"value": "={{ $('Set Clone Parameters').item.json.sample_voice_path }}"
}
]
},
"options": {}
},
"typeVersion": 1
},
{
"id": "7da98d65-08e3-4d6e-9957-ead2c8f1133f",
"name": "文件错误响应",
"type": "n8n-nodes-base.set",
"position": [
860,
480
],
"parameters": {
"values": {
"string": [
{
"name": "success",
"value": "false"
},
{
"name": "error_type",
"value": "file_not_found"
},
{
"name": "message",
"value": "Sample voice file could not be read from: {{ $('Set Clone Parameters').item.json.sample_voice_path }}"
},
{
"name": "suggestion",
"value": "Please check the file path and ensure the file exists"
}
]
},
"options": {}
},
"typeVersion": 1
},
{
"id": "44006f98-4241-436d-b8cf-1c586271a35a",
"name": "API 错误响应",
"type": "n8n-nodes-base.set",
"position": [
1100,
480
],
"parameters": {
"values": {
"string": [
{
"name": "success",
"value": "false"
},
{
"name": "error_type",
"value": "api_error"
},
{
"name": "message",
"value": "Voice cloning API request failed"
},
{
"name": "error_details",
"value": "={{ $json.error ? $json.error.message : 'Unknown API error' }}"
},
{
"name": "suggestion",
"value": "Please check your API key and try again"
}
]
},
"options": {}
},
"typeVersion": 1
},
{
"id": "e2c14808-e209-4daf-93dd-9c7049261e60",
"name": "Webhook响应",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
1880,
100
],
"parameters": {
"options": {},
"respondWith": "json",
"responseBody": "={{ $json }}"
},
"typeVersion": 1
},
{
"id": "8268fd4a-fd84-4462-9ad1-9af8152d0cf3",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-960,
-1200
],
"parameters": {
"color": 4,
"width": 780,
"height": 340,
"content": "🎙️ 语音克隆工作流 - ZONOS API"
},
"typeVersion": 1
},
{
"id": "cdbb775f-8408-43a9-89b1-1039315c6678",
"name": "Base64 转换器",
"type": "n8n-nodes-base.code",
"position": [
400,
-80
],
"parameters": {
"jsCode": "// Get binary data from previous node\nconst binaryData = $input.first().binary?.data;\n\nif (!binaryData) {\n throw new Error(\"No binary data found\");\n}\n\n// Binary data in n8n is already base64 encoded\nconst base64String = binaryData.data;\n\nreturn {\n json: {\n base64_content: base64String,\n // Add other fields as needed\n }\n};\n"
},
"typeVersion": 2
},
{
"id": "88b0131c-f93b-4593-9c88-ed4f91b74c88",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-960,
-740
],
"parameters": {
"color": 6,
"width": 780,
"height": 1020,
"content": "📥 必需的 WEBHOOK 参数"
},
"typeVersion": 1
},
{
"id": "3be24130-054d-4435-9aac-d5ad9c7b92d0",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
820,
-380
],
"parameters": {
"color": 6,
"width": 480,
"height": 460,
"content": "🔐 需要配置 API 密钥!"
},
"typeVersion": 1
},
{
"id": "08780e5a-4663-4a0d-aeff-69f4059495ce",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-60,
-280
],
"parameters": {
"color": 6,
"width": 740,
"height": 560,
"content": "📁 文件处理过程"
},
"typeVersion": 1
},
{
"id": "223743b2-aeb2-45cc-8094-9bef48fc815e",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
820,
180
],
"parameters": {
"color": 6,
"width": 480,
"height": 480,
"content": "🚨 错误处理与响应"
},
"typeVersion": 1
},
{
"id": "939714c2-9feb-4ccb-b3b6-fd133c65c56a",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
1400,
-220
],
"parameters": {
"color": 6,
"width": 660,
"height": 540,
"content": "🎵 输出详情"
},
"typeVersion": 1
},
{
"id": "0a90485e-417a-415e-a9a4-f128aea6b9f1",
"name": "便签6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-940,
-440
],
"parameters": {
"color": 5,
"width": 700,
"height": 440,
"content": "POST http://localhost:5678/webhook-test/voice-clone"
},
"typeVersion": 1
}
],
"active": true,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "c4a644b3-3029-47ed-9dad-6396d22a9841",
"connections": {
"76f2c278-c769-443f-8aa5-541713323b51": {
"main": [
[
{
"node": "0772d98e-7cd8-487d-a3db-26c3d6d50304",
"type": "main",
"index": 0
}
]
]
},
"cdbb775f-8408-43a9-89b1-1039315c6678": {
"main": [
[
{
"node": "86e0f9bf-ccec-4bb1-b9ce-7d1b94fdfcca",
"type": "main",
"index": 0
}
]
]
},
"02f1b766-953a-4834-8d93-4cc596ffe77c": {
"main": [
[
{
"node": "e2c14808-e209-4daf-93dd-9c7049261e60",
"type": "main",
"index": 0
}
]
]
},
"86e0f9bf-ccec-4bb1-b9ce-7d1b94fdfcca": {
"main": [
[
{
"node": "2980ae94-30e3-4065-8d2c-b607c73c3c5f",
"type": "main",
"index": 0
}
],
[
{
"node": "7da98d65-08e3-4d6e-9957-ead2c8f1133f",
"type": "main",
"index": 0
}
]
]
},
"b3dc1528-90d7-4397-83e6-18c5f2dbf495": {
"main": [
[
{
"node": "cdbb775f-8408-43a9-89b1-1039315c6678",
"type": "main",
"index": 0
}
],
[
{
"node": "7da98d65-08e3-4d6e-9957-ead2c8f1133f",
"type": "main",
"index": 0
}
]
]
},
"0f896518-98ce-4176-8977-1f0380b54469": {
"main": [
[
{
"node": "02f1b766-953a-4834-8d93-4cc596ffe77c",
"type": "main",
"index": 0
}
]
]
},
"44006f98-4241-436d-b8cf-1c586271a35a": {
"main": [
[
{
"node": "e2c14808-e209-4daf-93dd-9c7049261e60",
"type": "main",
"index": 0
}
]
]
},
"7da98d65-08e3-4d6e-9957-ead2c8f1133f": {
"main": [
[
{
"node": "e2c14808-e209-4daf-93dd-9c7049261e60",
"type": "main",
"index": 0
}
]
]
},
"0772d98e-7cd8-487d-a3db-26c3d6d50304": {
"main": [
[
{
"node": "b3dc1528-90d7-4397-83e6-18c5f2dbf495",
"type": "main",
"index": 0
}
]
]
},
"2980ae94-30e3-4065-8d2c-b607c73c3c5f": {
"main": [
[
{
"node": "0f896518-98ce-4176-8977-1f0380b54469",
"type": "main",
"index": 0
}
],
[
{
"node": "44006f98-4241-436d-b8cf-1c586271a35a",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 内容创作, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用 OpenAI、LangChain 和 API 集成的工作流自动化初学者指南
使用 OpenAI、LangChain 和 API 集成的工作流自动化初学者指南
If
Set
Code
+
If
Set
Code
33 节点Meelioo
内容创作
特定域名网页内容爬虫,带深度控制和文本提取
特定域名网页内容爬虫,带深度控制和文本提取
If
Set
Code
+
If
Set
Code
18 节点Le Nguyen
内容创作
通过关键词搜索和Markdown格式化提取和过滤Reddit帖子和评论
通过关键词搜索和Markdown格式化提取和过滤Reddit帖子和评论
If
Set
Code
+
If
Set
Code
28 节点Muhammad Asadullah
内容创作
Telegram AI歌词学习机器人 — 翻译、摘要、词汇
Telegram AI歌词学习机器人 — 翻译、摘要、词汇
If
Set
Code
+
If
Set
Code
30 节点Raphael De Carvalho Florencio
内容创作
会议纪要和行动项跟踪器
基于AI的会议纪要:使用GPT-4、任务分配和多渠道分发
If
Set
Code
+
If
Set
Code
38 节点Jitesh Dugar
内容创作
从趋势电子表格生成SEO内容到存储(SharePoint/Drive/Dropbox)
使用GPT-4o、FAL AI和多存储支持从趋势自动生成SEO内容
If
Set
Code
+
If
Set
Code
47 节点plemeo
内容创作
工作流信息
难度等级
高级
节点数量18
分类2
节点类型8
作者
Tiartyos
@tiartyos🎮 Gaming // 💻 Coding // 🎨 Creating Pro-AI 🤖 | Open Source 🌟 | 🧟♂️ Horror junkie | 🍜 Anime lover Turning caffeine into questionable code since 2017 ☕
外部链接
在 n8n.io 查看 →
分享此工作流