QTrobot Sound and Speech
QTrobot has double speakers powered by 2.8W stereo amplifier. The speakers are connected to Raspberry PI (QTRP) audio analog output via the amplifier. That provides a standard Linux audio device which you can use freely for playing sounds.
Software Interface
The qt_robot_interface
ROS node is the QTrobot's driver for speech and audio. This node implements varieties of ROS interfaces including Speech Interface for Text-to-Speech and the Audio Interface for playing any audio files.
Speech
The QTrobot's Text-to-Speech service is based on Acapela software. Depends on your robot and purchased languages/voices, the Acapela pre-installed voice data can be found in ~/robot/acapela/voices
folder. The default language along with other properties such as speed and pitch are configured using /opt/ros/noetic/share/qt_robot_interface/config/qtrobot-interface.yaml
config file. Under speech section you will see corresponding lines.
speech:
engine: acapela
acapela:
path: '/home/qtrobot/robot/acapela/'
language: en_US
speed: 80
pitch: 150
voices:
en_US: enu_ella_22k_ns.qvcu
en_SP: enu_valeriaenglish_22k_ns.qvcu
de_DE: ged_lea_22k_ns.qvcu
fr_FR: frf_valentin_22k_ns.qvcu
...
Audio
QTrobot audio interface can play standard audio files with mp3
or wav
format. The default folder where the interface looks for the audio files is ~/robot/data/audios
. QTrobot comes with some audio examples. You can play any audio file that is in the audios
folder using service call or ROS publish command as shown bellow. You can also play audio files using Educator tablet.
Publisher:
rostopic pub /qt_robot/audio/play std_msgs/String "data: 'QT/Komiku_Glouglou'"
Service call:
rosservice call /qt_robot/audio/play "filename: 'QT/Komiku_Glouglou'
filepath: ''"
As it shown in the above example, you do not need to give the audio's file extension (.wav
or .mp3
) to the interface!
How to play custom audio?
To play custom audio file, you first need to copy it in the default audios data folder (~/robot/data/audios
) on QTRP. Next you can repeat any of above shown command to play your audio on QTrobot speakers. Let's look at the example.
- Audio name: "song.wav"
- Audio path: "~/robot/data/audios/song.wav"
Example:
rostopic pub /qt_robot/audio/play std_msgs/String "data: 'song'"
How to adjust the volume?
You can change the volume of the speaker in different way:
- Using Educator tablet app
- Calling
/qt_robot/setting/setVolume
ROS service (via coding, command line ROS commands or QTrobot Visual scripting) - Using standard Linux tools such as
alsamixer
Adjusting volume using ROS service call:
rosservice call /qt_robot/setting/setVolume "volume: 60"
Adjusting volume using alsamixer of QTRP:
Access QTRP terminal via SSH and run alsamixer
command. Select the bcm2835 Headphone sound card by pressing F6
and finally use keyboard arrows up/down to change the volume.