GameVoice 1.1.1

dotnet add package GameVoice --version 1.1.1
                    
NuGet\Install-Package GameVoice -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GameVoice" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GameVoice" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="GameVoice" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GameVoice --version 1.1.1
                    
#r "nuget: GameVoice, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GameVoice@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GameVoice&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=GameVoice&version=1.1.1
                    
Install as a Cake Tool

GameVoice

Reusable Blazor Server voice and text chat library (speech recognition, TTS, voice floor, in-game and lobby text chat) 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.

Disclaimer

GameVoice is not an AI bot. It does not generate replies, and there is no AI model or chatbot in the library. It only relays what players type or say to the other players in the same game or lobby group, and reads those messages aloud with the browser's built-in text-to-speech.

GameVoice does not log, store or share personal information about users, apart from speech-to-text audio, which some browsers (e.g. Chrome and Edge) send to their vendor's speech service:

  • It writes nothing to disk or to a database, and makes no network calls of its own. Chat messages are kept only in server memory (the lobby keeps the last 200), so they are gone when the app restarts.
  • The only thing it saves in the browser is the "talk enabled" setting (GameVoiceTalkEnabled in localStorage).
  • Debug messages, including transcripts and spoken text, go only to the browser's own developer console.

Speech recognition is done by the browser's Web Speech API, not by GameVoice. Some browsers (for example Chrome and Edge) send the audio to their vendor's online speech service to turn it into text; see your browser's privacy policy. Apps that use GameVoice (such as Draughts and Reversi) have their own accounts and storage, which are covered by those apps, not by this library.

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

  1. Reference the package (from nuget.org, so no extra package source or token is needed):

    <PackageReference Include="GameVoice" Version="1.1.0" />
    
  2. Load the scripts before the app's own scripts in App.razor:

    <script src="_content/GameVoice/gameVoice.js"></script>
    <script src="_content/GameVoice/gameChat.js"></script>
    
  3. Give each game (room) a VoiceRoom and implement IVoiceRoomHost on 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
        }
    }
    
  4. Register services in Program.cs:

    builder.Services.AddSingleton<ChessService>();
    builder.Services.AddSingleton<IVoiceRoomHost>(sp => sp.GetRequiredService<ChessService>());
    builder.Services.AddGameVoice();
    
  5. Detect support once after first render and drop the controls into the page (@using GameVoice in _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");
    

    TranscriptReceived gets the trimmed final text; post it to your chat (e.g. with a [VOICE] prefix). Use _voiceControls.Status for a status line ("Hold to talk", "Sam talking…", "Mic error: …"). To read messages aloud call GameVoice.speakAndDescribe(text, voiceKey, language, region) or GameVoice.speakDefaultAndDescribe(text) with the sender's room.GetPreference(senderId).

Text chat:

  • In-game: give each game a ChatLog (public ChatLog ChatMessages { get; } = new();), add messages with TryAdd(senderId, senderName, text) or AddSystem(text), and show ChatMessages.Format(startIndex, hideVoice).
  • Lobby: call builder.Services.AddGameChat(); and inject LobbyChatService; subscribe to ChatUpdated to 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.1 0 11/25/2026
1.1.0 92 11/23/2026
1.0.0 94 11/23/2026
1.0.0-preview.3 58 11/23/2026