v0.1: Robovoice — PTT re-voicing app
WinForms tray app that captures text (from file or direct input) and synthesizes speech via libpiper (Piper TTS), outputting to any audio device (VB-CABLE for virtual mic routing). Features: - Global PTT hotkey (configurable F1-F12) via WH_KEYBOARD_LL - Text file sequential reader (line-by-line on each PTT cycle) - Direct text input with Speak button - Voice manager: browse 147-voice Piper catalogue, download, remove - libpiper P/Invoke wrapper with UTF-8 marshaling, streaming chunks - BufferedWaveProvider streaming playback with trailing silence flush - Sentence terminator auto-append (fixes espeak-ng final-word drop) - Tray icon with minimize-to-tray Architecture: - Robovoice.Core: ITtsEngine, ISttSource interfaces, voice catalogue - Robovoice.Tts.LibPiper: P/Invoke wrapper for libpiper.dll - Robovoice.Stt.File: text file STT source (testing without mic server) - Robovoice.Stt.Udp: UDP client stub (for future Linux mic server) - Robovoice.App: WinForms UI, orchestrator, PTT hotkey, audio output
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
using Robovoice.Core;
|
||||
|
||||
namespace Robovoice.Stt.File;
|
||||
|
||||
public sealed class FileSttSource : ISttSource
|
||||
{
|
||||
private readonly object _lock = new();
|
||||
private string[] _lines = Array.Empty<string>();
|
||||
private int _currentIndex;
|
||||
private bool _disposed;
|
||||
|
||||
public event TranscriptEventHandler? TranscriptReceived;
|
||||
|
||||
public string FilePath { get; set; } = string.Empty;
|
||||
public int LineCount { get; private set; }
|
||||
public int CurrentIndex => _currentIndex;
|
||||
|
||||
public void LoadFile(string path)
|
||||
{
|
||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||
FilePath = path;
|
||||
_lines = System.IO.File.ReadAllLines(path);
|
||||
LineCount = _lines.Length;
|
||||
_currentIndex = 0;
|
||||
}
|
||||
|
||||
public string? GetPendingLine()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_lines.Length == 0) return null;
|
||||
int idx = _currentIndex % _lines.Length;
|
||||
return _lines[idx];
|
||||
}
|
||||
}
|
||||
|
||||
public void EmitNext()
|
||||
{
|
||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||
string? line = null;
|
||||
lock (_lock)
|
||||
{
|
||||
if (_lines.Length > 0)
|
||||
{
|
||||
int idx = _currentIndex % _lines.Length;
|
||||
line = _lines[idx];
|
||||
_currentIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
TranscriptReceived?.Invoke(this, new TranscriptEventArgs
|
||||
{
|
||||
Message = new TranscriptMessage(TranscriptType.Final, line!),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_currentIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken ct = default)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken ct = default)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public ValueTask DisposeAsync()
|
||||
{
|
||||
_disposed = true;
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Robovoice.Core\Robovoice.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user