Illustrative home voice terminal and local computer, not a tested installation
Embedded System Development

Connecting an ESP32 Voice Device to a Private LAN Server

An ESP32 can keep calling its old endpoint after the voice server moves onto the LAN. The new server can also keep calling cloud models.

ESP32
Implementation bridge

Using this research in a live engineering project?

Send the device, workflow, data, integration, or deployment constraints. An engineer can help turn the article direction into a scoped next step.

An ESP32 can keep calling its old endpoint after the voice server moves onto the LAN. The new server can also keep calling cloud models. Moving the chain means changing the addresses delivered to the device, the providers actually selected by the server, and the resources those providers access during startup and conversation. A running Docker container covers only part of that work.

This guide uses the Xiaozhi device protocol and xinnan-tech's self-hosted server in its single-service configuration mode. It follows device discovery first, then recognition, language-model, and synthesis dependencies. The basis is pinned source and configuration, not a completed hardware deployment. Network, audio, and restart checks below are proposed integration work; no minimum RAM, concurrency, or first-response latency is claimed.

Give the device an address it can reach

Listening on 0.0.0.0:8000 means accepting connections on interfaces in the server's network environment. It is not a destination to put into the ESP32. The device needs a host address reachable from its Wi-Fi network. Container addresses, computer loopback addresses, and addresses reachable by another terminal serve different purposes.

The pinned server configuration separates the WebSocket listener on port 8000 from the simple OTA HTTP service on port 8003. server.websocket is the address the OTA interface tells the device to use. Opening an OTA page in a browser establishes reachability to that page, not to the voice endpoint returned by it.

For an assumed LAN host address of 192.168.10.20, the following illustrates address relationships in single-service mode. It is not a complete installation configuration:

server:
  ip: 0.0.0.0
  port: 8000
  http_port: 8003
  websocket: ws://192.168.10.20:8000/xiaozhi/v1/

The corresponding custom OTA entry is http://192.168.10.20:8003/xiaozhi/ota/. Read it from the device's network and inspect the returned WebSocket host, port, and path. Testing only on the server itself misses that distinction. A changed NIC, DHCP assignment, or port mapping does not repair an old device entry automatically. A fixed lease or controlled LAN name can reduce address drift, provided the device can resolve that name.

Keep this example inside its intended trust boundary. The ws and http addresses illustrate a controlled LAN and provide no transport encryption. Do not expose both ports to the internet merely to get a first connection. Across an untrusted network, arrange a TLS entry point the device actually supports, certificate verification, and access control. Review device identity, token issuance, and revocation on both firmware and server; a default authentication setting is not a product security decision.

The firmware-setting guide describes a custom server entry. It does not make every ESP32 audio program compatible. The pinned WebSocket protocol defines hello messages, JSON events, and binary audio. Ollama's general text interface does not directly consume those device frames. A local model still needs the voice-service adapter between it and the terminal.

Change the providers the server is actually using

Inspect selected_module before editing a provider block. It selects named configurations elsewhere in the file. An accurate Ollama URL is irrelevant if the running service still selects another LLM. The frozen default combination includes local FunASR, ChatGLMLLM, and EdgeTTS: local recognition does not make the other stages offline.

The configuration also documents its override behavior. In single-service mode, data/.config.yaml overrides default fields, while fields not overridden continue to come from the base configuration. A deployment using the management console follows that configuration path instead. Establish who loads the effective values before editing files; otherwise the file, database, and console can retain three different answers.

Stage Entry in the pinned configuration Resources to place locally
Recognition ASR.FunASR, type fun_local models/SenseVoiceSmall, runtime dependencies, and a readable model path
Conversation LLM.OllamaLLM, type ollama Reachable Ollama service, downloaded model, and the selected model name
Synthesis A local HTTP example such as TTS.CustomTTS Service, model and voice resources, response format, and audio-download address
Additional capabilities Intent, Memory, plugins, and MCP Separate dependencies for tools, retrieval, weather, and memory summarization

