Changes

Jump to navigation Jump to search
Line 108: Line 108:     
==== Track marks example ====
 
==== Track marks example ====
 +
 +
  import gtk
 +
  import gst<br>
 +
  text = '<mark name="mark to Hello"/>Hello, <mark name="mark for World"/>World!'<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-mark':
 +
          offset = message.structure['offset']
 +
          mark = message.structure['mark']
 +
          print '%d:%s' % (offset, mark)<br>
 +
  pipe = gst.Pipeline('pipeline')<br>
 +
  src = gst.element_factory_make('espeak', 'src')
 +
  src.props.text = text
 +
  src.props.track = 2
 +
  src.props.gap = 100
 +
  pipe.add(src)<br>
 +
  sink = gst.element_factory_make('autoaudiosink', 'sink')
 +
  pipe.add(sink)
 +
  src.link(sink)<br>
 +
  bus = pipe.get_bus()
 +
  bus.add_signal_watch()
 +
  bus.connect('message', gstmessage_cb, pipe)<br>
 +
  pipe.set_state(gst.STATE_PLAYING)<br>
 +
  gtk.main()
    
=== Resources ===
 
=== Resources ===
 
* [http://git.sugarlabs.org/projects/gst-plugins-espeak Sources]
 
* [http://git.sugarlabs.org/projects/gst-plugins-espeak Sources]
 
* [http://download.sugarlabs.org/sources/honey/gst-plugins-espeak/ Tarballs]
 
* [http://download.sugarlabs.org/sources/honey/gst-plugins-espeak/ Tarballs]

Navigation menu