Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
adstep committed Nov 25, 2022
0 parents commit 06f9f95
Show file tree
Hide file tree
Showing 50 changed files with 2,561 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/**/appsettings.secret.json
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Speech To Chess

Play chess in the browser using voice commands.

A speech-to-chess console application that allows the user to play on the popular chess website Lichess using their voice. Supports running on Windows Desktop Speech technology, locally, or Azure Cognitive Services, if configured for remote.

## Usage

SpeechToChess.exe --help
SpeechToChess 1.0.0
Copyright (C) 2022 SpeechToChess

-e, --engine (Default: Local) Set speech recognition engine.

--help Display this help screen.

--version Display version information.


## Configuration

All configuration is done via an ```appsettings.local.json``` that should be adjacent ot the exe.

### **Cognitive**

Configuration for Azure Cognitive Services. Only necessary if running using ```Cognitive``` Speech recognition engine. To setup the necessary resources, you can follow the run-script ```./scripts/setup.ps1```.

**Key**: The Speech resource key the endpoint is associated with.
**Region**: The Azure region the endpoint is associated with.
**EndpointId**: The identifier of the endpoint.

Example:

```json
{
"Cognitive": {
"Key": "",
"Region": "",
"EndpointId": ""
}
}
```

### **Lichess**

Configuration for logging onto a specified Lichess account.

**UserName**: Lichess userName.
**Passowrd**: Lichess password.

Example:
```json
{
"Lichess": {
"UserName": "",
"Password": ""
}
}
```

## Supported voice commands

Valid chess moves in ```Algebraic Notation```:
* move {file} {rank} to {file} {rank}
* {file} {rank} [moves] to {file} {rank}
* move {piece} to {file} {rank}
* {piece} [moves] to {file} {rank}
* {piece} {file} {rank}
* king-side [castle]
* queen-side [castle]
* [promote] {file} eight [to] {piece}

A number of other commands are supported:
* ```clear```/```undo```: Clears lichess text input
* ```resign```: Inputs lichess resign command
* ```draw```: Inputs lichess draw command
* ```clock```/```time```: Inputs lichess clock command
* ```who```: Inputs lichess who command
* ```next```: Inputs lichess next puzzle command
* ```puzzle```: Navigates lichess to puzzle page
* ```home```: Navigates lichess to home page

See [algebraic-notation.md](./config/algebraic-notation.md) for complete description of supported commands. File is written in structured text data supported by Azure Cognitive Services. Read [structured-text-data-for-training](https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/how-to-custom-speech-test-and-train#structured-text-data-for-training) for in-depth description of format.
58 changes: 58 additions & 0 deletions config/algebraic-notation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@list command =
- clear :
- undo
- resign
- draw
- clock :
- time
- who
- next
- puzzle
- home

@ list piece =
- king
- queen
- bishop
- knight
- rook
- pawn

@ list file =
- a :
- alpha
- b :
- bravo
- c :
- charlie
- d :
- delta
- e :
- echo
- f :
- foxtrot
- g :
- golf
- h :
- hotel

@ list rank =
- one
- two
- three
- four
- five
- six
- seven
- eight

#AlgebraicNotation_Section1
- move {@file} {@rank} to {@file} {@rank}
- {@file} {@rank} [moves] to {@file} {@rank}
- move {@piece} to {@file} {@rank}
- {@piece} [moves] to {@file} {@rank}
- {@piece} {@file} {@rank}
- king-side [castle]
- queen-side [castle]
- [promote] {@file} eight [to] {@piece}
- {@command}
7 changes: 7 additions & 0 deletions license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2022 Adam Stephenson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
78 changes: 78 additions & 0 deletions scripts/setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
$region = "westus2"
$rgName = "stc-rg-demo"
$name = "stc-cog-demo"

Write-Host "Log in to your Azure account..."
Connect-AzAccount

Write-Host "Creating resource group..."
New-AzResourceGroup `
-Location $region `
-Name $rgName `
-Force `
| Out-Null

Write-Host "Creating CognitiveServices Account..."
New-AzCognitiveServicesAccount `
-ResourceGroupName $rgName `
-Name $name `
-Type CognitiveServices `
-SkuName "S0" `
-Location $region `
-Force `
| Out-Null

Write-Host "Note: No API exists for creating an CognitiveServices endpoint, so we'll walk through the steps manually..."

Write-Host "Navigating to speech studio..."
Start-Process "https://speech.microsoft.com/portal/844856f4c9ce4426884a3741b3106393/customspeech"

Write-Host "Click 'Create a project'"
Read-Host "`tPress (enter) to continue"

Write-Host "Input details into 'New Project' Form"
Read-Host "`tPress (enter) to continue"

Write-Host "Navigate to your Custom Speech project"
Read-Host "`tPress (enter) to continue"

Write-Host "Click 'Upload data'"
Read-Host "`tPress (enter) to continue"

Write-Host "Click 'Structure text' then 'Next'"
Read-Host "`tPress (enter) to continue"

Write-Host "Select 'config/algebraic-notation.md' to upload"
Read-Host "`tPress (enter) to continue"

Write-Host "Name 'Algebraic Notation Dataset'"
Read-Host "`tPress (enter) to continue"

Write-Host "Review details and click 'Save and close'"
Read-Host "`tPress (enter) to continue"

Write-Host "Click 'Train custom models'"
Read-Host "`tPress (enter) to continue"

Write-Host "Click 'Train a new model'"
Read-Host "`tPress (enter) to continue"

Write-Host "Select 'General' scenario and latest baseline model"
Read-Host "`tPress (enter) to continue"

Write-Host "Choose 'Algebraic Notation Dataset'"
Read-Host "`tPress (enter) to continue"

Write-Host "Name 'Algebraic Notation Model'"
Read-Host "`tPress (enter) to continue"

Write-Host "Click 'Deploy models'"
Read-Host "`tPress (enter) to continue"

Write-Host "Name 'Algebraic Notation Endpoint' and select 'Algebraic Notation Model'"
Read-Host "`tPress (enter) to continue"

Write-Host "Open 'Algebraic Notation Endpoint' to retrieve 'EndpointId', 'Region' and 'Key'"
Read-Host "`tPress (enter) to continue"

Write-Host "Done!"
Loading

0 comments on commit 06f9f95

Please sign in to comment.