GameVoice 1.0.0
See the version list below for details.
dotnet add package GameVoice --version 1.0.0
NuGet\Install-Package GameVoice -Version 1.0.0
<PackageReference Include="GameVoice" Version="1.0.0" />
<PackageVersion Include="GameVoice" Version="1.0.0" />
<PackageReference Include="GameVoice" />
paket add GameVoice --version 1.0.0
#r "nuget: GameVoice, 1.0.0"
#:package GameVoice@1.0.0
#addin nuget:?package=GameVoice&version=1.0.0
#tool nuget:?package=GameVoice&version=1.0.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. |
Text chat, game rules and persistence 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.0.0" />Load the script before the app's own scripts in
App.razor:<script src="_content/GameVoice/gameVoice.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).
Rooms are not tied to two players: a WalkieTalkie group or a lobby can be a VoiceRoom too.
Building and releasing
dotnet test GameVoice.slnx
dotnet pack src/GameVoice -c Release -o artifacts
To publish, bump nothing and push a tag: git tag v1.0.1 && git push origin v1.0.1. 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.