GameVoice 1.1.0
dotnet add package GameVoice --version 1.1.0
NuGet\Install-Package GameVoice -Version 1.1.0
<PackageReference Include="GameVoice" Version="1.1.0" />
<PackageVersion Include="GameVoice" Version="1.1.0" />
<PackageReference Include="GameVoice" />
paket add GameVoice --version 1.1.0
#r "nuget: GameVoice, 1.1.0"
#:package GameVoice@1.1.0
#addin nuget:?package=GameVoice&version=1.1.0
#tool nuget:?package=GameVoice&version=1.1.0
GameVoice
Reusable Blazor Server voice library (speech recognition, TTS, voice floor) for Draughts, Reversi and future games
such as Chess and WalkieTalkie. It is a Razor class library published as the GameVoice package on nuget.org.
What's in the package
| Piece | Purpose |
|---|---|
wwwroot/gameVoice.js (window.GameVoice) |
Browser speech recognition (push-to-talk), TTS unlock, voice enumeration/diagnostics, voice matching and speak* helpers. Calls back into .NET via OnVoiceTranscript, OnVoiceError and OnVoiceEnded. |
VoiceRoom |
Game-independent voice state for one room: talk floor (take/renew/release with expiry), room mute (only the muter can unmute) and each user's preferred TTS voice/language/region. Thread-safe. |
VoiceRoomService |
Room-id based operations on VoiceRooms; notifies the app's IVoiceRoomHost after each change. |
IVoiceRoomHost |
Implemented by the app (e.g. the game service): finds a room by id and reacts to changes (touch timeouts, raise UI updates, announce voices). |
VoiceControls.razor |
Talk (hold to talk) and Mute/Unmute buttons. Owns the push-to-talk lifecycle: floor acquire/renew every 2 s/release, GameVoice.start/stop, transcript and error callbacks. |
VoicePreference |
A user's TTS voice key/language/region, with normalisation. |
IVoiceCatalog, VoiceCatalogEntry, VoiceCatalog |
Interface for the admin-allowed voice catalogue (storage stays in the app, e.g. a UsableMsVoice table) and token/key helpers. |
IVoicePreferenceStore |
Optional interface for persisting per-user voice preferences. |
wwwroot/gameChat.js (window.GameChat) |
Text chat helpers: scrollToBottom(el) and wireEnterToSend(el, dotNetRef, methodName = 'OnChatEnterFromJs'). |
ChatMessage |
One chat line (time, sender id/name, text, optional lobby group). VoicePrefix ([VOICE] ) marks speech transcripts; IsVoice tests for it. |
ChatLog |
Thread-safe in-game chat for one room: TryAdd (normalises text), AddSystem, Clear, indexer/Count, and Format(startIndex, hideVoice) for a chat textarea. |
LobbyChatService |
Shared lobby chat: group-only messages, admin broadcasts to every group, system messages, per-user delete/clear, last 200 messages, ChatUpdated event. Register with AddGameChat(). |
Game rules, persistence and the chat/lobby page layout stay in each app.
Using it in an app
Reference the package (from nuget.org, so no extra package source or token is needed):
<PackageReference Include="GameVoice" Version="1.1.0" />Load the script before the app's own scripts in
App.razor:<script src="_content/GameVoice/gameVoice.js"></script> <script src="_content/GameVoice/gameChat.js"></script>Give each game (room) a
VoiceRoomand implementIVoiceRoomHoston the service that owns the games:public class ChessGame { public VoiceRoom Voice { get; } = new(); } public class ChessService : IVoiceRoomHost { public VoiceRoom? FindVoiceRoom(string roomId) => GetGame(roomId)?.Voice; public void OnVoiceRoomChanged(string roomId, VoiceRoomChange change) { // touch the game's idle timer and raise your GameUpdated event } }Register services in
Program.cs:builder.Services.AddSingleton<ChessService>(); builder.Services.AddSingleton<IVoiceRoomHost>(sp => sp.GetRequiredService<ChessService>()); builder.Services.AddGameVoice();Detect support once after first render and drop the controls into the page (
@using GameVoicein_Imports.razor):<VoiceControls @ref="_voiceControls" RoomId="@_gameId" UserId="@_userId" UserName="@_userName" Supported="@_voiceSupported" SupportChecked="@_voiceSupportChecked" TalkEnabled="@_talkEnabled" TranscriptReceived="OnVoiceTranscript" MessageRaised="OnVoiceMessage" />await JS.InvokeAsync<bool>("GameVoice.installTtsUnlocker"); _voiceSupported = await JS.InvokeAsync<bool>("GameVoice.isSupported");TranscriptReceivedgets the trimmed final text; post it to your chat (e.g. with a[VOICE]prefix). Use_voiceControls.Statusfor a status line ("Hold to talk", "Sam talking…", "Mic error: …"). To read messages aloud callGameVoice.speakAndDescribe(text, voiceKey, language, region)orGameVoice.speakDefaultAndDescribe(text)with the sender'sroom.GetPreference(senderId).
Text chat:
- In-game: give each game a
ChatLog(public ChatLog ChatMessages { get; } = new();), add messages withTryAdd(senderId, senderName, text)orAddSystem(text), and showChatMessages.Format(startIndex, hideVoice). - Lobby: call
builder.Services.AddGameChat();and injectLobbyChatService; subscribe toChatUpdatedto re-render. - Enter-to-send:
await JS.InvokeVoidAsync("GameChat.wireEnterToSend", textareaRef, dotNetRef);calls the component's[JSInvokable] OnChatEnterFromJs();GameChat.scrollToBottom(el)keeps the latest line visible.
Rooms are not tied to two players: a WalkieTalkie group or a lobby can be a VoiceRoom (and a ChatLog) too.
Building and releasing
dotnet test GameVoice.slnx
dotnet pack src/GameVoice -c Release -o artifacts
The tag must start with v or V followed by the version, e.g. v1.0.1. Any other tag (such as 1.0.1 or release-1.0.1) does not publish anything.
Git tags are case-sensitive but Windows is not, so don't create both v1.0.1 and V1.0.1.
To publish, bump nothing and push a tag: git tag v1.0.1 && git push origin v1.0.1, or create a GitHub release with that tag. The
publish workflow packs that version and pushes it to nuget.org using nuget.org
Trusted Publishing (policy: owner djaus2, repo GameVoice, workflow publish.yml; no API key or secret). New versions take a few minutes to appear after nuget.org validates them.
Then bump <PackageReference Include="GameVoice" Version="..." /> in each app.
To try library changes in an app before publishing, pack to a local folder and restore from it:
dotnet pack src/GameVoice -c Release -o ~/localfeed -p:Version=1.0.1-dev
dotnet add <app>.csproj package GameVoice --version 1.0.1-dev --source ~/localfeed
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.0 | 0 | 11/23/2026 |
| 1.0.0 | 0 | 11/23/2026 |
| 1.0.0-preview.3 | 0 | 11/23/2026 |