Okay, here is a schematic outline for a proof-of-concept (PoC) n8n workflow designed to take unfiltered audio input, convert it to text, and then perform actions based on voice commands, aiming for near real-time processing.
This schematic assumes the audio is captured by an external application (like a script, mobile app, or web page) and sent to n8n. Real-time audio streaming directly into n8n from a microphone is not a standard feature; typically, audio chunks or files are sent to a webhook.
Conceptual n8n Workflow Schematic
graph TD
A[Start: Webhook Trigger] --> B(Receive Audio Data);
B --> C{Process Audio Data};
C --> D(Send Audio to STT Service);
D --> E{Receive Transcribed Text};
E --> F(Extract Intent & Parameters);
F --> G{Router: Based on Intent};
G -- Intent: Send Email --> H(Action: Send Email Node);
G -- Intent: Create Task --> I(Action: Create Task Node);
G -- Intent: Control Device --> J(Action: HTTP Request Node);
G -- Intent: Unknown/Other --> K(Handle Unknown Command);
H --> L(Optional: Response);
I --> L;
J --> L;
K --> L;
L --> M(End);
%% Styling (Optional)
classDef default,regularNode,startNode,endNode,processNode,decisionNode fill:#f9f,stroke:#333,stroke-width:2px;
classDef startNode fill:#bbf,stroke:#333;
classDef endNode fill:#bbf,stroke:#333;
classDef decisionNode fill:#bfb,stroke:#333;
classDef processNode fill:#ffb,stroke:#333;
class A startNode;
class B, C, D, E, F processNode;
class G decisionNode;
class H, I, J, K processNode;
class L processNode;
class M endNode;
Explanation of Nodes and Steps:
-
Start: Webhook Trigger:
- Node:
Webhook node.
- Purpose: This node acts as the entry point for the workflow. The external application capturing audio sends the audio data (e.g., as a file attachment or encoded data in the request body) to the URL provided by this webhook.
- Real-time Aspect: The external app should send audio chunks frequently rather than waiting for a long recording to finish to minimize latency.
-
Receive Audio Data:
- Implicit Step: Handled by the
Webhook node. The received audio data becomes available as input for the next node.
-
Process Audio Data:
- Node: Could be a
Function node or similar.
- Purpose: Depending on how the audio is sent, this step might involve decoding base64 data, preparing the data format, or extracting the audio file path/data from the webhook request structure to be ready for the Speech-to-Text service. Basic filtering could potentially be done before sending to n8n in the external application for better real-time performance.
-
Send Audio to STT Service:
- Node:
HTTP Request node or a dedicated node if available (e.g., an OpenAI node for Whisper, if n8n has one, or a community node for other services).
- Purpose: This is the core Speech-to-Text conversion step. The audio data from the previous step is sent to a cloud-based STT service API (e.g., OpenAI Whisper, Google Cloud Speech-to-Text, AssemblyAI, Deepgram).
- Configuration: Configure the node with the STT service API endpoint, authentication (API key), and the method (usually POST) to send the audio data.
- Real-time Aspect: Choose an STT service known for fast processing and ideally one that supports streaming audio input for lowest latency.
-
Receive Transcribed Text:
- Implicit Step: Handled by the
HTTP Request node receiving the response from the STT service.
-
Extract Transcribed Text:
- Node:
Function node or a data manipulation node.
- Purpose: Parses the JSON response from the STT service to extract the plain text transcription string.
-
Extract Intent & Parameters:
- Node:
Function node or OpenAI node (or another LLM via HTTP Request).
- Purpose: Analyzes the transcribed text to understand the user's command (the "intent") and extract any necessary details (like names, values, actions – these are the "parameters").
- Examples:
- Text: "Send an email to John saying hello" -> Intent:
send_email, Parameters: { recipient: "John", message: "hello" }
- Text: "Create a task to buy groceries" -> Intent:
create_task, Parameters: { task: "buy groceries" }
- Text: "Turn on the living room lights" -> Intent:
control_device, Parameters: { device: "living room lights", action: "on" }
-
Router: Based on Intent:
- Node:
Switch node.
- Purpose: Directs the workflow down different paths based on the
intent identified in the previous step. Each possible intent corresponds to a different branch (case) in the switch.
-
Action Nodes:
- Nodes: Various nodes depending on the command (e.g.,
Send Email, Todoist, Google Calendar, HTTP Request to interact with smart home APIs, Slack to send a message, etc.).
- Purpose: These nodes perform the actual requested operation using the parameters extracted from the voice command.
-
Handle Unknown Command:
- Node: Could be a
Function node or a notification node.
- Purpose: A default case in the
Switch node if the intent is not recognized. This could log the unknown command or send a message back to the user indicating the command wasn't understood.
-
Optional: Response:
- Node:
Webhook Response node or another communication node (e.g., sending a confirmation message via Slack or a push notification).
- Purpose: Provides feedback to the user via the external application or another channel, confirming whether the command was executed successfully or if there was an error.
-
End:
- Implicit Step: The workflow concludes after the action or response is handled.
PoC Implementation Notes:
- External App: You'll need a simple script or application to capture microphone audio and send it to the n8n webhook. For a PoC, this could be Python with
pyaudio and requests, or a simple web page using the Web Audio API and fetch.
- STT Service: Choose one that is easy to integrate and offers a free tier or trial (e.g., OpenAI Whisper API is often used for its quality and ease of use).
- Intent Recognition: Start with simple keyword matching in the
Function node. For more robustness, use a small language model via an API call.
- Actions: Begin with one or two simple actions (e.g., logging the command, sending a test email).
- Latency: Measure the time taken for each step (audio capture+send, STT processing, n8n execution) to identify bottlenecks. Sending shorter audio clips more frequently will be crucial for perceived real-time performance.