Say Hello World (DEPRECATED)

On this page

<< return to C++ examples

The aim of this example is to demonstrate how to use the specialized proxy to ALTextToSpeech. This example will make NAO say “Hello World”.

The complete example is available here

Source file:


 * Copyright (c) 2011 Aldebaran Robotics. All Rights Reserved
 * \file sayhelloworld.cpp
 * \brief Make NAO say a short phrase.
 * A simple example showing how to make NAO say a short phrase using the
 * specialized proxy ALTextToSpeechProxy.

#include <iostream>
#include <alerror/alerror.h>
#include <alproxies/altexttospeechproxy.h>

int main(int argc, char* argv[])
  if(argc != 2)
    std::cerr << "Wrong number of arguments!" << std::endl;
    std::cerr << "Usage: say NAO_IP" << std::endl;

  /** The desired phrase to be said. */
  const std::string phraseToSay = "Hello world";
    /** Create an ALTextToSpeechProxy so that we can call the say method
    * Arguments for the constructor are:
    *  - IP of the robot
    *  - port on which NAOqi is listening. Default is 9559
    AL::ALTextToSpeechProxy tts(argv[1], 9559);

    /** Call the say method */
  catch (const AL::ALError& e)
    std::cerr << "Caught exception: " << e.what() << std::endl;



The corresponding CMakeLists.txt file is the following:


# Copyright (c) 2011 Aldebaran Robotics. All Rights Reserved.

cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR)
# Give a name to the project.
# This include enable you to use qibuild framework

# Create an executable named sayhelloworld,
# with the source file : sayhelloworld.cpp
qi_create_bin(sayhelloworld sayhelloworld.cpp)

# Tell CMake that sayhelloworld depends on ALCOMMON and ALPROXIES
# This will set the libraries to link sayhelloworld with,
# the include paths, and so on
qi_use_lib(sayhelloworld ALCOMMON ALPROXIES)