DYSTOPIANPIXEL

speechControl Driver

Angled copper and periwinkle assembly code beside microphone, speech-processing and speaker motifs
Illustrative assembly code and speech-processing motifs for speechControl.

Last updated: · On hold

What we tried, why we chose an approach and what we learned. These are dated accounts; see Progress for the current position and recorded outcomes.

The first voice from the Next

Recovering the M3A4 diagnostic changed the picture. The sentence and its settings were intact, the acknowledgement had been processed and recovery worked. The earlier timeout investigation could be closed without pretending the missing diagnostic had already told us what was wrong.

Generation and playback are different tests

eSpeak NG produced a speech WAV, but the initial playback route was silent. A file existing on the Pi did not prove that the sound was reaching the Next. Selecting the Next’s DAC explicitly isolated that part of the journey.

Put punctuation where it can be handled reliably

A direct command from BASIC ran into punctuation parsing. Moving playback into a small Pi-side wrapper made the boundary simpler. Hearing “Hello from speech control” was the result of checking synthesis and output separately, then using a reliable way to invoke the output path.

Join proven pieces next

The speech request and the audible playback test were separate successes. M3B still needed to connect them into one driver-controlled request. Keeping that distinction visible prevents a convincing sound demonstration from being mistaken for a completed speech service. The recording and measured results are retained in Progress.

Tracing the first speech request

After proving the NextPi connection, I reduced the next question to one transaction: could a sentence and its settings reach the Pi and return an acknowledgement? Speech synthesis would wait until that exchange could be trusted.

A timeout did not identify its cause

Handing control back to the Supervisor caused difficulties, and one recovery change interfered with an ordinary packet byte. The revised M3A4 test still timed out. That was evidence that the transaction needed investigation, not evidence that every layer of the proven connection was broken.

Check which service is running

The expected diagnostic file was missing. An older running service or a failure to write diagnostics were possibilities, but neither was established. Verifying the persistent service was therefore more useful than changing more protocol code on an assumption.

Separate transport from speech

Keeping the M2E communications checkpoint intact limited the investigation. The recovered diagnostic and first audible output are described in the next story on the same date. This entry records the earlier investigation and why we checked deployment and evidence before attempting to connect the speech engine.

A proven link to NextPi

From a speech experiment to a proper driver

The project started with a simple question: can the ZX Spectrum Next use its Pi Zero to turn text into speech and spoken words into game commands? The answer quickly became more interesting than a one-off demo. The Next already contains two very different processors, each suited to a different job. The Z80 is the game machine; the Pi is the speech processor. That led to the rule that still defines the project: the Spectrum controls speech, while the Pi performs speech processing.

Instead of wrapping Linux commands directly in BASIC, the project became a proper NextZXOS driver with a stable game-facing API and a replaceable Pi-side backend.

The first hardware bug arrived before speech did

The earliest real .INSTALL attempt crashed back to the menu. The cause was not TTS, UART or Linux: it was the driver relocation table. The image contained more absolute references than the table described. Fixing that was an important reminder that the low-level driver foundation had to be proven before any speech code was allowed to hide mistakes underneath it.

That decision paid off. By the end of Milestone 1, install/uninstall, worker-bank mapping, local buffering and the IM1 callback had all been tested independently on the real machine.

Proving that MMU7 can be borrowed safely

The banked worker design depends on temporarily using MMU7 for the extra 8K driver bank. That is powerful, but dangerous if the original mapping is not restored exactly. Hardware tests therefore record the MMU7 value before and after public driver calls. The successful M1C test showed the same value on both sides while the interrupt callback continued to run, giving confidence that speechControl can coexist with a game rather than quietly damaging its memory map.

Teaching the driver to take control of NextPi

NextPi normally presents its Supervisor shell over the UART. speechControl therefore cannot simply start sending binary frames and hope for the best. Milestone 2 built a controlled transition from SUP> to the speech service: recover the Supervisor, launch the service, wait for SCSP READY 1, exchange HELLO and PING, then enter READY state.

The work also exposed the difference between a cold bootstrap and a warm reconnect. Once the service is already alive, the actual SCSP protocol handshake is quick: the hardware test consistently reaches READY in about 0.42 seconds.

Why the cold start suddenly became three times faster

The first protocol harness was deliberately embedded in a python2 -c command. That was useful while the service changed frequently, but it meant the Supervisor had to receive and parse a large Python program every time the driver started. The measured cold start was about 2.44 seconds.

M2E moved the Python code into a persistent nextpi-speech_service file and changed the Z80 launch command to a short python2 invocation. On the same real machine the cold start dropped to 41 frames, or about 0.82 seconds, while warm reconnect stayed at 21 frames / 0.42 seconds. That is a useful performance win achieved by architecture rather than Z80 micro-optimisation.

The zero-byte service that looked like a successful upload

M2E also produced a very practical deployment lesson. The first setup program displayed a 5119-byte transfer and eventually printed SERVICE DEPLOYMENT COMPLETE, yet the persistent service was missing. Investigation through .term showed that /ram contained nextpi-speech_service with a size of zero bytes.

Using .PIPUT transferred the actual file, after which running the service manually immediately produced SCSP READY 1. The driver then passed the M2E timing test. The protocol had been correct all along; the failure was the installer trusting an upload without validating the result. That will now feed directly into the release-installer design.

The next story should be audible

Up to this point the most important successes have deliberately been invisible: safe memory mapping, interrupt entry, Supervisor recovery, CRC checks, sequence handling and reconnect timing. That foundation is now solid enough that the next development story can finally cross the boundary into something a user can hear: the first TTS_SAY command producing real speech through the Pi/Next audio path.

A foundation for speech

Connecting the speech service

I am keeping the tested first milestone as a checkpoint and developing the Pi connection next. Real speech comes after that conversation between the machines is dependable.

A self-contained test

A test that assumed an already-running driver produced a misleading failure. Revising it to handle its own setup made the result repeatable and led to the successful shutdown-and-restart checkpoint.

A quiet first milestone

The first major result did not need a talking game. It showed that the driver could start, stop, restart and keep its background work running safely on the real machine. That is the foundation the later voice features need.