Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves #118: text to speech #119

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
target/
logs/

log/
logs/
*.wav

# IntelliJ
.DS_Store
.idea
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package de.gleex.pltcmd.game.application.examples.speaker

import de.gleex.pltcmd.game.sound.speech.Speaker
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import org.hexworks.cobalt.logging.api.LoggerFactory

private val log = LoggerFactory.getLogger("SpeakerExample")

private val texts = listOf(
"Hello World!",
"Bravo, engage enemy at (1 1 5| 2 2 4), out."
)

@ExperimentalCoroutinesApi
fun main() {

/*
Documentation about maryTTS can be found here: http://marytts.phonetik.uni-muenchen.de:59125/documentation.html

Available effects: http://marytts.phonetik.uni-muenchen.de:59125/audioeffects
The list is:
Volume amount:2.0;
TractScaler amount:1.5;
F0Scale f0Scale:2.0;
F0Add f0Add:50.0;
Rate durScale:1.5;
Robot amount:100.0;
Whisper amount:100.0;
Stadium amount:100.0
Chorus delay1:466;amp1:0.54;delay2:600;amp2:-0.10;delay3:250;amp3:0.30
FIRFilter type:3;fc1:500.0;fc2:2000.0
JetPilot

Description for a specific effect (change effect name in the URL):
http://marytts.phonetik.uni-muenchen.de:59125/audioeffect-help?effect=TractScaler
*/

log.info("Starting Speaker...")
Speaker.startup()

for (text in texts) {
log.info("Saying '$text'...")
runBlocking {
Speaker.say(text)
delay(100)
Speaker.waitForQueueToEmpty()
}
log.info("")
log.info(" - - -")
log.info("")
}

runBlocking {
delay(500)
Speaker.waitForQueueToEmpty()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import de.gleex.pltcmd.game.engine.entities.types.callsign
import de.gleex.pltcmd.game.engine.entities.types.element
import de.gleex.pltcmd.game.options.GameOptions
import de.gleex.pltcmd.game.options.UiOptions
import de.gleex.pltcmd.game.sound.speech.Speaker
import de.gleex.pltcmd.game.ticks.Ticker
import de.gleex.pltcmd.game.ui.entities.GameWorld
import de.gleex.pltcmd.game.ui.mapgeneration.MapGenerationProgressController
Expand All @@ -22,6 +23,7 @@ import de.gleex.pltcmd.model.world.Sector
import de.gleex.pltcmd.model.world.WorldMap
import de.gleex.pltcmd.model.world.coordinate.Coordinate
import de.gleex.pltcmd.model.world.toSectorOrigin
import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.hexworks.amethyst.api.Engine
import org.hexworks.cobalt.logging.api.LoggerFactory
import org.hexworks.zircon.api.SwingApplications
Expand All @@ -32,16 +34,19 @@ import org.hexworks.zircon.api.screen.Screen
import java.util.concurrent.TimeUnit
import kotlin.random.Random

@ExperimentalCoroutinesApi
private val log = LoggerFactory.getLogger(::main::class)
private val random = Random(GameOptions.MAP_SEED)

@ExperimentalCoroutinesApi
fun main() {
Main().run()
}

/**
* Setups, starts and runs the game.
*/
@ExperimentalCoroutinesApi
open class Main {

/**
Expand All @@ -50,6 +55,8 @@ open class Main {
open fun run() {
val application = SwingApplications.startApplication(UiOptions.buildAppConfig())

Speaker.startup()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this takes some time consider calling this asynchronous!


val tileGrid = application.tileGrid
val screen = tileGrid.toScreen()

Expand Down
3 changes: 1 addition & 2 deletions game/application/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
<logger name="org.hexworks.cobalt" level="WARN"/>

<logger name="de.gleex.pltcmd.game.application" level="DEBUG"/>
<!-- <logger name="de.gleex.pltcmd.model" level="DEBUG"/>-->
<!-- <logger name="de.gleex.pltcmd.game.ui.renderers.SignalVisualizer" level="DEBUG"/>-->
<logger name="de.gleex.pltcmd.game.ui" level="DEBUG"/>
<!-- <logger name="de.gleex.pltcmd.game.engine.systems" level="DEBUG"/>-->

<logger name="de.gleex.pltcmd.game.engine.Game" level="TRACE" additivity="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ object GameOptions {
* Vertical number of sectors in the world.
*/
const val SECTORS_COUNT_V: Int = 10

const val SOUND_ENABLED = true
}
6 changes: 6 additions & 0 deletions game/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<module>ui</module>
<module>engine</module>
<module>ui-strings</module>
<module>sound</module>
</modules>

<dependencies>
Expand Down Expand Up @@ -76,6 +77,11 @@
<artifactId>ui-strings</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>de.gleex.pltcmd.game</groupId>
<artifactId>sound</artifactId>
<version>${project.version}</version>
</dependency>
<!-- other internal projects -->
<dependency>
<groupId>de.gleex.pltcmd.model</groupId>
Expand Down
53 changes: 53 additions & 0 deletions game/sound/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>game</artifactId>
<groupId>de.gleex.pltcmd.game</groupId>
<version>0.2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>sound</artifactId>
<name>Sound</name>
<description>Everything related to sound output.</description>

<properties>
<marytts.version>5.2</marytts.version>
<marytts.version.beta>${marytts.version}-beta3</marytts.version.beta>
</properties>

<dependencies>
<dependency>
<groupId>de.gleex.pltcmd.game</groupId>
<artifactId>options</artifactId>
</dependency>

<dependency>
<groupId>de.dfki.mary</groupId>
<artifactId>voice-cmu-rms-hsmm</artifactId>
<version>${marytts.version}</version>
<exclusions>
<exclusion>
<groupId>de.dfki.mary</groupId>
<artifactId>marytts-runtime</artifactId>
</exclusion>
<exclusion>
<groupId>de.dfki.mary</groupId>
<artifactId>marytts-common</artifactId>
</exclusion>
<exclusion>
<groupId>de.dfki.mary</groupId>
<artifactId>marytts-signalproc</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- We need the beta version of the runtime as the Rate-Effect does not work in 5.2 -->
<dependency>
<groupId>de.dfki.mary</groupId>
<artifactId>marytts-runtime</artifactId>
<version>${marytts.version.beta}</version>
</dependency>
</dependencies>
</project>
Loading