Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
MaryTTS is an open-source, Text-to-Speech Synthesis platform written in Java:
http://mary.dfki.de

I try to implement an example from GitHub (3 line codes, please find as follows).
Subject: Simple text-to-speech with default settings:
https://github.com/marytts/marytts/wiki/MaryInterface#simple-text-to-speech-with-default-settings

Java
MaryInterface marytts = new LocalMaryInterface();
AudioInputStream audio = marytts.generateAudio("This is my text.");
MaryAudioUtils.writeWavFile(MaryAudioUtils.getSamplesAsDoubleArray(audio), "/tmp/thisIsMyText.wav", audio.getFormat());

I installed Mary TTS on my Windows, using MaryTTS installer:
https://github.com/marytts/marytts-installer

I started the Mary TTS server and the Mary TTS client (http://localhost:59125), and I did some trials with text to audio conversion (its great).

I hope I'm not bothering you with too much of a newbie questions.
I've spent a few hours over the last three weeks on this issue but with no success.

Just to get started.., I can't realize how to implement this example.
I.e. After using MaryTTS installer, what steps are needed to get the above example code to work?

Thanks again for the help request.
Mike
Posted

1 solution

Im quite new too but i will try to help you with it.
First of all you need to import the classes from your importet lib. (which you can download at http://mary.dfki.de/download/index.html[^]. Btw. its the runtimepackage so you dont need the server...
To set up your interface you need the following:
import marytts.LocalMaryInterface;
import marytts.MaryInterface;

The example is writing a wave called thisIsMyText in your tmp folder on your system.
After this you have to open it and then you can play it.
try this to play the wave within your project.

try {
		    AudioInputStream input = AudioSystem.getAudioInputStream(new File("/tmp/thisIsMyText.wav"));
		    SourceDataLine line = AudioSystem.getSourceDataLine(input.getFormat());
		    line.open(input.getFormat());
		    line.start();
		    byte[] buffer = new byte[1024];
		    int count;
		    while((count = input.read(buffer, 0, 1024)) != -1) {
		        line.write(buffer, 0, count);
		    }
		    line.drain();
		    line.stop();
		    line.close();
		} catch(Exception e) {
		    e.printStackTrace();
		}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900