added automatic inclusion of voice add-ons

Signed-off-by: Kai Kreuzer <kai@openhab.org>
pull/136/head
Kai Kreuzer 2016-11-11 09:41:49 +01:00 committed by Thomas Dietrich
parent d1e667aa54
commit a0424deca7
6 changed files with 205 additions and 0 deletions

4
_data/voice.csv Normal file
View File

@ -0,0 +1,4 @@
id,label,description
marytts,Mary Text-to-Speech,"The Mary Text-to-Speech (TTS) service is a pure Java implementation of a TTS service, which uses the [MaryTTS](http://mary.dfki.de/) project of DFKI."
voicerss,VoiceRSS Text-to-Speech,"VoiceRSS is an Internet based TTS service hosted at http://api.voicerss.org."
voicerss,VoiceRSS Text-to-Speech,"VoiceRSS is an Internet based TTS service hosted at http://api.voicerss.org."
1 id label description
2 marytts Mary Text-to-Speech The Mary Text-to-Speech (TTS) service is a pure Java implementation of a TTS service, which uses the [MaryTTS](http://mary.dfki.de/) project of DFKI.
3 voicerss VoiceRSS Text-to-Speech VoiceRSS is an Internet based TTS service hosted at http://api.voicerss.org.
4 voicerss VoiceRSS Text-to-Speech VoiceRSS is an Internet based TTS service hosted at http://api.voicerss.org.

View File

@ -62,6 +62,13 @@
{% endfor %}
</ul>
</li>
<li><a href="{{docu}}/addons/voice.html">Voice Services</a>
<ul>
{% for binding in site.data.voice %}
<li><a href="{{docu}}/addons/voice/{{ voice.id }}/readme.html">{{ voice.label }}</a></li>
{% endfor %}
</ul>
</li>
<li><a href="{{docu}}/addons/io.html">System Integrations</a>
<ul>
<li><a href="{{docu}}/addons/io/homekit/readme.html">HomeKit</a></li>

16
addons/voice.md Normal file
View File

@ -0,0 +1,16 @@
---
layout: documentation
---
{% include base.html %}
# List of Available Voice Services
{% assign voices = "" | split: "|" %}
{% for voice in site.data.voice %}{% assign voices = voices | push: voice %}{% endfor %}
{% assign sorted_voices = voices | sort: "id" %}
| Voice Service | Description |
|-------|----------------------|
{% for voice in sorted_voices %}| [{{ voice.label }}]({{docu}}/addons/voice/{{ voice.id }}/readme.html) | {{ voice.description }} |
{% endfor %}

View File

@ -0,0 +1,33 @@
---
layout: documentation
---
{% include base.html %}
# Mary Text-to-Speech
## Overview
The Mary Text-to-Speech (TTS) service is a pure Java implementation of a TTS service, which uses the [MaryTTS](http://mary.dfki.de/) project of DFKI.
While it provides good quality results, it must be noted that it is too heavy-weight for most embedded hardware like Raspberry Pis. When using this service, you should be running openHAB on some real server instead.
## Configuration
There is no need to configure anything for this service.
## Voices
MaryTTS comes with three packages voices, one for American English, two for German:
```
> voice voices
marytts:cmuslthsmm cmu-slt-hsmm (en_US)
marytts:bits3hsmm bits3-hsmm (de)
marytts:bits1hsmm bits1-hsmm (de)
```
## Supported Audio Formats
The MaryTTS service produces audio streams using WAV containers and PCM (signed) codec with 16bit depth.
The sample frequency depends on the chosen voice and ranges from 16kHz to 48kHz.

View File

@ -0,0 +1,66 @@
---
layout: documentation
---
{% include base.html %}
# VoiceRSS Text-to-Speech
## Overview
VoiceRSS is an Internet based TTS service hosted at http://api.voicerss.org.
It requires an API Key to get access to this service. The free version allows to make up to 350 requests/day, for more you may need a commercial subscription.
For more information, see http://www.voicerss.org/
## Samples
Replace API_KEY with your personal API key for simple testing of different API calls:
```
# EN
https://api.voicerss.org/?key=API_KEY&hl=en-us&src=Hello%20World
https://api.voicerss.org/?key=API_KEY&hl=en-us&c=WAV&src=Hello%20World
https://api.voicerss.org/?key=API_KEY&hl=en-us&f=44khz_16bit_mono&src=Hello%20World
https://api.voicerss.org/?key=API_KEY&hl=en-gb&f=44khz_16bit_stereo&src=Hello%20World
# DE
https://api.voicerss.org/?key=API_KEY&hl=de-de&f=44khz_16bit_mono&src=Hallo%20Welt
```
## Configuration
You have to add your API_KEY to your configuration, e.g. by adding a file "voicerss.cfg" to the services folder, with this entry:
```
apiKey=1234567890
```
It actually supports only one voice: "voicerss:default", which is configured to use 44kHz, mono, 16 bit sampling quality.
## Caching
The VoiceRSS extension does cache audio files from previous requests, to reduce traffic, improve performance, reduce number of requests and provide same time offline capability.
For convenience, there is a tool where the audio cache can be generated in advance, to have a prefilled cache when starting this extension. You have to copy the generated data to your userdata/voicerss/cache folder.
Synopsis of this tool:
```
Usage: java org.openhab.voice.voicerss.tool.CreateTTSCache <args>
Arguments: --api-key <key> <cache-dir> <locale> { <text> | @inputfile }
key the VoiceRSS API Key, e.g. "123456789"
cache-dir is directory where the files will be stored, e.g. "voicerss-cache"
locale the language locale, has to be valid, e.g. "en-us", "de-de"
text the text to create audio file for, e.g. "Hello World"
inputfile a name of a file, where all lines will be translatet to text, e.g. "@message.txt"
Sample: java org.openhab.voice.voicerss.tool.CreateTTSCache --api-key 1234567890 cache en-US @messages.txt
```
## Open Issues
* add all media formats
* add all supported languages
* do not log API-Key in plain text

79
pom.xml
View File

@ -149,6 +149,34 @@
</resources>
</configuration>
</execution>
<execution>
<id>copy-voice-docs</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/addons/voice</outputDirectory>
<resources>
<resource>
<directory>${basedir}/_repos/smarthome/extensions/voice</directory>
<includes>
<include>**/README.md</include>
<include>**/doc/**</include>
<include>**/cfg/**</include>
</includes>
</resource>
<resource>
<directory>${basedir}/_repos/openhab2-addons/addons/voice</directory>
<includes>
<include>**/README.md</include>
<include>**/doc/**</include>
<include>**/cfg/**</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-io-docs</id>
<phase>process-resources</phase>
@ -249,6 +277,57 @@
</source>
</configuration>
</execution>
<execution>
<id>rename-voice-files</id>
<phase>process-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
def voice = new File(project.basedir, 'addons/voice')
def voiceList = new File(project.basedir, '_data/voice.csv')
voiceList.write("id,label,description\n")
voice.eachFile
{
def name = it.name
if(name.contains('voice')) {
def voiceId =
it.name.replace('org.eclipse.smarthome.voice.', '').replace('org.openhab.voice.', '')
def simpleVoiceNameDir = new
File(voice.path, voiceId)
it.renameTo(simpleVoiceNameDir)
def readme = new
File(simpleVoiceNameDir.path, 'README.md')
if(readme.exists()) {
println readme
readme.renameTo(new File(simpleVoiceNameDir.path, 'readme.md'))
if(!readme.text.startsWith('---')) {
readme.write("---\nlayout: documentation\n---\n\n{% include base.html %}\n\n" + readme.text)
}
def label = readme.readLines().find{it.startsWith('#')}.replace('#', '').trim()
def description = ""
boolean firstHeadline = false
for(def line : readme.readLines()) {
if(line.startsWith('#')) {
if(!firstHeadline) {
firstHeadline = true
}
} else {
if(firstHeadline &amp;&amp; line.trim().size() > 0) {
description = line.trim()
break
}
}
}
voiceList.append(voiceId + ',' + label + ',"' + description + '"\n')
}
}
}
</source>
</configuration>
</execution>
<execution>
<id>rename-iconset-files</id>
<phase>process-resources</phase>