SpongeEngine.FakeYouSharp
1.1.1
dotnet add package SpongeEngine.FakeYouSharp --version 1.1.1
NuGet\Install-Package SpongeEngine.FakeYouSharp -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="SpongeEngine.FakeYouSharp" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SpongeEngine.FakeYouSharp --version 1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SpongeEngine.FakeYouSharp, 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.
// Install SpongeEngine.FakeYouSharp as a Cake Addin #addin nuget:?package=SpongeEngine.FakeYouSharp&version=1.1.1 // Install SpongeEngine.FakeYouSharp as a Cake Tool #tool nuget:?package=SpongeEngine.FakeYouSharp&version=1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FakeYouSharp
C# client for the FakeYou TTS API.
Features
- Easy-to-use API for text-to-speech generation
- Cross-platform WAV audio processing
- Built-in format conversion to 16-bit PCM
- Engine-agnostic design (works with Unity, Godot, and other frameworks)
- Configurable retry policies for improved reliability
- Full async/await support
- Comprehensive logging capabilities
- Strong type safety
Installation
Install FakeYouSharp via NuGet:
dotnet add package FakeYouSharp
Quick Start
using FakeYouSharp.Client;
// Create a client instance
var client = new FakeYouClient(options =>
{
options.ApiKey = "your_api_key"; // Optional
options.Timeout = TimeSpan.FromMinutes(2);
});
// Generate speech
var modelToken = "TM:1234"; // Replace with actual model token
var text = "Hello, world!";
byte[] audioData = await client.GenerateAudioAsync(modelToken, text);
// List available voice models
var models = await client.GetVoiceModelsAsync();
foreach (var model in models)
{
Console.WriteLine($"Voice: {model.Title} ({model.ModelToken})");
}
Audio Format
FakeYouSharp automatically handles audio format conversion. The library:
- Accepts various input formats from FakeYou API
- Automatically converts to 16-bit PCM WAV
- Preserves original sample rate (typically 32kHz, 44.1kHz, or 48kHz)
- Maintains channel configuration (mono/stereo)
Using with Different Frameworks
Unity
byte[] audioData = await client.GenerateAudioAsync(modelToken, text);
// Convert to Unity AudioClip
var audioClip = AudioClip.Create("TTS", /* samples */ ...);
audioClip.SetData(/* your conversion code */);
Godot
byte[] audioData = await client.GenerateAudioAsync(modelToken, text);
// Convert to Godot AudioStreamWav
var stream = new AudioStreamWav();
stream.Data = audioData;
stream.Format = AudioStreamWav.FormatEnum.Format16Bits;
// Set other properties as needed
Raw Audio Processing
byte[] audioData = await client.GenerateAudioAsync(modelToken, text);
// Get format information
var wavProcessor = new WavProcessor();
var format = wavProcessor.GetWavFormat(audioData);
Console.WriteLine($"Sample Rate: {format.SampleRate}Hz");
Console.WriteLine($"Bits Per Sample: {format.BitsPerSample}");
Console.WriteLine($"Channels: {format.Channels}");
Advanced Usage
Custom Configuration
var client = new FakeYouClient(options =>
{
options.ApiKey = "your_api_key";
options.MaxRetryAttempts = 3;
options.RetryDelay = TimeSpan.FromSeconds(2);
options.Logger = yourLoggerInstance;
options.ValidateResponseData = true;
});
Progress Tracking
client.OnProgress += (progress) =>
{
switch (progress.State)
{
case FakeYouProgressState.Starting:
Console.WriteLine("Starting generation...");
break;
case FakeYouProgressState.Processing:
Console.WriteLine($"Processing: {progress.Message}");
break;
case FakeYouProgressState.Complete:
Console.WriteLine("Generation complete!");
break;
}
};
Error Handling
try
{
var audioData = await client.GenerateAudioAsync(modelToken, text);
}
catch (FakeYouException ex)
{
Console.WriteLine($"FakeYou API error: {ex.Message}");
if (ex.StatusCode.HasValue)
{
Console.WriteLine($"Status code: {ex.StatusCode}");
}
}
catch (Exception ex)
{
Console.WriteLine($"General error: {ex.Message}");
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Please see CONTRIBUTING.md for details on:
- How to publish to NuGet
- Development guidelines
- Code style
- Testing requirements
- Pull request process
Support
For issues and feature requests, please use the GitHub issues page.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.Extensions.Caching.Memory (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Polly (>= 8.5.0)
-
net7.0
- Microsoft.Extensions.Caching.Memory (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Polly (>= 8.5.0)
-
net8.0
- Microsoft.Extensions.Caching.Memory (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Polly (>= 8.5.0)
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 | 75 | 1/1/2025 |