text-to-speech-converter is a Node.js package that provides a simple API for converting text to speech using the festival
text-to-speech synthesis tool.
git clone https://github.com/Francis-Mwaniki/TextToSpeechApi
Before you can use this package, you need to ensure that the festival
text-to-speech synthesis tool is installed on your system. Follow the instructions below based on your operating system:
sudo apt-get update
sudo apt-get install festival
brew install festival
Windows Subsystem for Linux (WSL) allows you to run a Linux distribution alongside your Windows installation. This method enables you to use Festival within a Linux environment on your Windows system.
-
Enable WSL: Follow the instructions from Microsoft's official documentation to enable WSL on your Windows version. You can find detailed steps here.
-
Install a Linux Distribution:
- Open Microsoft Store and search for a Linux distribution like Ubuntu.
- Install the Linux distribution of your choice.
-
Open the Installed Linux Distribution:
- After installation, open the installed Linux distribution from the Start menu. It will open a Linux terminal window.
-
Install and Run Festival:
- Inside the Linux terminal, you can use standard Linux commands, including installing and running Festival. For example:
sudo apt-get update sudo apt-get install festival festival
- Inside the Linux terminal, you can use standard Linux commands, including installing and running Festival. For example:
const TextToSpeech = require('text-to-speech-converter')
async function testSpeechGeneration() {
try {
const outputFilePath = 'output';
const text = 'Hello francis, this is a test';
const result = await TextToSpeech(text, outputFilePath);
console.log(result);
} catch (error) {
console.error('Error:', error);
}
}
testSpeechGeneration();
The TextToSpeech
function takes in two parameters:
text
: The text to be converted to speech.outputFilePath
: The path to the output file where the speech will be saved.
The function returns a promise that resolves to the path of the output file.
node test.js