Skip to content
Snippets Groups Projects
Commit 0843f778 authored by Stuart Mark James's avatar Stuart Mark James
Browse files

README, build target for audio, tweak tests

parent f5a75383
No related branches found
No related tags found
No related merge requests found
......@@ -126,8 +126,19 @@ target_include_directories(TextToSpeech
PRIVATE ${INCLUDE_PATHS}
PRIVATE "${PROJECT_BINARY_DIR}")
# copy the jingles into the build environment so we can test with them
file(COPY jingles DESTINATION ${CMAKE_BINARY_DIR})
# Assets -----------------------------------
# Prepare the audio files for use, copy to the build env and convert
set(JINGLE_DIR "${CMAKE_CURRENT_BINARY_DIR}/jingles")
add_custom_command(
OUTPUT ${JINGLE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/jingles ${CMAKE_CURRENT_BINARY_DIR}/jingles)
add_custom_target(
convert-audio
COMMAND ${CMAKE_SOURCE_DIR}/scripts/convert_audio_files "${CMAKE_CURRENT_BINARY_DIR}/jingles"
DEPENDS ${JINGLE_DIR})
# Tests -----------------------------------
if(TEXT_TO_SPEECH_BUILD_TESTS)
......
LICENSE 0 → 100644
This diff is collapsed.
# TextToSpeech
TextToSpeech (TTS) is a text to speech service TANGO device server. It is based on Amazon Web Services (AWS), and writes its audio via Pulse Audio. The device server currently includes some simple file caching services, to reduce the interaction with AWS.
The main text to speech and audio playback code has been separated out into a static library that is linked to both the device server and the unit tests. This separation allows the TTS functionality to be tested per class, and TTS code developed in isolation to the device server. It also reduces the dependencies of the unit tests.
## Version
The current release version is 0.1.0
## Documentation
## Building
Ensure the dependencies are installed before build.
### Dependencies
TextToSpeech has a number of dependencies both in its toolchain and shared library linkage. Dependencies have been broken down and are as follows:
#### Libraries
* Amazon AWS SDK for C++. This is available from [[github|https://github.com/aws/aws-sdk-cpp]].
* The AWS SDK has several dependencies of its own, including libcurl, libopenssl and zlib. To compile the AWS SDK the development version of these dependencies must be installed. A compiled version is provided under /libs. This has been compiled and linked on Debian 9, if using these copy to an appropriate location within the library search path.
* PulseAudio development library libpulse-dev and headers.
* Suggest using a debian package, since this will resolve the dependencies correctly.
* Tango Controls 9 or higher.
* omniORB release 4 - libomniorb4 and libomnithread.
* libzmq - libzmq3-dev or libzmq5-dev.
#### Toolchain Dependencies
* C++14 compliant compiler and std++ library. The device server uses some modern C++ features, including the filesystem API (from C++14), threading, lamda's, futures (from C++11) etc.
* CMake 3.0.0 or greater is required to perform the build.
* Debian 9 (Stretch) as a compilation environment.
### Build Flags
| Flag | Default | Use |
|------|---------|-----|
|TEXT_TO_SPEECH_BUILD_TESTS|ON|Build unit tests|
|TEXT_TO_SPEECH_BUILD_DEBUG_SYMBOLS|OFF|Build the device server with debug systems|
|TTS_ENABLE_DEBUG|ON|Build the subsystem tts_library with debug, this is pipped to tango output|
|TTS_ENABLE_TRACING|OFF|Build the subsystem tts_library with full code tracing|
### Build
#### TextToSpeech Device Server
The build must be out of source, so first create a build directory:
```
mkdir build
cd build
```
This device server uses the tango.pc package config file to configure the build system. When tango is installed on linux (by package or source install), the tango.pc file is also installed. This will be picked up by default when cmake attempts to configure the build system.
Its possible to redirect cmakes search to find a particular tango.pc file. This can be done simply by setting an environment variable:
```
export PKG_CONFIG_PATH=/segfs/tango/release/debian9/lib/pkconfig
cmake ..
```
Or for the command itself:
```
PKG_CONFIG_PATH=/segfs/tango/release/debian9/lib/pkconfig cmake ..
```
Now build with make:
```
make
```
#### Assets
A second target exists to copy and convert the audio assets into raw pcm files (this is the format supported by the TextToSpeech device server currently). This must be run before testing the device server from the build directory, since it will provide a number of jingles for the device server. Once converted, these audio assets should be deployed with the device server. To run the copy and conversion:
```
make convert-audio
```
## Installation
Along with the binary, the TextToSpeech device server requires a small script to configure the AWS keys and some pre-converted audio files.
## Running Tests
The tts_library is covered by a number of unit tests to verify its functionality. There are based on the Catch2 Unit Test framework and are built by default (since TEXT_TO_SPEECH_BUILD_TESTS is set to ON). The tests require both a working internet connection (for AWS Polly) and sound hardware (for PulseAudio). To run the tests from the build directory:
```bash
./tests/unit-tests
```
To look at the available tests and tags, should you wish to run a subset of the test suite (for example, you do not have sound hardware), then tests and be listed:
```bash
./bin/unit-tests --list-tests
```
Or:
```bash
./bin/unit-tests --list-tags
```
To see more options for the unit-test command line binary:
```bash
./bin/unit-tests --help
```
## License
The code is released under the GPL3 license and a copy of this license is provided with the code.
\ No newline at end of file
#!/bin/bash
for i in *;
do name=`echo $i | cut -d'.' -f1`;
echo $name;
ffmpeg -y -i "$i" -ar 8000 -f s16le -acodec pcm_s16le "${name}.pcm";
done
#!/bin/bash
# remove old pcm files
rm $1/*.pcm
# convert everything in the directory
for filename in $1/*; do
name=`echo $filename | cut -d'.' -f1`;
echo $name;
ffmpeg -y -i "$filename" -ar 8000 -f s16le -acodec pcm_s16le "${name}.pcm";
done
#!/bin/bash
export AWS_ACCESS_KEY_ID=AKIAJYJ6YWMGMCJLYZZQ
export AWS_SECRET_ACCESS_KEY=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
......@@ -25,6 +25,31 @@ using namespace std;
using namespace TTSLibrary;
using namespace Catch;
SCENARIO("Initalise PollyTTSDriver", "[pollytts][connected]" )
{
GIVEN("A PollyTTSDriver object")
{
REQUIRE(getenv("AWS_ACCESS_KEY_ID"));
REQUIRE(getenv("AWS_SECRET_ACCESS_KEY"));
PollyTTSDriver tts_driver;
WHEN("initialise() called with valid default proxy")
{
THEN("No exception is thrown")
{
REQUIRE_NOTHROW(tts_driver.initialise());
}
}
WHEN("initialise() called with an invalid proxy")
{
THEN("An exception is thrown")
{
REQUIRE_THROWS(tts_driver.initialise("proxy.invalid.fr", 8000));
}
}
}
}
SCENARIO("Request available voice", "[pollytts][connected]" )
{
GIVEN("Correctly configured PollyDriver and environment")
......@@ -97,7 +122,14 @@ SCENARIO("Requesting speech", "[pollytts][connected]" )
REQUIRE(buffer->size() > 0);
REQUIRE(buffer.use_count() == 1);
}
}
}
AND_WHEN("An invalid voice is requested")
{
THEN("An exception is raised")
{
REQUIRE_THROWS(tts_driver.getSpeechBuffer("Invalid test", "Invalid voice"));
}
}
}
}
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ unset(LIBRARIES)
unset(LIBRARY_PATHS)
# Options
option(TTS_ENABLE_TRACING "Enable tracing on all function calls" ON)
option(TTS_ENABLE_TRACING "Enable tracing on all function calls" OFF)
option(TTS_ENABLE_DEBUG "Enable debugging output" ON)
if(TTS_ENABLE_TRACING)
......
......@@ -56,7 +56,7 @@ PollyTTSDriver::~PollyTTSDriver()
//=============================================================================
//=============================================================================
void PollyTTSDriver::initialise()
void PollyTTSDriver::initialise(const std::string &proxy, int proxy_port)
{
TRACE_LOGGER;
LOG(Debug) << "Init Driver" << endl;
......@@ -68,8 +68,8 @@ void PollyTTSDriver::initialise()
// todo optionize this
ClientConfiguration config;
config.proxyHost = ProxyAddress.c_str();
config.proxyPort = ProxyPort;
config.proxyHost = proxy.c_str();
config.proxyPort = proxy_port;
_polly_client = Aws::MakeShared<PollyClient>(AppName.c_str(), config);
......
......@@ -21,6 +21,7 @@
#define _POLLY_TTSDRIVER_HPP
#include "TTSDataTypes.hpp"
#include "TTSDefines.hpp"
#include <string>
#include <vector>
#include <aws/core/Aws.h>
......@@ -42,7 +43,10 @@ public:
~PollyTTSDriver();
// This call will connect to amazon services
void initialise();
void initialise(
const std::string &proxy = ProxyAddress,
int proxy_port = ProxyPort);
void destroy();
// Voice selection API
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment