Here is my code :
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package speech;
import java.util.* ;
// import marytts . modules . synthesis . voice . * ;
import marytts.MaryInterface;
import marytts.modules.synthesis.Voice;
import javax.sound.sampled.AudioInputStream;
import marytts.LocalMaryInterface;
import marytts.util.data.audio.AudioPlayer;
public class App {
// variable to hold the text that will be audible
public static void main( String args[ ] )
{
try {
// creating an object of the class TexttoSpeech
MaryInterface marytts = new LocalMaryInterface();
Set<String> voices = marytts.getAvailableVoices();
System.out.println(marytts.getAvailableVoices());
//marytts.setLocale(Locale.FRENCH);
//marytts.setVoice("enst-camille-hsmm");
AudioInputStream audio = marytts.generateAudio("Good luck Alexandre, Self Destruction in 5, 4, 3, 2, 1");
AudioPlayer player = new AudioPlayer(audio);
player.start();
player.join();
} catch (Exception e) {
e.printStackTrace();
}
}
}
It works fine
i have a libs folder where i put a jar file with a french voice for marytts :
libs/marytts-lang-fr-5.2.jar
Here is my build.gradle file :
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
configurations.implementation.setCanBeResolved(true)
// tag::repositories[]
repositories{
mavenCentral()
flatDir name: 'localRepository',dirs: '.libs/'
exclusiveContent {
forRepository {
maven {
url 'https://mlt.jfrog.io/artifactory/mlt-mvn-releases-local'
}
}
filter {
includeGroup 'de.dfki.lt.jtok'
}
}
}
// end::repositories[]
// tag::dependencies[]
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
implementation fileTree(dir: '.libs/', include: '*.jar')
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
implementation "joda-time:joda-time:2.2"
implementation "junit:junit:4.12"
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'org.apache.commons:commons-lang3:3.5'
testImplementation 'junit:junit:4.13'
implementation 'org.apache.logging.log4j:log4j-api:2.18.0'
implementation 'org.apache.logging.log4j:log4j-core:2.18.0'
implementation group: 'de.dfki.mary', name: 'voice-cmu-slt-hsmm', version: '5.2.1', {
exclude group: 'com.twmacinta', module: 'fast-md5'
exclude group: 'gov.nist.math', module: 'Jampack'
}
//compile 'commons-cli:commons-cli:1.3.1'
//compile 'de.dfki.mary:voice-cmu-slt-hsmm:5.2-beta3'
}
sourceSets.main.java.srcDirs = ['src']
mainClassName = 'speech.App'
run {
//jvmArgs = ['-D java.library.path=./lib/']
systemProperty 'java.library.path','.libs/'
}
tasks.withType(Tar){
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.withType(Zip){
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.withType(Jar){
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
task fatJar(type: Jar) {
archiveVersion = '0.1.0'
manifest {
attributes('Implementation-Title': 'Gradle Jar File Example', 'Implementation-Version': archiveVersion,'Main-Class': mainClassName )
}
archiveBaseName = project.name + '-all'
from { configurations.implementation.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
// tag::jar[]
jar {
archiveBaseName = 'speech'
archiveVersion = '0.1.0'
manifest {
attributes(
'Class-Path': configurations.implementation.collect { it.getName() }.join(' '),
'Main-Class': mainClassName
)
}
}
test {
useJUnitPlatform()
}
How can i add the new voice from the marytts-lang-fr-5.2.jar to marytts ?
I would like to know how to do that it seems that now marytts can add new voice from a jar very easily, but i didn't found how to do that.
edit : there is a test project here : https://github.com/bussiere/SpeechTest Regards