Step3: Testing Voice Synthesis Component

Here we will learn how to use text-to-speech component.

Preparation

  1. Preparation of test components

Test component will output a text data in some period. Please create a test program as follows.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import time
import OpenRTM_aist
import RTC
 
consolein_spec = ["implementation_id", "ConsoleIn",
                  "type_name",         "ConsoleIn",
                  "description",       "Console input component",
                  "version",           "1.0",
                  "vendor",            "sample",
                  "category",          "example",
                  "activity_type",     "DataFlowComponent",
                  "max_instance",      "10",
                  "language",          "Python",
                  "lang_type",         "script",
                  ""]
 
class ConsoleIn(OpenRTM_aist.DataFlowComponentBase):
    def __init__(self, manager):
        OpenRTM_aist.DataFlowComponentBase.__init__(self, manager)
        self._data = RTC.TimedString(RTC.Time(0,0),"")
        self._outport = OpenRTM_aist.OutPort("out", self._data)
 
    def onInitialize(self):
        self.registerOutPort("out", self._outport)
        return RTC.RTC_OK
 
    def onExecute(self, ec_id):
        self._data.data = "testing"
        OpenRTM_aist.setTimestamp(self._data)
        self._outport.write()
        time.sleep(5)
        return RTC.RTC_OK
 
def MyModuleInit(manager):
    profile = OpenRTM_aist.Properties(defaults_str=consolein_spec)
    manager.registerFactory(profile,
                            ConsoleIn,
                            OpenRTM_aist.Delete)
    comp = manager.createComponent("ConsoleIn")
 
def main():
    mgr = OpenRTM_aist.Manager.init(sys.argv)
    mgr.setModuleInitProc(MyModuleInit)
    mgr.activateManager()
    mgr.runManager()
 
if __name__ == "__main__":
    main()

We will call this component “ConsoleIn component” hereafter..

  1. Prepare the rtc.conf

Test procedures

  1. Start the ConsoleIn and Festival components.
Open two terminals and enter following commands respectively
% python ConsoleIn.py
% festivalrtc

Make sure you start naming service view component is displayed.

../_images/ss_jtalk01.png
  1. Place the ConsoleIn and Festival component to RT System Editor.

Drag and drop the components to the editor panel.

../_images/ss_jtalk02.png
  1. Remove the links between AudioInput-AudioOutput.

Select the link and choose “Delete” from the right-click menu.

../_images/ss_jtalk03.png
  1. Connect the ConsoleIn, Festival, and AudioOutput, respectively.
  • Connect ConsoleIn output port and Festival input port.
  • Connect the Festival “result” output port and AudioOutput input port.

(Please be careful not to connect to the different port. )

../_images/ss_jtalk04.png
  1. Activate and verify the behavior.

Press “All Activate” button to activate all the components.

Verify the text you set the ConsoleIn component is synthesized as audio.

In the next step, we will create a complete dialog system by connecting the speech recognition component.

Proceed to Step4: Creating Dialog System.