Activity Team/gst-plugins-espeak: Difference between revisions

Line 81: Line 81:


==== Track words example ====
==== Track words example ====
  import gtk
  import gst<br>
  text = file(__file__, 'r').read()<br>
  def gstmessage_cb(bus, message, pipe):
      if message.type in (gst.MESSAGE_EOS, gst.MESSAGE_ERROR):
          pipe.set_state(gst.STATE_NULL)
      elif message.type == gst.MESSAGE_ELEMENT and \
              message.structure.get_name() == 'espeak-word':
          offset = message.structure['offset']
          len = message.structure['len']
          print text[offset:offset+len]<br>
  pipe = gst.Pipeline('pipeline')<br>
  src = gst.element_factory_make('espeak', 'src')
  src.props.text = text
  src.props.track = 1
  pipe.add(src)<br>
  sink = gst.element_factory_make('autoaudiosink', 'sink')
  pipe.add(sink)
  src.link(sink)<br>
  bus = pipe.get_bus()
  jbus.add_signal_watch()
  bus.connect('message', gstmessage_cb, pipe)<br>
  pipe.set_state(gst.STATE_PLAYING)<br>
  gtk.main()


==== Track marks example ====
==== Track marks example ====