Aquila.TTSandSTT 1.0.5

dotnet add package Aquila.TTSandSTT --version 1.0.5
                    
NuGet\Install-Package Aquila.TTSandSTT -Version 1.0.5
                    
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="Aquila.TTSandSTT" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aquila.TTSandSTT" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Aquila.TTSandSTT" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Aquila.TTSandSTT --version 1.0.5
                    
#r "nuget: Aquila.TTSandSTT, 1.0.5"
                    
#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.
#:package Aquila.TTSandSTT@1.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Aquila.TTSandSTT&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Aquila.TTSandSTT&version=1.0.5
                    
Install as a Cake Tool

Aquila.TTSandSTT Library

Cross-platform TTS (Text-to-Speech) and STT (Speech-to-Text) library for .NET MAUI / .NET 9.0

Supports Android fully and can be extended for other platforms (Windows, iOS, macOS).


Table of Contents

  1. Overview

  2. Installation

  3. Usage

    • Speak
    • Listen
    • Save to File
  4. API Reference

  5. Platform-specific Notes

  6. Permissions

  7. Troubleshooting

  8. Example MAUI Project


Overview

Aquila.TTSandSTT provides a unified interface for:

  • Text-to-Speech (TTS): Speak any string or save it as audio.
  • Speech-to-Text (STT): Capture spoken input and return text.

It is designed as a singleton service for easy DI integration in .NET MAUI apps.


Installation

  1. Add Aquila.TTSandSTT project/library to your solution.
  2. Add reference to your MAUI project.
  3. Ensure your TargetFrameworks include Android:
<TargetFrameworks>net9.0-android;net9.0-windows10.0.19041.0</TargetFrameworks>

Usage

1. Register the service (MAUI MauiProgram.cs)

using Aquila.TTSandSTT;

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();

        // Register the TTS/STT service
        builder.Services.AddSingleton(sp => ServiceHelper.GetVoiceService());

        builder
            .UseMauiApp<App>()
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
            });

        return builder.Build();
    }
}

2. Inject into MainPage

using Aquila.TTSandSTT.Interfaces;

public partial class MainPage : ContentPage
{
    private readonly IAquilaVoice _voice;

    public MainPage(IAquilaVoice voice)
    {
        InitializeComponent();
        _voice = voice;
    }
}

3. Speak Text

await _voice.SpeakAsync("Hello World!", rate: 1.0f, pitch: 1.0f);

4. Listen (Speech-to-Text)

string result = await _voice.ListenAsync(language: "en-US", timeoutSeconds: 10);
Console.WriteLine(result);

5. Save Speech to File

string path = Path.Combine(FileSystem.AppDataDirectory, "speech.wav");
await _voice.SaveSpeechToFileAsync("Hello World", path);
Console.WriteLine($"Saved to {path}");

API Reference

IAquilaVoice

Method Description Parameters Return
Task SpeakAsync(string text, string language = "en-US", float pitch = 1.0f, float rate = 1.0f) Speak text aloud text, language, pitch, rate Task
Task<string> ListenAsync(string language = "en-US", int timeoutSeconds = 10) Capture speech and return as text language, timeoutSeconds Task<string>
Task<string> SaveSpeechToFileAsync(string text, string filePath, string language = "en-US", float pitch = 1.0f, float rate = 1.0f) Save speech to audio file text, filePath, language, pitch, rate Task<string>
bool IsSpeaking Check if TTS is currently speaking — bool

Platform-specific Notes

  • Android: Full TTS & STT support.
  • Windows: Currently TTS/STT methods throw NotSupportedException.
  • iOS/macOS: Can implement using AVSpeechSynthesizer and SpeechRecognizer in future versions.

Permissions

For Android, add these to AndroidManifest.xml:

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />

Note: Runtime permission request is required on Android 6.0+:

var status = await Permissions.RequestAsync<Permissions.Microphone>();
if (status != PermissionStatus.Granted)
{
    await DisplayAlert("Permission", "Microphone permission is required", "OK");
}

Troubleshooting

  • Ambiguous reference errors (TextToSpeech, Locale, Application): Use fully qualified names:

    var tts = new global::Android.Speech.Tts.TextToSpeech(...);
    var locale = new global::Java.Util.Locale("en-US");
    var context = global::Android.App.Application.Context;
    
  • Windows compilation errors: Wrap Android-specific code in #if ANDROID ... #endif.

  • STT returns empty: Ensure microphone permission is granted and device supports speech recognition.


Example MAUI Page

<VerticalStackLayout Padding="20">
    <Editor x:Name="InputText" HeightRequest="100" Placeholder="Enter text"/>
    <Button Text="Speak" Clicked="SpeakClicked"/>
    <Button Text="Listen" Clicked="ListenClicked"/>
    <Label x:Name="ResultText"/>
</VerticalStackLayout>
private async void SpeakClicked(object sender, EventArgs e)
{
    await _voice.SpeakAsync(InputText.Text);
}

private async void ListenClicked(object sender, EventArgs e)
{
    string text = await _voice.ListenAsync();
    ResultText.Text = text;
}

Product Compatible and additional computed target framework versions.
.NET net9.0-android35.0 is compatible.  net9.0-windows10.0.19041 is compatible.  net10.0-android was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0.5 186 2/11/2026
1.0.4 135 2/11/2026
1.0.3 135 2/11/2026
1.0.2 128 2/11/2026
1.0.1 129 2/11/2026
1.0.0 127 2/11/2026