Skip to content

Commit ba2c506

Browse files
authored
Merge pull request #12 from ouspg/521275A-2023-speech-synthesis
521275 a 2023 speech synthesis
2 parents 40b5ed2 + 1936c68 commit ba2c506

File tree

18 files changed

+375
-1
lines changed

18 files changed

+375
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
.vscode/*
88
!.vscode/c_cpp_properties.json
99

10+
src/tts_package/resource/*
11+
src/tts_package/resource/config.json
12+
src/tts_package/resource/model.pth
13+
src/tts_package/resource/output.wav
1014

1115
build
1216
devel

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Joint -> Servo mappings are defined in two files. Configuration file connects se
2424
* src/inmoov_description - robot files, which define the robot geometry and configuration for simulation (URDF, SRDF & rviz configuration)
2525
* src/robot - robot launch files & servo controller configurations
2626
* src/robot_hardware - hardware interface for ros2_controller, communicates with U2D2 via dynamixel workbench
27+
* src/tts_package - Text-to-speech package for finnish speech synthesis
2728

2829
## Servo Table
2930

docs/BRINGUP.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,22 @@ Anyway, you are able to test the face tracking and eye movements like this.
5555

5656
**Note: currently, only jaw, eyes, right hand & head pan movement can be simulated**
5757

58+
### Launching text-to-speech service
59+
60+
Text-to-speech works as a service which can be called from terminal utilizing the ros2 client in package.
61+
62+
Run the service in a (new) terminal
63+
64+
```console
65+
ros2 run tts_package service
66+
```
67+
68+
Call the service from terminal using client and synthetize speech
69+
70+
```console
71+
ros2 run tts_package client "Tämä lause syntentisoidaan puheeksi."
72+
```
73+
5874
## Bring-up real HW robot
5975

6076
### (0. Test servo communication)
@@ -142,6 +158,22 @@ Finally, start the eye movement node in a new terminal window
142158
ros2 run eye_movement eye_movement_node
143159
```
144160

161+
### 5. Launching text-to-speech service
162+
163+
Text-to-speech works as a service which can be called from terminal utilizing the ros2 client in package.
164+
165+
Run the service in a (new) terminal
166+
167+
```console
168+
ros2 run tts_package service
169+
```
170+
171+
Call the service from terminal using client and synthetize speech
172+
173+
```console
174+
ros2 run tts_package client "Tämä lause syntentisoidaan puheeksi."
175+
```
176+
145177
**Todo: simplify bring up process (add the starting of the controllers to the launch file)**
146178

147179
## Sending action goals manually

src/tts_msgs/CMakeLists.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(tts_msgs)
3+
4+
# Default to C99
5+
if(NOT CMAKE_C_STANDARD)
6+
set(CMAKE_C_STANDARD 99)
7+
endif()
8+
9+
# Default to C++14
10+
if(NOT CMAKE_CXX_STANDARD)
11+
set(CMAKE_CXX_STANDARD 14)
12+
endif()
13+
14+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
15+
add_compile_options(-Wall -Wextra -Wpedantic)
16+
endif()
17+
18+
# find dependencies
19+
find_package(ament_cmake REQUIRED)
20+
# uncomment the following section in order to fill in
21+
# further dependencies manually.
22+
# find_package(<dependency> REQUIRED)
23+
find_package(rosidl_default_generators REQUIRED)
24+
25+
rosidl_generate_interfaces(${PROJECT_NAME}
26+
"srv/StringToWav.srv"
27+
)
28+
29+
if(BUILD_TESTING)
30+
find_package(ament_lint_auto REQUIRED)
31+
# the following line skips the linter which checks for copyrights
32+
# uncomment the line when a copyright and license is not present in all source files
33+
#set(ament_cmake_copyright_FOUND TRUE)
34+
# the following line skips cpplint (only works in a git repo)
35+
# uncomment the line when this package is not in a git repo
36+
#set(ament_cmake_cpplint_FOUND TRUE)
37+
ament_lint_auto_find_test_dependencies()
38+
endif()
39+
40+
ament_package()

src/tts_msgs/package.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>tts_msgs</name>
5+
<version>1.0.0</version>
6+
<description>Interface for tts_package</description>
7+
<maintainer email="[email protected]">Konsta Laurila</maintainer>
8+
<license>TODO: License declaration</license>
9+
10+
<buildtool_depend>ament_cmake</buildtool_depend>
11+
12+
<test_depend>ament_lint_auto</test_depend>
13+
<test_depend>ament_lint_common</test_depend>
14+
15+
<depend>geometry_msgs</depend>
16+
<buildtool_depend>rosidl_default_generators</buildtool_depend>
17+
<exec_depend>rosidl_default_runtime</exec_depend>
18+
<member_of_group>rosidl_interface_packages</member_of_group>
19+
20+
<export>
21+
<build_type>ament_cmake</build_type>
22+
</export>
23+
</package>

src/tts_msgs/srv/StringToWav.srv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
string data
2+
---
3+
bool success

src/tts_package/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
This package contains service and client for finnish text-to-speech feature. Service will automatically play synthesized speech when called with wanted sentence as an argument.
2+
3+
# Usage
4+
5+
## Before
6+
Check that model.pth and config.json are located in src/tts_package/resource/ folder. These should be downloaded and installed automatically when installing environment with vagrant. Scripts located in /vagrant-scripts/bootstrap.sh.
7+
8+
## Dependencies
9+
10+
* `TTS`
11+
* `espeak-ng`
12+
* `simpleaudio`
13+
14+
These are included in the newest version of the vagrantfile. If these are not installed during bootstrap, they need to be installed to VM before starting the service.
15+
16+
Install TTS
17+
> pip install TTS <br>
18+
19+
And install espeak
20+
> apt -y install espeak
21+
22+
## Run TTS service
23+
> ros2 run tts_package service
24+
25+
26+
## Using the service
27+
Service can be used by calling client with terminal, giving sentences as an argument. Note that sentences should be inside quotes and in finnish.
28+
> ros2 run tts_package client "Hei. Tässä on lause joka syntentisoidaan puheeksi."
29+
30+
Service will now try to synthentize sentence into .wav file located in 'src/tts_package/resource/output.wav' which will then be played automatically.
31+
32+
## Potential future improvements
33+
34+
* Implement this feature to work with potential speech-to-text and chatbot features.

src/tts_package/package.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>tts_package</name>
5+
<version>1.0.0</version>
6+
<description>Text-to-speech pacakge for synthetizing speech.</description>
7+
<maintainer email="[email protected]">Konsta Laurila</maintainer>
8+
<license>TODO: License declaration</license>
9+
10+
<depend>python3-TTS</depend>
11+
<depend>python3-simpleaudio</depend>
12+
13+
<exec_depend>tts_msgs</exec_depend>
14+
15+
<test_depend>ament_copyright</test_depend>
16+
<test_depend>ament_flake8</test_depend>
17+
<test_depend>ament_pep257</test_depend>
18+
<test_depend>python3-pytest</test_depend>
19+
20+
<export>
21+
<build_type>ament_python</build_type>
22+
</export>
23+
</package>

src/tts_package/resource/tts_package

Whitespace-only changes.

src/tts_package/setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[develop]
2+
script-dir=$base/lib/tts_package
3+
[install]
4+
install-scripts=$base/lib/tts_package

0 commit comments

Comments
 (0)