These are configuration inspection points, not components demonstrated together on one host. TTS is particularly easy to overlook: a self-hosted voice server can still use online synthesis. If switching the LLM to Ollama produces reply text but no sound, follow the selected TTS request, response, and audio download before questioning transcription that already succeeded.

FunASR points at a local model directory. The deployment instructions require SenseVoiceSmall files to be prepared separately, while the Compose file mounts host files into the container. Read those together. A model existing on the host does not establish that the container can read its intended path. Model identity, mounts, and loading logs should refer to the same resources, including after an image upgrade.

Keep an override that can be inspected

This excerpt separates provider selection from the configuration it references. It applies only to the single-service configuration path above. Authentication, full TTS parameters, and deployment-network definitions are deliberately absent, so it is not a production-ready file:

selected_module:
  ASR: FunASR
  LLM: OllamaLLM
  TTS: CustomTTS
  Memory: nomem
  Intent: nointent
LLM:
  OllamaLLM:
    type: ollama
    model_name: qwen2.5
    base_url: http://ollama:11434
    api_key: ollama

Here ollama is an illustrative container service name. It works only where the voice service can resolve and reach it. qwen2.5 is an example name already present in the frozen configuration; it must match a model actually downloaded and suitable under its license. Changing models can change output formats, tool use, and conversation templates. Loading successfully does not establish equivalent interaction behavior.

Temporarily selecting empty Intent and Memory capabilities narrows the first conversation chain. It is not a recommendation to remove those product features permanently. Retained tools, memory, or retrieval need their own model and service entries in the dependency inventory. A module with a separate LLM setting need not follow a change to the main conversation model. Re-enable additional capabilities one at a time so a new outbound connection can be attributed to the feature that introduced it.

Save a redacted view of the effective configuration rather than sharing a complete file containing keys. Useful fields include the selected ASR/LLM/TTS types, destination hosts and ports, model names, and the configuration loading source. Wrong values point first to overrides or management-console configuration. Correct values followed by connection failure point toward networking. Keeping those branches separate shortens the investigation.

Identify whose localhost is making the request

An Ollama example using http://localhost:11434 may be correct when both services run as host processes. Put the voice service in a container and the same string generally points back into that container, not to the host. Repeatedly changing the model name will not repair that connection refusal.

Services on one controlled container network can use service names resolvable there. With one service in a container and another on the host, arrange reachability for that operating system and network topology. A platform-specific special hostname is not a universal Linux answer. Test from the voice service's network environment; opening Ollama from a desktop browser does not cover that path.

The pinned Ollama adapter adds /v1 to a host-only base URL and uses a compatible chat-completions client. Supply the service base address expected by this adapter, not the device WebSocket path or an arbitrary full inference endpoint. HTTP reachability, model availability, and a response the adapter can parse are successive checks.

The official Ollama FAQ explains binding configuration. Expanding a listener for container connectivity also expands who can reach the model interface. A LAN can contain untrusted terminals. Keeping that port inside a controlled network or behind an authentication gateway, while devices use only the device-facing entry point, makes the separation clearer. An API-key placeholder does not establish authentication.

TTS has the same address problem twice. The pinned CustomTTS example points at 127.0.0.1:8880 and includes a returned-download-link option. Check both the synthesis request and the process that later downloads the audio. A successful response containing a URL aimed at the wrong process's localhost can produce text with no playable sound. Record the failed stage instead of reducing it to a whole-conversation timeout.

Technical architecture diagram
Technical architecture diagram

Configuration relationships, not evidence that these components started or completed an offline conversation. Check each address from the actual requesting environment.

Stop a failure at one layer with a small request

The first probes need not involve a real microphone. From the voice-service network environment, establish Ollama reachability and inspect the model list. Then make a short text request to the selected model and compare its response with the adapter's expectations. A readable list followed by inference failure can indicate model readiness or a request mismatch; it is a different problem from ESP32 OTA discovery.

