Anonymous user
Speech synthesis: Difference between revisions
→{{header|Scala}}
(Adds Clojure solution) |
|||
Line 248:
=={{header|Scala}}==
[[Category:Scala Implementations]]
{{libheader|FreeTTS|1.2}}<lang scala>import javax.speech.Central
▲import javax.speech.synthesis.{ Synthesizer, SynthesizerModeDesc }
object ScalaSpeaker extends App {
def speech(text: String) = {
if (!text.trim.isEmpty
val VOICENAME = "kevin16"
System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory")
Central.registerEngineCentral("com.sun.speech.freetts.jsapi.FreeTTSEngineCentral")
val synth = Central.createSynthesizer(
synth.allocate()
val desc = synth.getEngineModeDesc
▲ .setVoice(desc.getVoices().find(_.toString() == VOICENAME).get)
▲ synth.speak(text, null)
synth.waitEngineState(Synthesizer.QUEUE_EMPTY)
Line 280 ⟶ 273:
}
speech( "
|I see broad rivers
|slowly chuntering
|through endless lowlands,
|rows of implausibly
|airy poplars
|standing like tall plumes
|against the horizon;
|and sunk in the unbounded
|vastness of space
|homesteads and boweries
|dotted across the land,
|copses, villages,
|couchant towers,
|churches and elm-trees,
|bound in one great unity.
|There the sky hangs low,
|and steadily the sun
|is smothered in a greyly
|iridescent smirr,
|and in every province
|the voice of water
|with its lapping disasters
|is feared and hearkened.""".stripMargin)
}</lang>
|