Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/espeak_gst_1.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/espeak_gst_1.py')
-rw-r--r--tests/espeak_gst_1.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/espeak_gst_1.py b/tests/espeak_gst_1.py
new file mode 100644
index 0000000..ef9402f
--- /dev/null
+++ b/tests/espeak_gst_1.py
@@ -0,0 +1,63 @@
+from gi.repository import Gtk
+from gi.repository import Gst
+from gi.repository import GObject
+
+GObject.threads_init()
+
+import gi
+gi.require_version('Gtk', '3.0')
+gi.require_version('Gst', '1.0')
+
+Gst.init(None)
+
+# pipeline = None
+# bus = None
+
+
+def _destroy_cb(widget, data=None):
+ Gtk.main_quit()
+
+window = Gtk.Window()
+window.set_default_size(100, 40)
+window.connect("destroy", _destroy_cb)
+
+
+def pipe_message_cb(bus, message, pipeline):
+ if message.type == Gst.MessageType.EOS:
+ print 'EOS'
+ pipeline.set_state(Gst.State.NULL)
+ elif message.type == Gst.MessageType.ERROR:
+ print 'ERROR'
+ pipeline.set_state(Gst.State.NULL)
+ print Gst.Message.parse_error(message)
+ # else:
+ # print 'Error'
+ # print message.type
+
+
+def play(*args, **kargs):
+ # global pipeline, bus
+
+ pipeline = Gst.parse_launch('espeak name=espeak ! autovideosink')
+
+ bus = pipeline.get_bus()
+ bus.add_signal_watch()
+ bus.connect('message', pipe_message_cb, pipeline)
+
+ src = pipeline.get_by_name('espeak')
+
+ src.props.text = 'Hello Manuel Kaufmann. Please, type something'
+ src.props.rate = 0
+ src.props.pitch = 0
+ src.props.voice = 'default'
+ # src.props.voice = 'en_GB.utf8'
+ src.props.track = 2
+
+ # pipeline.set_state(Gst.State.NULL)
+ pipeline.set_state(Gst.State.PLAYING)
+
+button = Gtk.Button('Click me!')
+button.connect('clicked', play)
+window.add(button)
+window.show_all()
+Gtk.main()