(Oct 4, 2025 09:25 AM)HerrWinston Wrote: Hello you all, I am working on a project I have in mind and I am looking for good ways of getting answers for my input through text to speech so for example you make an input and the voice answers you for testing it would be enough to just get the input as output, I have looked through some libraries but they all sound so extremely robotic, i am looking for something sounding natural or where i can customize the voice completely to my liking, I have tested pyttsx3 but it wasnt really for me, because of said reasons
I would love to hear your ideas! :)
I like what you're doing, my friend.I'll give you a basic example of when I was thinking about things like you.you have various engines you can use but if you want to learn and make custom you can try this :P
TTS libraries sounding robotic simple answer why not use your own voice :P
simple example:
Code
using System;
using System.Collections.Generic;
using System.IO;
using NAudio.Wave;
class Program
{
static void Main()
{
var wordToWavMap = new Dictionary<string, string>
{
{ "hello", "hello.wav" },
{ "world", "world.wav" }
// Add more words as needed
};
Console.WriteLine("Enter a sentence:");
string input = Console.ReadLine().ToLower();
foreach (var word in input.Split(' '))
{
if (wordToWavMap.TryGetValue(word, out var wavFile))
{
PlayWav(wavFile);
}
else
{
Console.WriteLine($"Word '{word}' not recognized.");
}
}
}
static void PlayWav(string wavFile)
{
if (!File.Exists(wavFile))
{
Console.WriteLine($"WAV file '{wavFile}' not found.");
return;
}
try
{
using var audioFile = new AudioFileReader(wavFile);
using var outputDevice = new WaveOutEvent();
outputDevice.Init(audioFile);
outputDevice.Play();
while (outputDevice.PlaybackState == PlaybackState.Playing)
{
System.Threading.Thread.Sleep(100);
}
}
catch (Exception ex)
{
Console.WriteLine($"Error playing '{wavFile}': {ex.Message}");
}
}
}
But for example by using NAudio, you can actually build your own "custom TTS engine" with some limitations.The idea is simple: instead of using robotic prebuilt TTS libraries, you record your own voice (or a set of voices) saying all the words or phonemes you need, and then play them back dynamically.But this is just thinking outside the box,but with the right implementation of NAudio you can do really great things and you will actually have absolutely complete control, volume,sleed etc etc...
I hope this was informative. <3