Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/speak/espeak.py
diff options
context:
space:
mode:
Diffstat (limited to 'speak/espeak.py')
-rw-r--r--speak/espeak.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/speak/espeak.py b/speak/espeak.py
index 389045d..70610c8 100644
--- a/speak/espeak.py
+++ b/speak/espeak.py
@@ -12,8 +12,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-import gst
-import gobject
+import gi.repository import Gst
+from gi.repository import GObject
import subprocess
import logging
@@ -21,27 +21,27 @@ logger = logging.getLogger('speak')
supported = True
-class BaseAudioGrab(gobject.GObject):
+class BaseAudioGrab(GObject.GObject):
__gsignals__ = {
- 'new-buffer': (gobject.SIGNAL_RUN_FIRST, None, [gobject.TYPE_PYOBJECT])
+ 'new-buffer': (GObject.SIGNAL_RUN_FIRST, None, [GObject.TYPE_PYOBJECT])
}
def __init__(self):
- gobject.GObject.__init__(self)
+ GObject.GObject.__init__(self)
self.pipeline = None
self.quiet = True
def restart_sound_device(self):
self.quiet = False
- self.pipeline.set_state(gst.STATE_NULL)
- self.pipeline.set_state(gst.STATE_PLAYING)
+ self.pipeline.set_state(Gst.STATE_NULL)
+ self.pipeline.set_state(Gst.STATE_PLAYING)
def stop_sound_device(self):
if self.pipeline is None:
return
- self.pipeline.set_state(gst.STATE_NULL)
+ self.pipeline.set_state(Gst.STATE_NULL)
# Shut theirs mouths down
self._new_buffer('')
@@ -55,7 +55,7 @@ class BaseAudioGrab(gobject.GObject):
# build a pipeline that reads the given file
# and sends it to both the real audio output
# and a fake one that we use to draw from
- self.pipeline = gst.parse_launch(
+ self.pipeline = Gst.parse_launch(
cmd + ' ' \
'! decodebin ' \
'! tee name=tee ' \
@@ -66,17 +66,17 @@ class BaseAudioGrab(gobject.GObject):
def on_buffer(element, buffer, pad):
# we got a new buffer of data, ask for another
- gobject.timeout_add(100, self._new_buffer, str(buffer))
+ GObject.timeout_add(100, self._new_buffer, str(buffer))
return True
sink = self.pipeline.get_by_name('sink')
sink.props.signal_handoffs = True
sink.connect('handoff', on_buffer)
- def gstmessage_cb(bus, message):
+ def Gstmessage_cb(bus, message):
self._was_message = True
- if message.type == gst.MESSAGE_WARNING:
+ if message.type == Gst.MESSAGE_WARNING:
def check_after_warnings():
if not self._was_message:
self.stop_sound_device()
@@ -84,16 +84,16 @@ class BaseAudioGrab(gobject.GObject):
logger.debug(message.type)
self._was_message = False
- gobject.timeout_add(500, self._new_buffer, str(buffer))
+ GObject.timeout_add(500, self._new_buffer, str(buffer))
- elif message.type in (gst.MESSAGE_EOS, gst.MESSAGE_ERROR):
+ elif message.type in (Gst.MESSAGE_EOS, Gst.MESSAGE_ERROR):
logger.debug(message.type)
self.stop_sound_device()
self._was_message = False
bus = self.pipeline.get_bus()
bus.add_signal_watch()
- bus.connect('message', gstmessage_cb)
+ bus.connect('message', Gstmessage_cb)
def _new_buffer(self, buf):
if not self.quiet:
@@ -103,13 +103,13 @@ class BaseAudioGrab(gobject.GObject):
# load proper espeak plugin
try:
- import gst
- gst.element_factory_make('espeak')
- from espeak_gst import AudioGrabGst as AudioGrab
- from espeak_gst import *
- logger.info('use gst-plugins-espeak')
+ import Gst
+ Gst.ElementFactory.make('espeak', None)
+ from espeak_Gst import AudioGrabGst as AudioGrab
+ from espeak_Gst import *
+ logger.info('use Gst-plugins-espeak')
except Exception, e:
- logger.info('disable gst-plugins-espeak: %s' % e)
+ logger.info('disable Gst-plugins-espeak: %s' % e)
if subprocess.call('which espeak', shell=True) == 0:
from espeak_cmd import AudioGrabCmd as AudioGrab
from espeak_cmd import *