mirror of
https://github.com/db9979/uconsole_asw_game.git
synced 2026-12-06 21:04:18 +01:00
Voice: every report ends with a full stop and a short silence (1.3.269)
Each spoken report is closed with a full stop (also after a colon, ellipsis or comma), and 0.6 s of silence follows it before the next one plays. Log entries go to the speech service one by one again: a probe on the owner's Qwen3-TTS service showed only 0.2-0.4 s between entries sent together, whatever the separator. Answers of the executive officer stay in one piece. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018daq29kru65UEEQQM3E6AK
This commit is contained in:
17 files changed
+139
-60
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
## Authority and scope
|
||||
|
||||
- This is U-Jagd 1.3.264 (`src/core/version.py`); saves are written as v53 and older saves from v38 on are lifted to v53 on load (`src/core/save_migrate.py`). Treat these as compatibility contracts, not changelog entries.
|
||||
- This is U-Jagd 1.3.269 (`src/core/version.py`); saves are written as v53 and older saves from v38 on are lifted to v53 on load (`src/core/save_migrate.py`). Treat these as compatibility contracts, not changelog entries.
|
||||
- Resolve conflicts in this order: executable code and focused tests; packaged JSON/runtime resources; `pyproject.toml` and provenance/license notices; `README.md`; design/history documents under `docs/`. A plan or old comment is not an implementation contract.
|
||||
- Preserve explicit compatibility tests and user data unless a task intentionally changes the contract. Add a regression test for behavior changes.
|
||||
- Older phase/milestone labels under `docs/GDD.md`, `docs/implementation-plan.md`, `docs/plan-0.1.6.md`, and `docs/plan-0.1.7.md` are historical, and so is `docs/plan-1.3.md` (the plan 1.3.0 was built from). Current resumable work is tracked in `docs/resume.md`.
|
||||
|
||||
@@ -4,6 +4,17 @@
|
||||
|
||||
Alle Versionen von U-Jagd, die neueste zuerst. Die [README](README.de.md) zeigt nur die neueste.
|
||||
|
||||
## 1.3.269
|
||||
|
||||
Version 1.3.269 gibt jeder gesprochenen Meldung ein klares Ende. Jede
|
||||
Meldung, die die Stimme liest, endet mit einem Punkt, auch nach einem
|
||||
Doppelpunkt oder Auslassungszeichen, und danach folgen 0,6 s Stille, bevor
|
||||
die nächste beginnt. Logmeldungen gehen dafür wieder einzeln an den
|
||||
Sprachdienst, denn ein Sprachmodell macht zwischen zusammen geschickten
|
||||
Meldungen nur eine kurze Satzpause. Antworten des Ersten Offiziers bleiben
|
||||
am Stück. Tasten und Spielstände bleiben gleich (v53; Spielstände v38 bis
|
||||
v52 laden weiter).
|
||||
|
||||
## 1.3.264
|
||||
|
||||
Version 1.3.264 macht den Kampf unter Wasser realistischer. Torpedo-Suchköpfe
|
||||
|
||||
@@ -4,6 +4,16 @@
|
||||
|
||||
Every U-Jagd release, newest first. The [README](README.md) shows only the latest one.
|
||||
|
||||
## 1.3.269
|
||||
|
||||
Release 1.3.269 gives every spoken report a clear end. Each report the
|
||||
voice reads ends with a full stop, also after a colon or an ellipsis, and
|
||||
0.6 s of silence follows it before the next one starts. Log entries go to
|
||||
the speech service one by one again, because a speech model leaves only a
|
||||
short sentence pause between entries sent together. Answers of the
|
||||
executive officer stay in one piece. Keys and saves are unchanged (v53;
|
||||
v38 to v52 saves still load).
|
||||
|
||||
## 1.3.264
|
||||
|
||||
Release 1.3.264 makes the underwater fight more realistic. Torpedo seekers
|
||||
|
||||
+9
-14
@@ -10,21 +10,16 @@ die Fregatte F-217 mit neun Stationen oder ein U-Boot mit sieben und jagen die
|
||||
andere Seite oder entkommen ihr. Freunde können Stationen im Browser im selben
|
||||
Netz besetzen.
|
||||
|
||||
Aktuelle Version: **1.3.264**
|
||||
Aktuelle Version: **1.3.269**
|
||||
|
||||
Version 1.3.264 macht den Kampf unter Wasser realistischer. Torpedo-Suchköpfe
|
||||
schauen jetzt in einem Kegel von etwa 45 Grad zu jeder Seite und in einem
|
||||
Tiefenfenster nach vorn, schalten nach Signalstärke gegen ihr Eigengeräusch
|
||||
auf, suchen langsam und leise und sprinten erst nach der Aufschaltung.
|
||||
KI-U-Boote reagieren auf einen Ping nach seiner Lautstärke: ein leiser
|
||||
schickt sie tief und langsam, ein naher lässt sie vom Pinger weglaufen. Sie
|
||||
weichen einem Torpedo aus, indem sie ihn querab nehmen, einen Täuschkörper
|
||||
ausstoßen und davonschleichen, und verstecken sich auf der Seite der
|
||||
Sprungschicht abseits eines ausgebrachten Tiefensonars. Harte Kurven kosten
|
||||
jetzt Fahrt, passive Kontakte an der Erfassungsgrenze schwinden und kommen
|
||||
wieder, und beim Geleitzugangriff warnt die Fregatte ihre Frachter, von denen
|
||||
etwa jeder dritte vor einem gehörten Torpedo abdreht. Spielstände sind v53;
|
||||
v38- bis v52-Spielstände lassen sich weiter laden.
|
||||
Version 1.3.269 gibt jeder gesprochenen Meldung ein klares Ende. Jede
|
||||
Meldung, die die Stimme liest, endet mit einem Punkt, auch nach einem
|
||||
Doppelpunkt oder Auslassungszeichen, und danach folgen 0,6 s Stille, bevor
|
||||
die nächste beginnt. Logmeldungen gehen dafür wieder einzeln an den
|
||||
Sprachdienst, denn ein Sprachmodell macht zwischen zusammen geschickten
|
||||
Meldungen nur eine kurze Satzpause. Antworten des Ersten Offiziers bleiben
|
||||
am Stück. Tasten und Spielstände bleiben gleich (v53; Spielstände v38 bis
|
||||
v52 laden weiter).
|
||||
|
||||
Frühere Versionen: [CHANGELOG.de.md](CHANGELOG.de.md).
|
||||
|
||||
|
||||
@@ -10,20 +10,15 @@ the frigate F-217 with nine stations, or a submarine with seven, and hunt or
|
||||
evade the other side. Friends can crew stations from a browser on the same
|
||||
network.
|
||||
|
||||
Current release: **1.3.264**
|
||||
Current release: **1.3.269**
|
||||
|
||||
Release 1.3.264 makes the underwater fight more realistic. Torpedo seekers
|
||||
now look ahead in a cone of about 45 degrees to each side and within a depth
|
||||
window, lock on by signal strength against their own noise, search slowly
|
||||
and quietly and sprint only once they hold a target. AI submarines react to
|
||||
a ping by its loudness: a faint one sends them deep and slow, a close one
|
||||
makes them run from the pinger. They evade a torpedo by putting it on the
|
||||
beam, dropping a decoy and creeping away, and they hide on the side of the
|
||||
layer away from a streamed variable-depth sonar. Hard turns now cost speed,
|
||||
passive contacts near the detection limit fade in and out, and in the
|
||||
convoy attack the escort warns its merchants, about every third one of
|
||||
which turns away from a torpedo it hears. Saves are v53; v38 to v52 saves
|
||||
still load.
|
||||
Release 1.3.269 gives every spoken report a clear end. Each report the
|
||||
voice reads ends with a full stop, also after a colon or an ellipsis, and
|
||||
0.6 s of silence follows it before the next one starts. Log entries go to
|
||||
the speech service one by one again, because a speech model leaves only a
|
||||
short sentence pause between entries sent together. Answers of the
|
||||
executive officer stay in one piece. Keys and saves are unchanged (v53;
|
||||
v38 to v52 saves still load).
|
||||
|
||||
Earlier releases: [CHANGELOG.md](CHANGELOG.md).
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ Ein OpenAI-kompatibler Sprachdienst (`/audio/speech`) gibt dem Ersten Offizier u
|
||||
- Crew: Mit eingeschalteten **gesprochenen Crew-Meldungen** (Optionen, Seite 2) spricht die Crew mit derselben Stimme statt mit `espeak-ng`; eine Meldung, die der Dienst nicht liefern kann, spricht `espeak-ng`. Meldungen, die älter als 20 s sind, fallen weg, statt verspätet zu kommen.
|
||||
- Log: Seite **4 Meldungen** liest das Log (`F11`) der eigenen Seite vor: **Logmeldungen vorlesen** (ab Werk an, sobald die Stimme eingerichtet ist) und ein Schalter je Station des Logs: Brücke und Navigation (NAV), Funk (FUNK; auf dem U-Boot sein Funkraum), Sonar, Waffen (WAF), OPZ, Schaden und Leckwehr (SCH), Ausguck (AUSG), Mission (MIS) sowie Wetter und Welt (WET). Unter jeder Station zählt die Seite ihre Meldungen der letzten 5 Minuten, so fällt eine Station, die zu viel meldet, gleich auf; solange die Stimme vorliest, hat die untere Zeile des `F11`-Logs je Station einen Knopf („SONAR An“), den ein Klick stumm oder wieder laut schaltet. Jeder Eintrag wird am Stück gesprochen wie ein Satz. Logmeldungen kommen nach den Antworten des Ersten Offiziers und den Crew-Rufen; jede Meldung wird vorgelesen, eine nach der anderen in der Reihenfolge des Logs (erst bei mehr als 48 wartenden fällt die älteste weg), und was die Crew schon ausruft, wird nicht noch einmal vorgelesen. Zahlen kommen wie alles, was die Stimme sagt, Ziffer für Ziffer.
|
||||
- Der Schlüssel liegt in `~/.u-jagd/tts_key` oder kommt aus `U_JAGD_TTS_KEY`. Bleibt er leer, gilt der Schlüssel des Sprachmodells, wenn beide Adressen denselben Server nennen. Wie dieser gelangt er nie in Einstellungen, Spielstände, Protokolle oder einen Browser.
|
||||
- Die Stimme spielt auf einem eigenen Tonkanal und schneidet nie den Sonarton ab; Anfragen und Dekodieren laufen neben dem Spiel, ein langsamer Dienst hält also kein Bild an. Jede Antwort geht am Stück hinaus, und Logmeldungen, die zusammen warten, gehen gemeinsam als eine Anfrage, denn ein Sprachmodell beginnt jede Anfrage mit leicht anderer Stimme; was schon angekommen ist, spielt als ein Stück, damit nichts stockt. Ton, den ein Dienst streamt (OpenAI tut das), spielt schon, während er noch ankommt; wie lange es bis zum ersten Ton dauert, liegt am Dienst. Mit ausgeschaltetem Spielton wird nichts gesprochen.
|
||||
- Die Stimme spielt auf einem eigenen Tonkanal und schneidet nie den Sonarton ab; Anfragen und Dekodieren laufen neben dem Spiel, ein langsamer Dienst hält also kein Bild an. Jede Antwort geht am Stück hinaus, denn ein Sprachmodell beginnt jede Anfrage mit leicht anderer Stimme; jede Meldung endet mit einem Punkt, und jede Logmeldung ist eine eigene Anfrage mit 0,6 s Stille danach, so läuft keine Meldung in die nächste; was schon angekommen ist, spielt als ein Stück, damit nichts stockt. Ton, den ein Dienst streamt (OpenAI tut das), spielt schon, während er noch ankommt; wie lange es bis zum ersten Ton dauert, liegt am Dienst. Mit ausgeschaltetem Spielton wird nichts gesprochen.
|
||||
- Remote-Crew-Browser behalten ihre eigene Stimme für die Crew-Meldungen (Einstellungen, Sprachausgabe des Browsers). Die Antworten des Ersten Offiziers spricht im Browser dieselbe Stimme: Der Host holt den Ton beim Sprachdienst (auch als „Server (nur Browser)“ ohne eigenen Lautsprecher), und nur der Browser, der gefragt hat, spielt ihn ab; Dienst und Schlüssel bleiben auf dem Host. **Antworten vorlesen** im Fenster des Offiziers schaltet das für diesen Browser ab; der Schalter erscheint nur, wenn der Host die Antworten des Offiziers spricht.
|
||||
|
||||
## Sprechtaste und Spracheingabe {#llm-talk}
|
||||
|
||||
@@ -28,7 +28,7 @@ An OpenAI-compatible speech service (`/audio/speech`) gives the executive office
|
||||
- Crew: with **Spoken crew reports** switched on (options page 2) the crew's calls use the same voice instead of `espeak-ng`; a call the service cannot deliver is said by `espeak-ng`. Calls older than 20 s are dropped instead of said late.
|
||||
- Log: page **4 Reports** reads the log (`F11`) of the own side aloud: **Read log entries aloud** (on by default once the voice is set up) and one switch per station of the log: Bridge and navigation (NAV), Radio (FUNK; on the submarine its radio room), Sonar, Weapons (WAF), CIC (OPZ), Damage control (SCH), Lookout (AUSG), Mission (MIS) and Weather and world (WET). Under each station the page counts its entries of the last 5 minutes, so a station that reports too much is easy to find; while the voice reads, the bottom line of the `F11` log has a button per station ("SONAR On") that a click mutes or unmutes. Each entry is said in one piece, like one sentence. Entries come after the executive officer's answers and the crew's calls; every entry is read, one after the other in the log's order (only beyond 48 waiting entries does the oldest drop), and an entry the crew already calls out is not read a second time. Numbers are read digit by digit like everything the voice says.
|
||||
- The key lives in `~/.u-jagd/tts_key` or comes from `U_JAGD_TTS_KEY`. Left empty, the language model's key is used when both addresses name the same server. Like the model's key it never enters the settings, saves, logs or a browser.
|
||||
- The voice plays on its own audio channel and never cuts the sonar tone; requests and decoding run beside the game, so a slow service never stalls a frame. Every answer is sent in one piece, and log entries waiting together go as one request, because a speech model starts every request with a slightly different voice; whatever has arrived plays as one sound so nothing stumbles. Audio that a service streams (OpenAI does) is played while it still arrives; the wait for the first sound is up to the service. With the game sound off nothing is spoken.
|
||||
- The voice plays on its own audio channel and never cuts the sonar tone; requests and decoding run beside the game, so a slow service never stalls a frame. Every answer is sent in one piece, because a speech model starts every request with a slightly different voice; every report ends with a full stop, and each log entry is its own request followed by 0.6 s of silence, so one report never runs into the next; whatever has arrived plays as one sound so nothing stumbles. Audio that a service streams (OpenAI does) is played while it still arrives; the wait for the first sound is up to the service. With the game sound off nothing is spoken.
|
||||
- Remote Crew browsers keep their own voice for the crew's calls (Settings, the browser's speech synthesis). The executive officer's answers are spoken in the browser by the same voice: the host fetches the audio from the speech service (also as "Server (browsers only)" without a speaker of its own), and only the browser that asked plays it; service and key stay on the host. **Speak answers** in the officer's window switches this off for that browser; the switch shows only when the host speaks the officer's answers.
|
||||
|
||||
## Talk key and speech input {#llm-talk}
|
||||
|
||||
Binary file not shown.
@@ -2545,7 +2545,7 @@ Ein OpenAI-kompatibler Sprachdienst (`/audio/speech`) gibt dem Ersten Offizier u
|
||||
- Crew: Mit eingeschalteten **gesprochenen Crew-Meldungen** (Optionen, Seite 2) spricht die Crew mit derselben Stimme statt mit `espeak-ng`; eine Meldung, die der Dienst nicht liefern kann, spricht `espeak-ng`. Meldungen, die älter als 20 s sind, fallen weg, statt verspätet zu kommen.
|
||||
- Log: Seite **4 Meldungen** liest das Log (`F11`) der eigenen Seite vor: **Logmeldungen vorlesen** (ab Werk an, sobald die Stimme eingerichtet ist) und ein Schalter je Station des Logs: Brücke und Navigation (NAV), Funk (FUNK; auf dem U-Boot sein Funkraum), Sonar, Waffen (WAF), OPZ, Schaden und Leckwehr (SCH), Ausguck (AUSG), Mission (MIS) sowie Wetter und Welt (WET). Unter jeder Station zählt die Seite ihre Meldungen der letzten 5 Minuten, so fällt eine Station, die zu viel meldet, gleich auf; solange die Stimme vorliest, hat die untere Zeile des `F11`-Logs je Station einen Knopf („SONAR An“), den ein Klick stumm oder wieder laut schaltet. Jeder Eintrag wird am Stück gesprochen wie ein Satz. Logmeldungen kommen nach den Antworten des Ersten Offiziers und den Crew-Rufen; jede Meldung wird vorgelesen, eine nach der anderen in der Reihenfolge des Logs (erst bei mehr als 48 wartenden fällt die älteste weg), und was die Crew schon ausruft, wird nicht noch einmal vorgelesen. Zahlen kommen wie alles, was die Stimme sagt, Ziffer für Ziffer.
|
||||
- Der Schlüssel liegt in `~/.u-jagd/tts_key` oder kommt aus `U_JAGD_TTS_KEY`. Bleibt er leer, gilt der Schlüssel des Sprachmodells, wenn beide Adressen denselben Server nennen. Wie dieser gelangt er nie in Einstellungen, Spielstände, Protokolle oder einen Browser.
|
||||
- Die Stimme spielt auf einem eigenen Tonkanal und schneidet nie den Sonarton ab; Anfragen und Dekodieren laufen neben dem Spiel, ein langsamer Dienst hält also kein Bild an. Jede Antwort geht am Stück hinaus, und Logmeldungen, die zusammen warten, gehen gemeinsam als eine Anfrage, denn ein Sprachmodell beginnt jede Anfrage mit leicht anderer Stimme; was schon angekommen ist, spielt als ein Stück, damit nichts stockt. Ton, den ein Dienst streamt (OpenAI tut das), spielt schon, während er noch ankommt; wie lange es bis zum ersten Ton dauert, liegt am Dienst. Mit ausgeschaltetem Spielton wird nichts gesprochen.
|
||||
- Die Stimme spielt auf einem eigenen Tonkanal und schneidet nie den Sonarton ab; Anfragen und Dekodieren laufen neben dem Spiel, ein langsamer Dienst hält also kein Bild an. Jede Antwort geht am Stück hinaus, denn ein Sprachmodell beginnt jede Anfrage mit leicht anderer Stimme; jede Meldung endet mit einem Punkt, und jede Logmeldung ist eine eigene Anfrage mit 0,6 s Stille danach, so läuft keine Meldung in die nächste; was schon angekommen ist, spielt als ein Stück, damit nichts stockt. Ton, den ein Dienst streamt (OpenAI tut das), spielt schon, während er noch ankommt; wie lange es bis zum ersten Ton dauert, liegt am Dienst. Mit ausgeschaltetem Spielton wird nichts gesprochen.
|
||||
- Remote-Crew-Browser behalten ihre eigene Stimme für die Crew-Meldungen (Einstellungen, Sprachausgabe des Browsers). Die Antworten des Ersten Offiziers spricht im Browser dieselbe Stimme: Der Host holt den Ton beim Sprachdienst (auch als „Server (nur Browser)“ ohne eigenen Lautsprecher), und nur der Browser, der gefragt hat, spielt ihn ab; Dienst und Schlüssel bleiben auf dem Host. **Antworten vorlesen** im Fenster des Offiziers schaltet das für diesen Browser ab; der Schalter erscheint nur, wenn der Host die Antworten des Offiziers spricht.
|
||||
|
||||
### Sprechtaste und Spracheingabe
|
||||
|
||||
@@ -2544,7 +2544,7 @@ An OpenAI-compatible speech service (`/audio/speech`) gives the executive office
|
||||
- Crew: with **Spoken crew reports** switched on (options page 2) the crew's calls use the same voice instead of `espeak-ng`; a call the service cannot deliver is said by `espeak-ng`. Calls older than 20 s are dropped instead of said late.
|
||||
- Log: page **4 Reports** reads the log (`F11`) of the own side aloud: **Read log entries aloud** (on by default once the voice is set up) and one switch per station of the log: Bridge and navigation (NAV), Radio (FUNK; on the submarine its radio room), Sonar, Weapons (WAF), CIC (OPZ), Damage control (SCH), Lookout (AUSG), Mission (MIS) and Weather and world (WET). Under each station the page counts its entries of the last 5 minutes, so a station that reports too much is easy to find; while the voice reads, the bottom line of the `F11` log has a button per station ("SONAR On") that a click mutes or unmutes. Each entry is said in one piece, like one sentence. Entries come after the executive officer's answers and the crew's calls; every entry is read, one after the other in the log's order (only beyond 48 waiting entries does the oldest drop), and an entry the crew already calls out is not read a second time. Numbers are read digit by digit like everything the voice says.
|
||||
- The key lives in `~/.u-jagd/tts_key` or comes from `U_JAGD_TTS_KEY`. Left empty, the language model's key is used when both addresses name the same server. Like the model's key it never enters the settings, saves, logs or a browser.
|
||||
- The voice plays on its own audio channel and never cuts the sonar tone; requests and decoding run beside the game, so a slow service never stalls a frame. Every answer is sent in one piece, and log entries waiting together go as one request, because a speech model starts every request with a slightly different voice; whatever has arrived plays as one sound so nothing stumbles. Audio that a service streams (OpenAI does) is played while it still arrives; the wait for the first sound is up to the service. With the game sound off nothing is spoken.
|
||||
- The voice plays on its own audio channel and never cuts the sonar tone; requests and decoding run beside the game, so a slow service never stalls a frame. Every answer is sent in one piece, because a speech model starts every request with a slightly different voice; every report ends with a full stop, and each log entry is its own request followed by 0.6 s of silence, so one report never runs into the next; whatever has arrived plays as one sound so nothing stumbles. Audio that a service streams (OpenAI does) is played while it still arrives; the wait for the first sound is up to the service. With the game sound off nothing is spoken.
|
||||
- Remote Crew browsers keep their own voice for the crew's calls (Settings, the browser's speech synthesis). The executive officer's answers are spoken in the browser by the same voice: the host fetches the audio from the speech service (also as "Server (browsers only)" without a speaker of its own), and only the browser that asked plays it; service and key stay on the host. **Speak answers** in the officer's window switches this off for that browser; the switch shows only when the host speaks the officer's answers.
|
||||
|
||||
### Talk key and speech input
|
||||
|
||||
Binary file not shown.
+21
-17
@@ -7,9 +7,10 @@ Requests run on the service's worker; this mixin only collects the pieces
|
||||
of audio that have arrived, once per frame (wall time, outside the
|
||||
simulation), and queues them on the audio engine's own voice channel, so
|
||||
the sonar tone is never cut and a streaming service is heard while it still
|
||||
speaks. Every report goes to the service in one piece, and log entries
|
||||
waiting together are joined into one: a speech model starts each request
|
||||
afresh, so a new request mid-answer audibly changes the speaker's tone.
|
||||
speaks. Every report goes to the service in one piece (a speech model
|
||||
starts each request afresh, so a new request mid-answer audibly changes
|
||||
the speaker's tone), ends with a full stop, and a short silence
|
||||
(``VOICE_GAP_S``) follows it, so one report never runs into the next.
|
||||
The local side's log entries (the event feed, F11) are read aloud too,
|
||||
behind the officer: each station of the log can be muted on its own
|
||||
(options page 2, page 4 "Log reports", and the F11 log's buttons). Every
|
||||
@@ -43,6 +44,8 @@ from src.llm import voice as voice_model
|
||||
from src.llm.voice import PRESET_VOICES, VoiceConfig, VoiceService
|
||||
|
||||
VOICE_QUEUE_MAX = 16
|
||||
# Silence between two reports (wall seconds), so one never runs into the next.
|
||||
VOICE_GAP_S = 0.6
|
||||
# Failures after which a crew report is said by espeak-ng instead.
|
||||
_FALLBACK_ERRORS = frozenset(("network", "timeout", "auth", "rate_limit", "server",
|
||||
"bad_reply", "no_audio"))
|
||||
@@ -67,9 +70,8 @@ def log_group(category) -> str | None:
|
||||
|
||||
|
||||
def _sentence(text: str) -> str:
|
||||
"""A log entry closed like a sentence, so joined entries keep a pause."""
|
||||
text = text.strip()
|
||||
return text if not text or text[-1] in ".!?…:" else text + "."
|
||||
"""A log entry closed like a sentence (a full stop as its end)."""
|
||||
return voice_model.close_sentence(text)
|
||||
|
||||
|
||||
def _host(url: str) -> str:
|
||||
@@ -85,6 +87,8 @@ class VoiceMixin:
|
||||
self._voice_queue: deque = deque(maxlen=VOICE_QUEUE_MAX)
|
||||
self.voice_test = None
|
||||
self._voice_playing = None
|
||||
# A short silence after each report before the next one starts.
|
||||
self._voice_quiet_until = 0.0
|
||||
# Which log is being read and how far (display state, never saved).
|
||||
self._log_voice_source = None
|
||||
self._log_voice_mark = 0
|
||||
@@ -147,7 +151,10 @@ class VoiceMixin:
|
||||
return False
|
||||
if role == "xo" and not self.preferences.tts_xo:
|
||||
return False
|
||||
text = voice_model.speakable(self._voice_text(text), clean=self.voice.config.clean)
|
||||
# Every report ends with a full stop: the model then closes it with
|
||||
# its sentence pause instead of running on.
|
||||
text = voice_model.close_sentence(
|
||||
voice_model.speakable(self._voice_text(text), clean=self.voice.config.clean))
|
||||
if not text:
|
||||
return False
|
||||
# One request for the whole report: the model would start every
|
||||
@@ -246,11 +253,14 @@ class VoiceMixin:
|
||||
self._feed_voice(playing)
|
||||
if playing.finished and not playing.pieces and not self.audio.voice_busy():
|
||||
self._voice_playing = None
|
||||
self._voice_quiet_until = time.monotonic() + VOICE_GAP_S
|
||||
return
|
||||
queue = self._voice_queue
|
||||
if not queue:
|
||||
return
|
||||
now = time.monotonic()
|
||||
if now < self._voice_quiet_until:
|
||||
return
|
||||
kept = []
|
||||
for request in queue:
|
||||
if request.status in ("failed", "dropped"):
|
||||
@@ -388,16 +398,10 @@ class VoiceMixin:
|
||||
if playing is not None and playing.role == "log":
|
||||
in_flight += 1
|
||||
while backlog and in_flight < LOG_IN_FLIGHT:
|
||||
# The entries waiting together go as one request (one even
|
||||
# voice), up to the length one request may have.
|
||||
text = _sentence(backlog.popleft())
|
||||
while backlog:
|
||||
joined = text + " " + _sentence(backlog[0])
|
||||
if len(self._voice_text(joined)) > voice_model.MAX_INPUT_CHARS:
|
||||
break # spoken in full, never cut
|
||||
text = joined
|
||||
backlog.popleft()
|
||||
if self.voice_say(text, "log"):
|
||||
# Each entry is its own request, closed with a full stop, and
|
||||
# VOICE_GAP_S of silence follows it: a speech model leaves only
|
||||
# its short sentence pause between entries sent together.
|
||||
if self.voice_say(_sentence(backlog.popleft()), "log"):
|
||||
in_flight += 1
|
||||
|
||||
# -- settings -----------------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ This module is deliberately dependency-free because setuptools imports the
|
||||
version while building the project.
|
||||
"""
|
||||
|
||||
APP_VERSION = "1.3.264"
|
||||
APP_VERSION = "1.3.269"
|
||||
SAVE_VERSION = 53
|
||||
SAVE_SCHEMA = "u-jagd-save-v53"
|
||||
SPLASH_TEXT = (
|
||||
|
||||
@@ -276,6 +276,21 @@ def clean_for_speech(text) -> str:
|
||||
return re.sub(r"^[,.;:!?\s]+", "", text)
|
||||
|
||||
|
||||
_OPEN_END = re.compile(r"[\s,;:\u2013\u2014\-\u2026.]+$")
|
||||
|
||||
|
||||
def close_sentence(text) -> str:
|
||||
"""``text`` ended like a sentence, with a full stop unless it ends in
|
||||
"!" or "?": a report then ends with the model's sentence pause."""
|
||||
text = text.strip() if type(text) is str else ""
|
||||
if not text or text[-1] in "!?":
|
||||
return text
|
||||
if text[-1] in ")]\"\u201c\u201d\u00bb\u00ab'":
|
||||
return text + "."
|
||||
body = _OPEN_END.sub("", text)
|
||||
return body + "." if body else ""
|
||||
|
||||
|
||||
def speakable(text, limit: int = MAX_INPUT_CHARS, clean: bool = True) -> str:
|
||||
"""One paragraph of text, cut at a sentence end when too long; with
|
||||
``clean`` only the words (``clean_for_speech``)."""
|
||||
|
||||
+55
-6
@@ -256,7 +256,7 @@ def test_the_submarine_reads_its_own_log_not_the_frigates():
|
||||
assert game.log_voice_count("funk") == 1
|
||||
|
||||
|
||||
def test_a_burst_is_read_in_order_joined_and_counts_all():
|
||||
def test_a_burst_is_read_in_order_one_by_one_and_counts_all():
|
||||
game = _game()
|
||||
_Mixer(game)
|
||||
game.preferences = dataclasses.replace(game.preferences, tts_enabled=True,
|
||||
@@ -278,11 +278,9 @@ def test_a_burst_is_read_in_order_joined_and_counts_all():
|
||||
for _round in range(40):
|
||||
game._voice_queue.clear() # said: the next ones go out
|
||||
game._pump_log_voice()
|
||||
# Waiting entries share a request, each closed like a sentence, all in
|
||||
# order, and no request is longer than the service takes.
|
||||
assert len(queued) < 40
|
||||
assert " ".join(queued) == " ".join(f"Weapons entry {n}." for n in range(40))
|
||||
assert all(len(game._voice_text(text)) <= voice.MAX_INPUT_CHARS for text in queued)
|
||||
# Every entry is its own request (a pause follows each), closed with a
|
||||
# full stop, all of them in order.
|
||||
assert queued == [f"Weapons entry {n}." for n in range(40)]
|
||||
assert game.log_voice_count("waffen") == 40
|
||||
|
||||
|
||||
@@ -370,3 +368,54 @@ def test_spoken_letters_never_rename_a_key_chip():
|
||||
german = Translator("de")
|
||||
for key in ("Z", "A", "D", "R", "2", "minus"):
|
||||
assert german.display(key) == key
|
||||
|
||||
|
||||
@pytest.mark.parametrize("text,said", [
|
||||
("Kontakt K1 neu", "Kontakt K1 neu."),
|
||||
("Sonar meldet:", "Sonar meldet."),
|
||||
("Warte …", "Warte."),
|
||||
("Kurs 270, ", "Kurs 270."),
|
||||
("Torpedo im Wasser!", "Torpedo im Wasser!"),
|
||||
("Fahrt (12 kn)", "Fahrt (12 kn)."),
|
||||
("Schon zu Ende.", "Schon zu Ende."),
|
||||
(" ", ""),
|
||||
])
|
||||
def test_every_report_ends_with_a_full_stop(text, said):
|
||||
assert voice.close_sentence(text) == said
|
||||
|
||||
|
||||
def test_a_report_sent_to_the_service_ends_with_a_full_stop():
|
||||
game = _game()
|
||||
_Mixer(game)
|
||||
game.preferences = dataclasses.replace(game.preferences, tts_enabled=True,
|
||||
tts_url="http://127.0.0.1:9/v1", tts_model="tts")
|
||||
game.configure_voice()
|
||||
sent = []
|
||||
game.voice.say = lambda text, language, role: sent.append(text) or voice.VoiceRequest(
|
||||
role, text, language)
|
||||
assert game.voice_say("Contact K1 bearing 270", "crew")
|
||||
assert sent[-1].endswith(".") and not sent[-1].endswith("..")
|
||||
|
||||
|
||||
def test_reports_are_parted_by_a_short_silence(monkeypatch):
|
||||
from src.core import game_voice
|
||||
game = _game()
|
||||
mixer = _Mixer(game)
|
||||
game.preferences = dataclasses.replace(game.preferences, tts_enabled=True,
|
||||
tts_url="http://127.0.0.1:9/v1", tts_model="tts")
|
||||
game.configure_voice()
|
||||
clock = [100.0]
|
||||
monkeypatch.setattr(game_voice.time, "monotonic", lambda: clock[0])
|
||||
first, second = (voice.VoiceRequest("log", text, "en") for text in ("One.", "Two."))
|
||||
for request in (first, second):
|
||||
request.created = clock[0]
|
||||
request._finish("done", pcm=np.ones(100, np.int16))
|
||||
game._voice_queue.append(request)
|
||||
game._pump_voice()
|
||||
assert len(mixer.played) == 1
|
||||
game._pump_voice() # the first one has ended
|
||||
game._pump_voice()
|
||||
assert len(mixer.played) == 1 # silence before the next report
|
||||
clock[0] += game_voice.VOICE_GAP_S + 0.01
|
||||
game._pump_voice()
|
||||
assert len(mixer.played) == 2
|
||||
@@ -86,7 +86,7 @@ def test_source_and_wheel_contain_editor_templates(tmp_path):
|
||||
(ROOT / "data/contact_analysis" / name).read_bytes()
|
||||
assert any(name.endswith(".dist-info/licenses/THIRD_PARTY_NOTICES.md")
|
||||
for name in wheel_names)
|
||||
assert any(name.endswith("-1.3.264.dist-info/METADATA") for name in wheel_names)
|
||||
assert any(name.endswith("-1.3.269.dist-info/METADATA") for name in wheel_names)
|
||||
|
||||
source = next(tmp_path.glob("u_jagd-*.tar.gz"))
|
||||
with tarfile.open(source) as archive:
|
||||
@@ -139,7 +139,7 @@ def test_source_and_wheel_contain_editor_templates(tmp_path):
|
||||
[sys.executable, "-c",
|
||||
"from importlib import resources; "
|
||||
"assert resources.files('data.editor_templates').joinpath('mission.json').is_file(); "
|
||||
"from src.core.version import APP_VERSION; assert APP_VERSION == '1.3.264'; "
|
||||
"from src.core.version import APP_VERSION; assert APP_VERSION == '1.3.269'; "
|
||||
"from src.commander.server import CommanderServer; "
|
||||
"server=CommanderServer(); server.start('127.0.0.1',0); server.stop(); "
|
||||
"from src.core import manual; page=manual.html_page('de'); assert 'station-sonar' in page; "
|
||||
|
||||
@@ -14,9 +14,9 @@ from src.world.real_coast import sector_for_seed
|
||||
|
||||
|
||||
def test_release_version_and_exact_splash_text():
|
||||
assert APP_VERSION == "1.3.264"
|
||||
assert APP_VERSION == "1.3.269"
|
||||
assert SPLASH_TEXT == (
|
||||
"Anti Sub Marine Warfare on uConsole by Dominik Bornhäußer Version 1.3.264"
|
||||
"Anti Sub Marine Warfare on uConsole by Dominik Bornhäußer Version 1.3.269"
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user