Probe TTS independently with short text, checking response status, media format, and whether the returned audio is readable. Next inspect how the voice server encodes or frames that result for the device. A service returning an MP3 file has not demonstrated delivery of playback data matching the terminal protocol. File creation, decoding, transmission, and speaker playback need distinguishable observation points. Different providers need not return the same format.

At the device, follow one recognizable short request through connection acceptance, input receipt, transcription, model output, synthesis, and playback completion. A shared session association and event order help locate the stalled stage. Do not publish the differences between those timestamps as end-to-end latency unless clocks, sampling boundaries, and measurement methods have been defined. Establishing stage correlation first keeps later optimization attached to the right problem.

Cancellation also crosses these interfaces. When the device ends a turn, the voice server needs to process the protocol's stop event and coordinate pending model and synthesis work. Actual interruption of upstream inference depends on provider support. Results that cannot be interrupted still must not enter the player of an ended session. This is an integration requirement, not a claim that the frozen server supplies identical cancellation semantics for every provider.

Illustrative local computer and attached storage

Local resource-preparation scene, not evidence of a particular model file, a wiring plan, or an offline test.

Bring startup dependencies inside the boundary too

Prepare model weights and voice resources before removing internet access. Images, Python dependencies, and first-run initialization resources belong in the deployment inventory as well. A moving server_latest tag makes it difficult to explain what a reinstall will retrieve. Record the source commit, image digest, and redacted effective configuration rather than relying only on a docker compose up command.

Local recognition, conversation, and synthesis do not account for every feature. Weather, news, retrieval, remote MCP, memory summaries, and fallback providers can still make outbound requests. Disable plugins outside the current task and define unavailable behavior for the external capabilities retained. Quietly returning sensitive conversations to a cloud provider to preserve a successful-looking answer changes the product's data boundary. If a capability intentionally uses the internet, describe that separate scope instead of calling the entire chain offline.

Data destinations deserve the same visibility. Audio, transcripts, conversations, and errors can land in different directories. Local inference does not determine retention or access permissions. Retain diagnostics as needed, restrict recording and token access, redact credentials from configuration backups, and decide how a lost or removed device loses access to the entry point.

Treat configuration and model resources as a set during upgrades. Preserve the current image identity, provider choices, and model-file inventory, then compare fields with the new version. Copying an old override over a new template can retain renamed or ineffective settings. A rollback should recover those inputs together, not just a container tag. Large model files need not be downloaded for every restart, but the restored service must read the intended version.

Temporary audio has a different lifecycle from model weights. A full temporary directory, changed write permissions, or a missing mount can break synthesis while recognition and the language model remain healthy. Separate rebuildable files from configuration and resources requiring persistence, with appropriate capacity and access policies. Otherwise a filesystem failure can be misdiagnosed as an unavailable model.

Disconnect the WAN, then start again

Finishing a conversation already in progress exercises a warm path. To assess offline operation, preserve the LAN and required local services, block the defined WAN exits, and cold-start both the device and service. This can reveal model downloads, external resolution, certificate, or time-synchronization dependencies hidden by warm caches. One successful response before a restart does not cover recovery afterward.

Follow a turn through admission, transcription, model processing, synthesis, and playback, assigning any failure to its actual stage. Stop the LLM or TTS separately and check that the terminal reports unavailability instead of replaying an earlier answer or waiting indefinitely. After WAN access returns, check that unwanted cloud fallback has not remained enabled. These are proposed fault conditions to cover, not tests performed for this article.

Keep three possible delivery statements distinct: the device can reach the LAN server; specified voice components are configured as local providers; a conversation actually completed under the listed disconnection, restart, and failure conditions. Connectivity can support the first. Effective configuration and loading records support the second. The third requires complete runtime evidence. Separating them prevents a successful demonstration from becoming an unsupported claim about private deployment.

For the choice of device-facing transport, see ESP32 voice transport selection. For firmware and private-host integration, see ESP32 development services. Sources were checked on November 24, 2026; this article contains no board-level or WAN-disconnection runtime results.