Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
krogenth committed Oct 22, 2023
1 parent 99442eb commit 5c90be1
Show file tree
Hide file tree
Showing 60 changed files with 2,500 additions and 0 deletions.
384 changes: 384 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build Job

on: [pull_request, push]

env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: .

jobs:
build:
runs-on: windows-latest
strategy:
matrix:
dotnet-version: [ '7.0.x' ]
configuration: [ Debug, Release ]

steps:
- uses: actions/checkout@v3

- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Install Dependencies
run: dotnet restore

- name: Build
run: dotnet build -c ${{ matrix.configuration }}
86 changes: 86 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Release Job

on:
push:
branches: [ main ]

concurrency: release

env:
SOLUTION_FILE_PATH: .
BASE_VERSION: 0.1
RELEASE_DIRECTORY: "release_output"
PUBLISH_DIRECTORY: "publish"

jobs:
tag:
name: Create Release Tag
runs-on: ubuntu-latest
steps:
- name: Get Version Info
id: version_info
run: |
echo "build_version=${{ env.BASE_VERSION }}.${{ github.run_number }}" >> $GITHUB_OUTPUT
shell: bash

- name: Create Tag
uses: actions/github-script@v6
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.version_info.outputs.build_version }}',
sha: context.sha
})
release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
dotnet-version: [ '7.0.x' ]
configuration: [ Release ]
os: [ windows-latest ]
include:
- os: windows-latest
OS_NAME: Windows x64
DOTNET_RUNTIME_IDENTIFIER: win10-x64
RELEASE_ZIP_OS_NAME: win_x64

steps:
- uses: actions/checkout@v3

- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Get Version Info
id: version_info
run: |
echo "build_version=${{ env.BASE_VERSION }}.${{ github.run_number }}" >> $GITHUB_OUTPUT
echo "git_short_hash=$(git rev-parse --short "${{ github.sha }}")" >> $GITHUB_OUTPUT
shell: bash

- name: Create Output Directory
run: "mkdir ${{ env.RELEASE_DIRECTORY }}"

- name: Run Publish
run: |
dotnet publish -c Release -r "${{ matrix.DOTNET_RUNTIME_IDENTIFIER }}" -o ./${{ env.PUBLISH_DIRECTORY }} -p:Version="${{ steps.version_info.outputs.build_version }}" -p:SourceRevisionId="${{ steps.version_info.outputs.git_short_hash }}" -p:DebugType=embedded src/G2DataGUI --self-contained true
- name: Pack Windows Build
if : matrix.os == 'windows-latest'
run: |
7z a ./${{ env.RELEASE_DIRECTORY }}/G2DataGUI-${{ steps.version_info.outputs.build_version }}-win_x64.zip ./${{ env.PUBLISH_DIRECTORY }}
shell: bash

- name: Push Release
uses: ncipollo/release-action@v1
with:
name: ${{ steps.version_info.outputs.build_version }}
artifacts: "${{ env.RELEASE_DIRECTORY }}/*.tar.gz,${{ env.RELEASE_DIRECTORY }}/*.zip"
tag: ${{ steps.version_info.outputs.build_version }}
allowUpdates: true
omitBodyDuringUpdate: true
replacesArtifacts: true
178 changes: 178 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates
.vs
.vscode

# Build results
[Dd]ebug/
[Rr]elease/
x64/
[Bb]uild/
[Bb]in/
[Oo]bj/
[Pp]ublish/

# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# Rider is a Visual Studio alternative
.idea/*

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
packages/*
*.config

# Include nuget.config
!nuget.config

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf


#LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml

# =========================
# Windows detritus
# =========================

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac desktop service store files
.DS_Store

# VS Launch Settings
launchSettings.json

# NetCore Publishing Profiles
PublishProfiles/

# Glade backup files
*.glade~

# game directories
/[Cc]ontent/
24 changes: 24 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<!-- Avalonia UI Packages -->
<PackageVersion Include="Avalonia" Version="11.0.4" />
<PackageVersion Include="Avalonia.Desktop" Version="11.0.4" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageVersion Include="Avalonia.Diagnostics" Version="11.0.4" Condition="'$(Configuration)' == 'Debug'" />
<PackageVersion Include="Avalonia.ReactiveUI" Version="11.0.4" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.0.4" />
<PackageVersion Include="FluentAvaloniaUI" Version="2.0.4" />

<!-- Audio Packages -->
<PackageVersion Include="NAudio" Version="2.2.1" />

<!-- Speech-To-Text Frameworks -->
<PackageVersion Include="Vosk" Version="0.3.38" />

<!-- Text-to-Speech Frameworks -->
<PackageVersion Include="System.Speech" Version="7.0.0" />
</ItemGroup>
</Project>
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# STTTS

## Setup

1. Setup a Virtual Audio Cable like [VB-Cable](https://vb-audio.com/Cable/).
2. For Vosk Recognition, you will need a model, many can be found [here](https://alphacephei.com/vosk/models), I would recommend the [vosk-model-small-en-us](https://alphacephei.com/vosk/models/vosk-model-small-en-us-0.15.zip).
3. Extract the downloaded Vosk model (preferably to the same directory as `STTTS`).
3. Open whatever application you wish to use `STTTS` with, and set the Input device/Microphone to the `CABLE Output` device (for CB-Cable).
4. Download and extract the latest version from [here](https://github.com/krogenth/STTTS/releases).
5. Run `STTTS`, open the Option Settings.
6. In Audio, configure the Output device to the `CABLE Input` device (for VB-Cable).
6. In Vosk, click the `Change` button to select the directory containing the Vosk model to be used (i.e. - `vosk-model-small-en-us` for the small english Vosk model).
6. Click the Start buttons for both `Recognizer` and `Synthesizer` to begin recognizing and outputting speech.

## How to use

The application is fairly simplistic in its current state. Settings are currently not saved and thus need to be reconfigured each time the application is used.
The Voice setting can be changed at any time, even while the Synthesizer is running. However, if input/output/playback devices are changed, the respective recognizer/synthesizer will stop running.
The Synthesizer playback checkbox will enable or disable playing the synthesized audio to the selected Playback device in the Audio settings page.

## Future Development

I am unsure how often I will actually work on this, but I would like to expand the number of recognizers and synthesizers possible, as the C# System Speech Synthesizer is somewhat limited.
I would also like to allow this to work with OSC to enable input comments and textbox typing in VRChat.
8 changes: 8 additions & 0 deletions STTTS.Common/Audio/AudioDeviceTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace STTTS.Common.Audio;

public enum AudioDeviceType
{
Input,
Output,
Playback,
};
24 changes: 24 additions & 0 deletions STTTS.Common/Audio/AudioDevices.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using NAudio.CoreAudioApi;

namespace STTTS.Common.Audio;

public static class AudioDevices
{
public static IEnumerable<MMDevice> GetOutputAudioDevices()
{
using var enumerator = new MMDeviceEnumerator();
return enumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active);
}

public static IEnumerable<MMDevice> GetInputAudioDevices()
{
using var enumerator = new MMDeviceEnumerator();
return enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active);
}

public static MMDevice? GetDeviceByID(string id)
{
using var mMDeviceEnumerator = new MMDeviceEnumerator();
return mMDeviceEnumerator.GetDevice(id);
}
}
18 changes: 18 additions & 0 deletions STTTS.Common/Audio/InstalledVoices.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Speech.Synthesis;

namespace STTTS.Common.Audio;

public static class InstalledVoices
{
public static IEnumerable<InstalledVoice> GetVoices()
{
using var synthesizer = new SpeechSynthesizer();

Check warning on line 9 in STTTS.Common/Audio/InstalledVoices.cs

View workflow job for this annotation

GitHub Actions / build (7.0.x, Debug)

This call site is reachable on all platforms. 'SpeechSynthesizer' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 9 in STTTS.Common/Audio/InstalledVoices.cs

View workflow job for this annotation

GitHub Actions / build (7.0.x, Release)

This call site is reachable on all platforms. 'SpeechSynthesizer' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
return synthesizer.GetInstalledVoices();

Check warning on line 10 in STTTS.Common/Audio/InstalledVoices.cs

View workflow job for this annotation

GitHub Actions / build (7.0.x, Debug)

This call site is reachable on all platforms. 'SpeechSynthesizer.GetInstalledVoices()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 10 in STTTS.Common/Audio/InstalledVoices.cs

View workflow job for this annotation

GitHub Actions / build (7.0.x, Release)

This call site is reachable on all platforms. 'SpeechSynthesizer.GetInstalledVoices()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
}

public static InstalledVoice? GetVoiceByID(string id)
{
using var synthesizer = new SpeechSynthesizer();

Check warning on line 15 in STTTS.Common/Audio/InstalledVoices.cs

View workflow job for this annotation

GitHub Actions / build (7.0.x, Debug)

This call site is reachable on all platforms. 'SpeechSynthesizer' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 15 in STTTS.Common/Audio/InstalledVoices.cs

View workflow job for this annotation

GitHub Actions / build (7.0.x, Release)

This call site is reachable on all platforms. 'SpeechSynthesizer' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
return synthesizer.GetInstalledVoices().Single(voice => voice.VoiceInfo.Id == id);

Check warning on line 16 in STTTS.Common/Audio/InstalledVoices.cs

View workflow job for this annotation

GitHub Actions / build (7.0.x, Debug)

This call site is reachable on all platforms. 'SpeechSynthesizer.GetInstalledVoices()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 16 in STTTS.Common/Audio/InstalledVoices.cs

View workflow job for this annotation

GitHub Actions / build (7.0.x, Debug)

This call site is reachable on all platforms. 'InstalledVoice.VoiceInfo' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 16 in STTTS.Common/Audio/InstalledVoices.cs

View workflow job for this annotation

GitHub Actions / build (7.0.x, Debug)

This call site is reachable on all platforms. 'VoiceInfo.Id' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 16 in STTTS.Common/Audio/InstalledVoices.cs

View workflow job for this annotation

GitHub Actions / build (7.0.x, Debug)

This call site is reachable on all platforms. 'InstalledVoice' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 16 in STTTS.Common/Audio/InstalledVoices.cs

View workflow job for this annotation

GitHub Actions / build (7.0.x, Release)

This call site is reachable on all platforms. 'InstalledVoice' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 16 in STTTS.Common/Audio/InstalledVoices.cs

View workflow job for this annotation

GitHub Actions / build (7.0.x, Release)

This call site is reachable on all platforms. 'SpeechSynthesizer.GetInstalledVoices()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 16 in STTTS.Common/Audio/InstalledVoices.cs

View workflow job for this annotation

GitHub Actions / build (7.0.x, Release)

This call site is reachable on all platforms. 'VoiceInfo.Id' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 16 in STTTS.Common/Audio/InstalledVoices.cs

View workflow job for this annotation

GitHub Actions / build (7.0.x, Release)

This call site is reachable on all platforms. 'InstalledVoice.VoiceInfo' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
}
}
Loading

0 comments on commit 5c90be1

Please sign in to comment.